Completed
Push — master ( b8bf1c...02faf6 )
by Yannick
10:43
created
manufacturer-statistics-departure-airport.php 3 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -8,13 +8,13 @@  discard block
 block discarded – undo
8 8
         die();
9 9
 }
10 10
 $Spotter = new Spotter();
11
-$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING)));
12
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
13
-$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,"0,1", $sort);
11
+$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'aircraft_manufacturer', FILTER_SANITIZE_STRING)));
12
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
13
+$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, "0,1", $sort);
14 14
 
15 15
 if (!empty($spotter_array))
16 16
 {
17
-	$title = sprintf(_("Most Common Departure Airports from %s"),$manufacturer);
17
+	$title = sprintf(_("Most Common Departure Airports from %s"), $manufacturer);
18 18
 
19 19
 	require_once('header.php');
20 20
 	print '<div class="select-item">';
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
 	$Stats = new Stats();
24 24
 	$all_manufacturers = $Stats->getAllManufacturers();
25 25
 	if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers();
26
-	foreach($all_manufacturers as $all_manufacturer)
26
+	foreach ($all_manufacturers as $all_manufacturer)
27 27
 	{
28
-		if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
28
+		if ($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
29 29
 		{
30 30
 			print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>';
31 31
 		} else {
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	include('manufacturer-sub-menu.php');
45 45
 	print '<div class="column">';
46 46
 	print '<h2>'._("Most Common Departure Airports").'</h2>';
47
-	print '<p>'.sprintf(_("The statistic below shows all departure airports of flights from <strong>%s</strong>."),$manufacturer).'</p>';
47
+	print '<p>'.sprintf(_("The statistic below shows all departure airports of flights from <strong>%s</strong>."), $manufacturer).'</p>';
48 48
 	$airport_airport_array = $Spotter->countAllDepartureAirportsByManufacturer($manufacturer);
49 49
 	print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>
50 50
     	<script>
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         	["'._("Airport").'", "'._("# of times").'"],';
60 60
 
61 61
 	$airport_data = '';
62
-	foreach($airport_airport_array as $airport_item)
62
+	foreach ($airport_airport_array as $airport_item)
63 63
 	{
64 64
 		$name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')';
65 65
 		$name = str_replace("'", "", $name);
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	print '</thead>';
99 99
 	print '<tbody>';
100 100
 	$i = 1;
101
-	foreach($airport_airport_array as $airport_item)
101
+	foreach ($airport_airport_array as $airport_item)
102 102
 	{
103 103
 		print '<tr>';
104 104
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@
 block discarded – undo
22 22
 	print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
23 23
 	$Stats = new Stats();
24 24
 	$all_manufacturers = $Stats->getAllManufacturers();
25
-	if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers();
25
+	if (empty($all_manufacturers)) {
26
+		$all_manufacturers = $Spotter->getAllManufacturers();
27
+	}
26 28
 	foreach($all_manufacturers as $all_manufacturer)
27 29
 	{
28 30
 		if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 require_once('require/class.Stats.php');
5 5
 require_once('require/class.Language.php');
6 6
 if (!isset($_GET['aircraft_manufacturer'])) {
7
-        header('Location: '.$globalURL.'/manufacturer');
8
-        die();
7
+		header('Location: '.$globalURL.'/manufacturer');
8
+		die();
9 9
 }
10 10
 $Spotter = new Spotter();
11 11
 $manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING)));
Please login to merge, or discard this patch.
aircraft.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
 	if (empty($aircraft_types) || $aircraft_types[0]['aircraft_manufacturer'] == '') $aircraft_types = $Spotter->getAllAircraftTypes();
20 20
 	$previous = null;
21 21
 	print '<div class="alphabet-legend">';
22
-	foreach($aircraft_types as $value) {
22
+	foreach ($aircraft_types as $value) {
23 23
 		//$firstLetter = substr($value['aircraft_name'], 0, 1);
24 24
 		$firstLetter = substr($value['aircraft_manufacturer'], 0, 1);
25
-		if($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')')
25
+		if ($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')')
26 26
 		{
27 27
 			if ($previous !== null) print ' | ';
28 28
 			print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>';
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 	}
32 32
 	print '</div>';
33 33
 	$previous = null;
34
-	foreach($aircraft_types as $value) {
34
+	foreach ($aircraft_types as $value) {
35 35
 		//$firstLetter = substr($value['aircraft_name'], 0, 1);
36 36
 		$firstLetter = substr($value['aircraft_manufacturer'], 0, 1);
37 37
 		if ($firstLetter != "")
38 38
 		{
39
-			if($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')')
39
+			if ($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')')
40 40
 			{
41 41
 				if ($previous !== null) print '</div>';
42 42
 				print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">';
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 	print '<h1>'._("Aircrafts Types").'</h1>';
17 17
 
18 18
 	$aircraft_types = $Stats->getAllAircraftTypes();
19
-	if (empty($aircraft_types) || $aircraft_types[0]['aircraft_manufacturer'] == '') $aircraft_types = $Spotter->getAllAircraftTypes();
19
+	if (empty($aircraft_types) || $aircraft_types[0]['aircraft_manufacturer'] == '') {
20
+		$aircraft_types = $Spotter->getAllAircraftTypes();
21
+	}
20 22
 	$previous = null;
21 23
 	print '<div class="alphabet-legend">';
22 24
 	foreach($aircraft_types as $value) {
@@ -24,10 +26,14 @@  discard block
 block discarded – undo
24 26
 		$firstLetter = substr($value['aircraft_manufacturer'], 0, 1);
25 27
 		if($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')')
26 28
 		{
27
-			if ($previous !== null) print ' | ';
29
+			if ($previous !== null) {
30
+				print ' | ';
31
+			}
28 32
 			print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>';
29 33
 		}
30
-		if ($firstLetter != '(' && $firstLetter != ')') $previous = $firstLetter;
34
+		if ($firstLetter != '(' && $firstLetter != ')') {
35
+			$previous = $firstLetter;
36
+		}
31 37
 	}
32 38
 	print '</div>';
33 39
 	$previous = null;
@@ -38,10 +44,14 @@  discard block
 block discarded – undo
38 44
 		{
39 45
 			if($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')')
40 46
 			{
41
-				if ($previous !== null) print '</div>';
47
+				if ($previous !== null) {
48
+					print '</div>';
49
+				}
42 50
 				print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">';
43 51
 			}
44
-			if ($firstLetter != '(' && $firstLetter != ')') $previous = $firstLetter;
52
+			if ($firstLetter != '(' && $firstLetter != ')') {
53
+				$previous = $firstLetter;
54
+			}
45 55
 			print '<div class="alphabet-item">';
46 56
 			print '<a href="'.$globalURL.'/aircraft/'.$value['aircraft_icao'].'">';
47 57
 			if ($value['aircraft_name'] == '') {
Please login to merge, or discard this patch.
require/class.Accident.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,12 +23,12 @@
 block discarded – undo
23 23
 	}
24 24
 	
25 25
 	/**
26
-	* Get Accidents data from DB
27
-	* @param String $limit Limit
28
-	* @param String $type Set type accident or incident
29
-	* @param String $date get data for a date
30
-	* @return Array Return Accidents data in array
31
-	*/
26
+	 * Get Accidents data from DB
27
+	 * @param String $limit Limit
28
+	 * @param String $type Set type accident or incident
29
+	 * @param String $date get data for a date
30
+	 * @return Array Return Accidents data in array
31
+	 */
32 32
 	public function getAccidentData($limit = '',$type = '',$date = '') {
33 33
 		global $globalURL, $globalDBdriver;
34 34
 		$Image = new Image($this->db);
Please login to merge, or discard this patch.
Braces   +75 added lines, -27 removed lines patch added patch discarded remove patch
@@ -96,8 +96,11 @@  discard block
 block discarded – undo
96 96
 			$data = array();
97 97
 			if ($row['registration'] != '') {
98 98
 				$image_array = $Image->getSpotterImage($row['registration']);
99
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
100
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
99
+				if (count($image_array) > 0) {
100
+					$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
101
+				} else {
102
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
103
+				}
101 104
 				$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
102 105
 				$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
103 106
 				if (!empty($aircraft_info)) {
@@ -113,17 +116,30 @@  discard block
 block discarded – undo
113 116
 					$data['aircraft_base'] = $owner_data['base'];
114 117
 					$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
115 118
 				}
116
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
117
-			if ($row['registration'] == '') $row['registration'] = 'NA';
118
-			if ($row['ident'] == '') $row['ident'] = 'NA';
119
+			} else {
120
+				$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
121
+			}
122
+			if ($row['registration'] == '') {
123
+				$row['registration'] = 'NA';
124
+			}
125
+			if ($row['ident'] == '') {
126
+				$row['ident'] = 'NA';
127
+			}
119 128
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
120 129
 			if (isset($identicao[0])) {
121 130
 				if (substr($row['ident'],0,2) == 'AF') {
122
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
123
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
124
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
131
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
132
+						$icao = $row['ident'];
133
+					} else {
134
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
135
+					}
136
+				} else {
137
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
138
+				}
125 139
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
126
-			} else $icao = $row['ident'];
140
+			} else {
141
+				$icao = $row['ident'];
142
+			}
127 143
 			$icao = $Translation->checkTranslation($icao,false);
128 144
 			//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
129 145
 			if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
@@ -138,10 +154,14 @@  discard block
 block discarded – undo
138 154
 				//else echo 'No data...'."\n";
139 155
 			}
140 156
 			$data = array_merge($row,$data);
141
-			if ($data['ident'] == null) $data['ident'] = $icao;
157
+			if ($data['ident'] == null) {
158
+				$data['ident'] = $icao;
159
+			}
142 160
 			if ($data['title'] == null) {
143 161
 				$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
144
-			} else $data['message'] = strtolower($data['title']);
162
+			} else {
163
+				$data['message'] = strtolower($data['title']);
164
+			}
145 165
 			$ids = $Spotter->getAllIDByRegistration($data['registration']);
146 166
 			$date = $data['date'];
147 167
 			if (isset($ids[$date])) {
@@ -158,8 +178,9 @@  discard block
 block discarded – undo
158 178
 		if (isset($result)) {
159 179
 			$result[0]['query_number_rows'] = $i;
160 180
 			return $result;
181
+		} else {
182
+			return array();
161 183
 		}
162
-		else return array();
163 184
 	}
164 185
 	
165 186
 	/*
@@ -198,7 +219,9 @@  discard block
 block discarded – undo
198 219
 	*/
199 220
 	public function import($file) {
200 221
 		global $globalTransaction, $globalDebug;
201
-		if ($globalDebug) echo 'Import '.$file."\n";
222
+		if ($globalDebug) {
223
+			echo 'Import '.$file."\n";
224
+		}
202 225
 		$result = array();
203 226
 		if (file_exists($file)) {
204 227
 			if (($handle = fopen($file,'r')) !== FALSE) {
@@ -209,8 +232,11 @@  discard block
 block discarded – undo
209 232
 				}
210 233
 				fclose($handle);
211 234
 			}
212
-			if (!empty($result)) $this->add($result,true);
213
-			elseif ($globalDebug) echo 'Nothing to import';
235
+			if (!empty($result)) {
236
+				$this->add($result,true);
237
+			} elseif ($globalDebug) {
238
+				echo 'Nothing to import';
239
+			}
214 240
 		}
215 241
 	}
216 242
 
@@ -246,14 +272,23 @@  discard block
 block discarded – undo
246 272
 					}
247 273
 				}
248 274
 				fclose($handle);
249
-			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
250
-		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
275
+			} elseif ($globalDebug) {
276
+				echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
277
+			}
278
+		} elseif ($globalDebug) {
279
+			echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
280
+		}
251 281
 		$result = $Common->arr_diff($all_md5_new,$all_md5);
252
-		if (empty($result) && $globalDebug) echo 'Nothing to update';
282
+		if (empty($result) && $globalDebug) {
283
+			echo 'Nothing to update';
284
+		}
253 285
 		foreach ($result as $file => $md5) {
254 286
 			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
255
-			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
256
-			elseif ($globalDebug) echo 'Download '.$file.' failed';
287
+			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) {
288
+				$this->import(dirname(__FILE__).'/../install/tmp/'.$file);
289
+			} elseif ($globalDebug) {
290
+				echo 'Download '.$file.' failed';
291
+			}
257 292
 		}
258 293
 	}
259 294
 
@@ -270,13 +305,17 @@  discard block
 block discarded – undo
270 305
 		$Image = new Image();
271 306
 		$Spotter = new Spotter();
272 307
 
273
-		if (empty($crash)) return false;
308
+		if (empty($crash)) {
309
+			return false;
310
+		}
274 311
 		if (!$new) {
275 312
 			$query_delete = 'DELETE FROM accidents WHERE source = :source';
276 313
 			$sthd = $Connection->db->prepare($query_delete);
277 314
 			$sthd->execute(array(':source' => $crash[0]['source']));
278 315
 		}
279
-		if ($globalTransaction) $Connection->db->beginTransaction();
316
+		if ($globalTransaction) {
317
+			$Connection->db->beginTransaction();
318
+		}
280 319
 		$initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null);
281 320
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
282 321
 		$sth_check = $Connection->db->prepare($query_check);
@@ -291,7 +330,9 @@  discard block
 block discarded – undo
291 330
 					return $value === "" ? NULL : $value;
292 331
 				}, $cr);
293 332
 				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
294
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
333
+					if (strpos($cr['registration'],'-') === FALSE) {
334
+						$cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
335
+					}
295 336
 					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
296 337
 					$sth_check->execute($query_check_values);
297 338
 					$result_check = $sth_check->fetch(PDO::FETCH_ASSOC);
@@ -313,9 +354,13 @@  discard block
 block discarded – undo
313 354
 					$Connection->db->beginTransaction();
314 355
 				}
315 356
 			}
316
-			if ($globalTransaction) $Connection->db->commit();
357
+			if ($globalTransaction) {
358
+				$Connection->db->commit();
359
+			}
317 360
 		} catch(PDOException $e) {
318
-			if ($globalTransaction) $Connection->db->rollBack();
361
+			if ($globalTransaction) {
362
+				$Connection->db->rollBack();
363
+			}
319 364
 			echo $e->getMessage();
320 365
 		}
321 366
 		$sth_check->closeCursor();
@@ -354,8 +399,11 @@  discard block
 block discarded – undo
354 399
 			return "error : ".$e->getMessage();
355 400
 		}
356 401
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
357
-		if ($row['nb'] > 0) return false;
358
-		else return true;
402
+		if ($row['nb'] > 0) {
403
+			return false;
404
+		} else {
405
+			return true;
406
+		}
359 407
 	}
360 408
 
361 409
 	public static function insert_last_accidents_update() {
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
29 29
 	* @param String $date get data for a date
30 30
 	* @return Array Return Accidents data in array
31 31
 	*/
32
-	public function getAccidentData($limit = '',$type = '',$date = '') {
32
+	public function getAccidentData($limit = '', $type = '', $date = '') {
33 33
 		global $globalURL, $globalDBdriver;
34 34
 		$Image = new Image($this->db);
35 35
 		$Spotter = new Spotter($this->db);
36 36
 		$Translation = new Translation($this->db);
37
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
37
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
38 38
 		date_default_timezone_set('UTC');
39 39
 		$result = array();
40 40
 		$limit_query = '';
41 41
 		if ($limit != "")
42 42
 		{
43 43
 			$limit_array = explode(",", $limit);
44
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
45
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
44
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
45
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
46 46
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
47 47
 			{
48 48
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -51,29 +51,29 @@  discard block
 block discarded – undo
51 51
 
52 52
 		if ($type != '') {
53 53
 			if ($date != '') {
54
-				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) {
54
+				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) {
55 55
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
56 56
 					//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
57
-					$query_values = array(':type' => $type,':date' => $date);
58
-				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) {
57
+					$query_values = array(':type' => $type, ':date' => $date);
58
+				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) {
59 59
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date BETWEEN :dated AND :datef GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
60
-					$query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31');
61
-				} elseif (preg_match("/^[0-9]{4}$/",$date)) {
60
+					$query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31');
61
+				} elseif (preg_match("/^[0-9]{4}$/", $date)) {
62 62
 					if ($globalDBdriver == 'mysql') {
63 63
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND YEAR(date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
64 64
 					} else {
65 65
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND EXTRACT(YEAR FROM date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
66 66
 					}
67
-					$query_values = array(':type' => $type,':date' => $date);
67
+					$query_values = array(':type' => $type, ':date' => $date);
68 68
 				} else {
69 69
 					$date = $date.'%';
70 70
 					if ($globalDBdriver == 'mysql') {
71 71
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND DATE_FORMAT(date,'%Y-%m-%d') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
72
-						$query_values = array(':type' => $type,':date' => $date);
72
+						$query_values = array(':type' => $type, ':date' => $date);
73 73
 					} else {
74 74
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
75 75
 						//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
76
-						$query_values = array(':type' => $type,':date' => $date);
76
+						$query_values = array(':type' => $type, ':date' => $date);
77 77
 					}
78 78
 				}
79 79
 			} else {
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 			}
84 84
 		} else {
85 85
 			if ($date != '') {
86
-				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) {
86
+				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) {
87 87
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
88 88
 					//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
89 89
 				} else {
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 		try {
103 103
 			$sth = $this->db->prepare($query);
104 104
 			$sth->execute($query_values);
105
-		} catch(PDOException $e) {
105
+		} catch (PDOException $e) {
106 106
 			echo "error : ".$e->getMessage();
107 107
 		}
108 108
 		$i = 0;
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 			$data = array();
113 113
 			if ($row['registration'] != '') {
114 114
 				$image_array = $Image->getSpotterImage($row['registration']);
115
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
116
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
115
+				if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
116
+				else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
117 117
 				$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
118 118
 				$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
119 119
 				if (!empty($aircraft_info)) {
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 					$data['aircraft_name'] = $aircraft_info[0]['type'];
122 122
 					$data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer'];
123 123
 				} else {
124
-					$data = array_merge($data,array('aircraft_type' => 'NA'));
124
+					$data = array_merge($data, array('aircraft_type' => 'NA'));
125 125
 				}
126 126
 				$owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']);
127 127
 				if (!empty($owner_data)) {
@@ -129,18 +129,18 @@  discard block
 block discarded – undo
129 129
 					$data['aircraft_base'] = $owner_data['base'];
130 130
 					$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
131 131
 				}
132
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
132
+			} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
133 133
 			if ($row['registration'] == '') $row['registration'] = 'NA';
134 134
 			if ($row['ident'] == '') $row['ident'] = 'NA';
135
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
135
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3));
136 136
 			if (isset($identicao[0])) {
137
-				if (substr($row['ident'],0,2) == 'AF') {
138
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
139
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
140
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
141
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
137
+				if (substr($row['ident'], 0, 2) == 'AF') {
138
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
139
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
140
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
141
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
142 142
 			} else $icao = $row['ident'];
143
-			$icao = $Translation->checkTranslation($icao,false);
143
+			$icao = $Translation->checkTranslation($icao, false);
144 144
 			//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
145 145
 			if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
146 146
 				//echo 'Check airline info... for '.$row['airline_name'].' ';
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
 				if (!empty($airline_info)) {
150 150
 					//echo 'data found !'."\n";
151 151
 					//print_r($airline_info);
152
-					$data = array_merge($data,$airline_info);
152
+					$data = array_merge($data, $airline_info);
153 153
 				} 
154 154
 				//else echo 'No data...'."\n";
155 155
 			}
156
-			$data = array_merge($row,$data);
156
+			$data = array_merge($row, $data);
157 157
 			if ($data['ident'] == null) $data['ident'] = $icao;
158 158
 			if ($data['title'] == null) {
159 159
 				$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 		try {
188 188
 			$sth = $this->db->prepare($query);
189 189
 			$sth->execute();
190
-		} catch(PDOException $e) {
190
+		} catch (PDOException $e) {
191 191
 			echo "Error : ".$e->getMessage();
192 192
 		}
193 193
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		try {
208 208
 			$sth = $this->db->prepare($query);
209 209
 			$sth->execute();
210
-		} catch(PDOException $e) {
210
+		} catch (PDOException $e) {
211 211
 			echo "Error : ".$e->getMessage();
212 212
 		}
213 213
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -222,15 +222,15 @@  discard block
 block discarded – undo
222 222
 		if ($globalDebug) echo 'Import '.$file."\n";
223 223
 		$result = array();
224 224
 		if (file_exists($file)) {
225
-			if (($handle = fopen($file,'r')) !== FALSE) {
226
-				while (($data = fgetcsv($handle,2000,",")) !== FALSE) {
225
+			if (($handle = fopen($file, 'r')) !== FALSE) {
226
+				while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) {
227 227
 					if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') {
228
-						$result[] = array('registration' => $data[0],'date' => strtotime($data[1]),'url' => $data[2],'country' => $data[3],'place' => $data[4],'title' => $data[5],'fatalities' => $data[6],'latitude' => $data[7],'longitude' => $data[8],'type' => $data[9],'ident' => $data[10],'aircraft_manufacturer' => $data[11],'aircraft_name' => $data[12],'operator' => $data[13],'source' => 'website_fam');
228
+						$result[] = array('registration' => $data[0], 'date' => strtotime($data[1]), 'url' => $data[2], 'country' => $data[3], 'place' => $data[4], 'title' => $data[5], 'fatalities' => $data[6], 'latitude' => $data[7], 'longitude' => $data[8], 'type' => $data[9], 'ident' => $data[10], 'aircraft_manufacturer' => $data[11], 'aircraft_name' => $data[12], 'operator' => $data[13], 'source' => 'website_fam');
229 229
 					}
230 230
 				}
231 231
 				fclose($handle);
232 232
 			}
233
-			if (!empty($result)) $this->add($result,true);
233
+			if (!empty($result)) $this->add($result, true);
234 234
 			elseif ($globalDebug) echo 'Nothing to import';
235 235
 		}
236 236
 	}
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 		$all_md5_new = array();
247 247
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
248 248
 			if ($this->check_accidents_nb() > 0) {
249
-				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
250
-					while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
249
+				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
250
+					while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
251 251
 						if (isset($data[1])) {
252 252
 							$year = $data[0];
253 253
 							$all_md5[$year] = $data[1];
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
 				}
258 258
 			}
259 259
 		}
260
-		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5');
260
+		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5');
261 261
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
262
-			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
263
-				while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
262
+			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
263
+				while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
264 264
 					if (isset($data[1])) {
265 265
 						$year = $data[0];
266 266
 						$all_md5_new[$year] = $data[1];
@@ -269,10 +269,10 @@  discard block
 block discarded – undo
269 269
 				fclose($handle);
270 270
 			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
271 271
 		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
272
-		$result = $Common->arr_diff($all_md5_new,$all_md5);
272
+		$result = $Common->arr_diff($all_md5_new, $all_md5);
273 273
 		if (empty($result) && $globalDebug) echo 'Nothing to update';
274 274
 		foreach ($result as $file => $md5) {
275
-			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
275
+			$Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file);
276 276
 			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
277 277
 			elseif ($globalDebug) echo 'Download '.$file.' failed';
278 278
 		}
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	* Add data to DB
283 283
 	* @param Array $crash An array with accidents/incidents data
284 284
 	*/
285
-	public function add($crash,$new = false) {
285
+	public function add($crash, $new = false) {
286 286
 		global $globalTransaction, $globalDebug;
287 287
 		require_once('class.Connection.php');
288 288
 		require_once('class.Image.php');
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 			$sthd->execute(array(':source' => $crash[0]['source']));
299 299
 		}
300 300
 		if ($globalTransaction) $Connection->db->beginTransaction();
301
-		$initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null);
301
+		$initial_array = array('ident' => null, 'type' => 'accident', 'url' => null, 'registration' => null, 'date' => null, 'place' => null, 'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '', 'source' => '', 'aircraft_manufacturer' => null, 'aircraft_name' => null, 'operator' => null);
302 302
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
303 303
 		$sth_check = $Connection->db->prepare($query_check);
304 304
 		$query = 'INSERT INTO accidents (aircraft_manufacturer,aircraft_name,ident,registration,date,url,country,place,title,fatalities,latitude,longitude,type,airline_name,source) VALUES (:aircraft_manufacturer,:aircraft_name,:ident,:registration,:date,:url,:country,:place,:title,:fatalities,:latitude,:longitude,:type,:airline_name,:source)';
@@ -311,31 +311,31 @@  discard block
 block discarded – undo
311 311
 				$cr = array_map(function($value) {
312 312
 					return $value === "" ? NULL : $value;
313 313
 				}, $cr);
314
-				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
315
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
316
-					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
314
+				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) {
315
+					if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
316
+					$query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']);
317 317
 					$sth_check->execute($query_check_values);
318 318
 					$result_check = $sth_check->fetch(PDO::FETCH_ASSOC);
319 319
 					if ($result_check['nb'] == 0) {
320
-						$query_values = array(':registration' => trim($cr['registration']),':date' => date('Y-m-d',$cr['date']),':url' => $cr['url'],':country' => $cr['country'],':place' => $cr['place'],':title' => $cr['title'],':fatalities' => $cr['fatalities'],':latitude' => $cr['latitude'],':longitude' => $cr['longitude'],':type' => $cr['type'],':source' => $cr['source'],':ident' => $cr['ident'],':aircraft_manufacturer' => $cr['aircraft_manufacturer'],':aircraft_name' => $cr['aircraft_name'],':airline_name' => $cr['operator']);
320
+						$query_values = array(':registration' => trim($cr['registration']), ':date' => date('Y-m-d', $cr['date']), ':url' => $cr['url'], ':country' => $cr['country'], ':place' => $cr['place'], ':title' => $cr['title'], ':fatalities' => $cr['fatalities'], ':latitude' => $cr['latitude'], ':longitude' => $cr['longitude'], ':type' => $cr['type'], ':source' => $cr['source'], ':ident' => $cr['ident'], ':aircraft_manufacturer' => $cr['aircraft_manufacturer'], ':aircraft_name' => $cr['aircraft_name'], ':airline_name' => $cr['operator']);
321 321
 						$sth->execute($query_values);
322
-						if ($cr['date'] > time()-(30*86400)) {
322
+						if ($cr['date'] > time() - (30*86400)) {
323 323
 							if (empty($Image->getSpotterImage($cr['registration']))) {
324 324
 								//if ($globalDebug) echo 'Get image...'."\n";
325 325
 								$Image->addSpotterImage($cr['registration']);
326 326
 							}
327 327
 							// elseif ($globalDebug) echo 'Image already in DB'."\n";
328 328
 						}
329
-						$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
329
+						$Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date']));
330 330
 					}
331 331
 				}
332
-				if ($globalTransaction && $j % 1000 == 0) {
332
+				if ($globalTransaction && $j%1000 == 0) {
333 333
 					$Connection->db->commit();
334 334
 					$Connection->db->beginTransaction();
335 335
 				}
336 336
 			}
337 337
 			if ($globalTransaction) $Connection->db->commit();
338
-		} catch(PDOException $e) {
338
+		} catch (PDOException $e) {
339 339
 			if ($globalTransaction) $Connection->db->rollBack();
340 340
 			echo $e->getMessage();
341 341
 		}
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 			$Connection = new Connection();
354 354
 			$sth = $Connection->db->prepare($query);
355 355
 			$sth->execute();
356
-		} catch(PDOException $e) {
356
+		} catch (PDOException $e) {
357 357
 			return "error : ".$e->getMessage();
358 358
 		}
359 359
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 			$Connection = new Connection();
372 372
 			$sth = $Connection->db->prepare($query);
373 373
 			$sth->execute();
374
-		} catch(PDOException $e) {
374
+		} catch (PDOException $e) {
375 375
 			return "error : ".$e->getMessage();
376 376
 		}
377 377
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 			$Connection = new Connection();
387 387
 			$sth = $Connection->db->prepare($query);
388 388
 			$sth->execute();
389
-		} catch(PDOException $e) {
389
+		} catch (PDOException $e) {
390 390
 			return "error : ".$e->getMessage();
391 391
 		}
392 392
 	}
Please login to merge, or discard this patch.
statistics-fatalities-year.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
             	["'._("Year").'", "'._("# of Fatalities").'"], ';
24 24
 
25 25
 $date_data = '';
26
-foreach($date_array as $date_item)
26
+foreach ($date_array as $date_item)
27 27
 {
28 28
 	$date_data .= '[ "'.$date_item['year'].'",'.$date_item['count'].'],';
29 29
 }
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
 
51 51
 if (!empty($date_array))
52 52
 {
53
-	foreach($date_array as $key => $row) {
53
+	foreach ($date_array as $key => $row) {
54 54
 		$years[$key] = $row['year'];
55 55
 		$counts[$key] = $row['count'];
56 56
 	}
57 57
 	//array_multisort($years,SORT_DESC,$date_array);
58
-	array_multisort($counts,SORT_DESC,$date_array);
58
+	array_multisort($counts, SORT_DESC, $date_array);
59 59
 	print '<div class="table-responsive">';
60 60
 	print '<table class="common-date table-striped">';
61 61
 	print '<thead>';
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	print '</thead>';
66 66
 	print '<tbody>';
67 67
 	$i = 1;
68
-	foreach($date_array as $date_item)
68
+	foreach ($date_array as $date_item)
69 69
 	{
70 70
 		print '<tr>';
71 71
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
table-output.php 3 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -390,17 +390,17 @@  discard block
 block discarded – undo
390 390
 				else {
391 391
 					$planespotter_url_array = explode("_", $spotter_item['image']);
392 392
 					$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
393
-                                        $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
393
+										$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
394 394
 				}
395 395
 				if (isset($spotter_item['airline_name'])) {
396 396
 					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
397 397
 				} else {
398 398
 					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
399 399
 				}
400
-                        } else {
401
-                    		if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
402
-                    		$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
403
-                    		} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
400
+						} else {
401
+							if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
402
+							$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
403
+							} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
404 404
 				if (isset($spotter_item['airline_name'])) {
405 405
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
406 406
 				} else {
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 		}
416 416
 	} elseif(strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed"){
417 417
 		if (!isset($spotter_item['squawk']) || $spotter_item['squawk'] == 0) {
418
-		    $spotter_item['squawk'] = '-';
418
+			$spotter_item['squawk'] = '-';
419 419
 		}
420 420
 		if ($spotter_item['image_thumbnail'] != "")
421 421
 		{
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 				else {
427 427
 					$planespotter_url_array = explode("_", $spotter_array[0]['image']);
428 428
 					$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
429
-                                        $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
429
+										$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
430 430
 				}
431 431
 				if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
432 432
 					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -438,9 +438,9 @@  discard block
 block discarded – undo
438 438
 					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
439 439
 				}
440 440
 			} else {
441
-                    		if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
442
-                    		$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
443
-                    		} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
441
+							if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
442
+							$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
443
+							} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
444 444
 				if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
445 445
 					print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
446 446
 				} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 			print '</td>'."\n";
455 455
 		} else {
456 456
 			print '<td class="aircraft_thumbnail">'."\n";
457
-       //   	 	print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
457
+	   //   	 	print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
458 458
 	//}
459 459
 			if (!isset($spotter_item['airline_name']) && !isset($spotter_item['aircraft_name'])) {
460 460
 				print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '._("Not available").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n";
@@ -559,13 +559,13 @@  discard block
 block discarded – undo
559 559
 				$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
560 560
 			} else $distance = '';
561 561
 			if ($distance != '') {
562
-			    if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
563
-				    echo '<br/><i>'.round($distance*0.539957).' nm</i>';
564
-			    } elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
565
-				    echo '<br/><i>'.round($distance*0.621371).' mi</i>';
566
-			    } elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
567
-				    echo '<br/><i>'.$distance.' km</i>';
568
-			    }
562
+				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
563
+					echo '<br/><i>'.round($distance*0.539957).' nm</i>';
564
+				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
565
+					echo '<br/><i>'.round($distance*0.621371).' mi</i>';
566
+				} elseif ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
567
+					echo '<br/><i>'.$distance.' km</i>';
568
+				}
569 569
 			}
570 570
 		}
571 571
 		print '</td>'."\n";
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	}
95 95
 	print '<th class="more"></th>';
96 96
 	print '</thead>';
97
-} else if (strtolower($current_page) == "upcoming"){
97
+} else if (strtolower($current_page) == "upcoming") {
98 98
 	print '<thead>';
99 99
 	if ($_GET['sort'] == "airline_name_asc")
100 100
 	{
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	}
145 145
 	*/
146 146
 	print '</thead>';
147
-} else if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive"){
147
+} else if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive") {
148 148
 	print '<thead>';
149 149
 	print '<th class="aircraft_thumbnail"></th>';
150 150
 	print '<th class="logo">'._("Airline").'</th>';
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	print '</thead>';
182 182
 } else {
183 183
 
184
-	if ($hide_th_links === true){
184
+	if ($hide_th_links === true) {
185 185
 		print '<thead>';
186 186
 		print '<th class="aircraft_thumbnail"></th>';
187 187
 		if ($_GET['sort'] == "airline_name_asc")
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 }
363 363
 
364 364
 print '<tbody>'."\n";
365
-foreach($spotter_array as $spotter_item)
365
+foreach ($spotter_array as $spotter_item)
366 366
 {
367 367
 	if (isset($globalTimezone))
368 368
 	{
@@ -393,13 +393,13 @@  discard block
 block discarded – undo
393 393
                                         $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
394 394
 				}
395 395
 				if (isset($spotter_item['airline_name'])) {
396
-					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
396
+					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
397 397
 				} else {
398
-					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
398
+					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
399 399
 				}
400 400
                         } else {
401 401
                     		if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
402
-                    		$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
402
+                    		$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
403 403
                     		} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
404 404
 				if (isset($spotter_item['airline_name'])) {
405 405
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 			print '<img src="'.$globalURL.'/images/placeholder_thumb.png" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" />'."\n";
414 414
 			print '</td>'."\n";
415 415
 		}
416
-	} elseif(strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed"){
416
+	} elseif (strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed") {
417 417
 		if (!isset($spotter_item['squawk']) || $spotter_item['squawk'] == 0) {
418 418
 		    $spotter_item['squawk'] = '-';
419 419
 		}
@@ -429,17 +429,17 @@  discard block
 block discarded – undo
429 429
                                         $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
430 430
 				}
431 431
 				if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
432
-					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
432
+					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
433 433
 				} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
434
-					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
434
+					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
435 435
 				} elseif (!isset($spotter_item['aircraft_name']) && !isset($spotter_item['airline_name'])) {
436
-					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
436
+					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
437 437
 				} else {
438
-					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
438
+					print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
439 439
 				}
440 440
 			} else {
441 441
                     		if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
442
-                    		$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
442
+                    		$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
443 443
                     		} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
444 444
 				if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
445 445
 					print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 	}
503 503
 	print '</td>'."\n";
504 504
 	// Aircraft type
505
-	if(strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive"){
505
+	if (strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive") {
506 506
 		print '<td class="type">'."\n";
507 507
 		if (!isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_name'])) {
508 508
 			print '<span class="nomobile">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</span>'."\n";
@@ -526,22 +526,22 @@  discard block
 block discarded – undo
526 526
 		}
527 527
 		if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) {
528 528
 			if ($spotter_item['departure_airport_time'] > 2460) {
529
-				$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
530
-			} else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
529
+				$departure_airport_time = date('H:m', $spotter_item['departure_airport_time']);
530
+			} else $departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2);
531 531
 			if ($spotter_item['real_departure_airport_time'] > 2460) {
532
-				$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
532
+				$real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']);
533 533
 			} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
534 534
 			print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n";
535 535
 		} elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') {
536 536
 			if ($spotter_item['real_departure_airport_time'] > 2460) {
537
-				$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
537
+				$real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']);
538 538
 			} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
539 539
 			print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n";
540 540
 		} elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
541 541
 			if ($spotter_item['departure_airport_time'] > 2460) {
542
-				$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
542
+				$departure_airport_time = date('H:m', $spotter_item['departure_airport_time']);
543 543
 			} else {
544
-				$departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
544
+				$departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2);
545 545
 			}
546 546
 			print '<br /><span class="airport_time">'.$departure_airport_time.'</span>'."\n";
547 547
 		}
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 					$latitude = $spotter_item['latitude'];
557 557
 					$longitude = $spotter_item['longitude'];
558 558
 				}
559
-				$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
559
+				$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'], $latitude, $longitude);
560 560
 			} else $distance = '';
561 561
 			if ($distance != '') {
562 562
 			    if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
@@ -597,20 +597,20 @@  discard block
 block discarded – undo
597 597
 		}
598 598
 		if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) {
599 599
 			if ($spotter_item['arrival_airport_time'] > 2460) {
600
-				$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
600
+				$arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']);
601 601
 			} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
602 602
 			if ($spotter_item['real_arrival_airport_time'] > 2460) {
603
-				$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
603
+				$real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']);
604 604
 			} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
605 605
 			print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n";
606 606
 		} elseif (isset($spotter_item['real_arrival_airport_time'])) {
607 607
 			if ($spotter_item['real_arrival_airport_time'] > 2460) {
608
-				$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
608
+				$real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']);
609 609
 			} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
610 610
 			print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n";
611 611
 		} elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
612 612
 			if ($spotter_item['arrival_airport_time'] > 2460) {
613
-				$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
613
+				$arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']);
614 614
 			} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
615 615
 			print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n";
616 616
 		}
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 					$latitude = $spotter_item['latitude'];
624 624
 					$longitude = $spotter_item['longitude'];
625 625
 				}
626
-				$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude);
626
+				$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'], $latitude, $longitude);
627 627
 			} else $distance = '';
628 628
 			if ($distance != '') {
629 629
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 		print '</td>'."\n";
639 639
 		if ((isset($globalIvAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalVAM) && $globalVAM) || (isset($globalphpVMS) && $globalphpVMS)) {
640 640
 			// Route stop
641
-			if(strtolower($current_page) != "upcoming"){
641
+			if (strtolower($current_page) != "upcoming") {
642 642
 				print '<td class="route_stop">'."\n";
643 643
 				if (!isset($spotter_item['route_stop']) || $spotter_item['route_stop'] == '' || $spotter_item['route_stop'] == 'NULL') {
644 644
 					print '<span class="nomobile">-</span>'."\n";
@@ -663,21 +663,21 @@  discard block
 block discarded – undo
663 663
 			} else {
664 664
 				//if (!isset($globalUnitDistance) || $globalUnitDistance == 'km') {
665 665
 				if ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
666
-					print '<span class="nomobile">'.round($spotter_item['distance'],2).' km</span>'."\n";
667
-					print '<span class="mobile">'.round($spotter_item['distance'],2).' km</span><br />'."\n";
666
+					print '<span class="nomobile">'.round($spotter_item['distance'], 2).' km</span>'."\n";
667
+					print '<span class="mobile">'.round($spotter_item['distance'], 2).' km</span><br />'."\n";
668 668
 				//} elseif ($globalUnitDistance == 'mi') {
669 669
 				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
670
-					print '<span class="nomobile">'.round($spotter_item['distance']*0.621371,2).' mi</span>'."\n";
671
-					print '<span class="mobile">'.round($spotter_item['distance']*0.621371,2).' mi</span><br />'."\n";
670
+					print '<span class="nomobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span>'."\n";
671
+					print '<span class="mobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span><br />'."\n";
672 672
 				//} elseif ($globalUnitDistance == 'nm') {
673 673
 				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
674
-					print '<span class="nomobile">'.round($spotter_item['distance']*0.539957,2).' nm</span>'."\n";
675
-					print '<span class="mobile">'.round($spotter_item['distance']*0.539957,2).' nm</span><br />'."\n";
674
+					print '<span class="nomobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span>'."\n";
675
+					print '<span class="mobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span><br />'."\n";
676 676
 				}
677 677
 			}
678 678
 			print '</td>'."\n";
679 679
 		}
680
-		if(strtolower($current_page) != "upcoming"){
680
+		if (strtolower($current_page) != "upcoming") {
681 681
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
682 682
 				print '<td class="pilot">'."\n";
683 683
 				if ((!isset($spotter_item['pilot_id']) || $spotter_item['pilot_id'] == '') && (!isset($spotter_item['pilot_name']) || $spotter_item['pilot_name'] == '')) {
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 	if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive") {
713 713
 		if (isset($spotter_item['decode']) && $spotter_item['decode'] != '') {
714 714
 			print '<td class="message"><p>'."\n";
715
-			print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
715
+			print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
716 716
 			print '</p><p class="decode">';
717 717
 			$decode_array = json_decode($spotter_item['decode']);
718 718
 			foreach ($decode_array as $key => $value) {
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 			print '</td>'."\n";
723 723
 		} else {
724 724
 			print '<td class="message">'."\n";
725
-			print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
725
+			print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
726 726
 			print '</td>'."\n";
727 727
 		}
728 728
 	}
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 		}
748 748
 		print '</td>'."\n";
749 749
 		print '<td class="message">'."\n";
750
-		print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
750
+		print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
751 751
 		print '</td>'."\n";
752 752
 	}
753 753
 	if (strtolower($current_page) == "incident-latest" || strtolower($current_page) == "incident-detailed") {
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
 		print '</td>'."\n";
774 774
 		*/
775 775
 		print '<td class="message">'."\n";
776
-		print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
776
+		print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
777 777
 		print '</td>'."\n";
778 778
 	}
779 779
 	// Date
Please login to merge, or discard this patch.
Braces   +45 added lines, -17 removed lines patch added patch discarded remove patch
@@ -367,7 +367,9 @@  discard block
 block discarded – undo
367 367
 	if (isset($globalTimezone))
368 368
 	{
369 369
 		date_default_timezone_set($globalTimezone);
370
-	} else date_default_timezone_set('UTC');
370
+	} else {
371
+		date_default_timezone_set('UTC');
372
+	}
371 373
 	if ($showSpecial === true)
372 374
 	{
373 375
 		print '<tr class="special">'."\n";
@@ -386,8 +388,9 @@  discard block
 block discarded – undo
386 388
 			print '<td class="aircraft_thumbnail">'."\n";
387 389
 			
388 390
 			if ($spotter_item['image_source'] == 'planespotters') {
389
-				if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
390
-				else {
391
+				if ($spotter_item['image_source_website'] != '') {
392
+					$image_src = $spotter_item['image_source_website'];
393
+				} else {
391 394
 					$planespotter_url_array = explode("_", $spotter_item['image']);
392 395
 					$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
393 396
                                         $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -400,7 +403,9 @@  discard block
 block discarded – undo
400 403
                         } else {
401 404
                     		if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
402 405
                     		$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
403
-                    		} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
406
+                    		} else {
407
+                    			$image_thumbnail = $spotter_item['image_thumbnail'];
408
+                    		}
404 409
 				if (isset($spotter_item['airline_name'])) {
405 410
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
406 411
 				} else {
@@ -422,8 +427,9 @@  discard block
 block discarded – undo
422 427
 			print '<td class="aircraft_thumbnail">'."\n";
423 428
 			//print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$spotter_item['image_thumbnail'].'" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
424 429
 			if ($spotter_item['image_source'] == 'planespotters') {
425
-				if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
426
-				else {
430
+				if ($spotter_item['image_source_website'] != '') {
431
+					$image_src = $spotter_item['image_source_website'];
432
+				} else {
427 433
 					$planespotter_url_array = explode("_", $spotter_array[0]['image']);
428 434
 					$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
429 435
                                         $image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -440,7 +446,9 @@  discard block
 block discarded – undo
440 446
 			} else {
441 447
                     		if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
442 448
                     		$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
443
-                    		} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
449
+                    		} else {
450
+                    			$image_thumbnail = $spotter_item['image_thumbnail'];
451
+                    		}
444 452
 				if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
445 453
 					print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
446 454
 				} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
@@ -527,15 +535,21 @@  discard block
 block discarded – undo
527 535
 		if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) {
528 536
 			if ($spotter_item['departure_airport_time'] > 2460) {
529 537
 				$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
530
-			} else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
538
+			} else {
539
+				$departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
540
+			}
531 541
 			if ($spotter_item['real_departure_airport_time'] > 2460) {
532 542
 				$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
533
-			} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
543
+			} else {
544
+				$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
545
+			}
534 546
 			print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n";
535 547
 		} elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') {
536 548
 			if ($spotter_item['real_departure_airport_time'] > 2460) {
537 549
 				$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
538
-			} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
550
+			} else {
551
+				$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
552
+			}
539 553
 			print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n";
540 554
 		} elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
541 555
 			if ($spotter_item['departure_airport_time'] > 2460) {
@@ -557,7 +571,9 @@  discard block
 block discarded – undo
557 571
 					$longitude = $spotter_item['longitude'];
558 572
 				}
559 573
 				$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
560
-			} else $distance = '';
574
+			} else {
575
+				$distance = '';
576
+			}
561 577
 			if ($distance != '') {
562 578
 			    if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
563 579
 				    echo '<br/><i>'.round($distance*0.539957).' nm</i>';
@@ -582,7 +598,9 @@  discard block
 block discarded – undo
582 598
 		} else {
583 599
 			if (isset($spotter_item['real_arrival_airport']) && $spotter_item['real_arrival_airport'] != $spotter_item['arrival_airport']) {
584 600
 				print '<span class="nomobile">Scheduled : <a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a></span>'."\n";
585
-				if (!isset($Spotter)) $Spotter = new Spotter();
601
+				if (!isset($Spotter)) {
602
+					$Spotter = new Spotter();
603
+				}
586 604
 				$arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']);
587 605
 				print '<br /><span class="nomobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n";
588 606
 				print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n";
@@ -598,20 +616,28 @@  discard block
 block discarded – undo
598 616
 		if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) {
599 617
 			if ($spotter_item['arrival_airport_time'] > 2460) {
600 618
 				$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
601
-			} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
619
+			} else {
620
+				$arrival_airport_time = $spotter_item['arrival_airport_time'];
621
+			}
602 622
 			if ($spotter_item['real_arrival_airport_time'] > 2460) {
603 623
 				$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
604
-			} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
624
+			} else {
625
+				$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
626
+			}
605 627
 			print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n";
606 628
 		} elseif (isset($spotter_item['real_arrival_airport_time'])) {
607 629
 			if ($spotter_item['real_arrival_airport_time'] > 2460) {
608 630
 				$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
609
-			} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
631
+			} else {
632
+				$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
633
+			}
610 634
 			print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n";
611 635
 		} elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
612 636
 			if ($spotter_item['arrival_airport_time'] > 2460) {
613 637
 				$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
614
-			} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
638
+			} else {
639
+				$arrival_airport_time = $spotter_item['arrival_airport_time'];
640
+			}
615 641
 			print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n";
616 642
 		}
617 643
 		if (!isset($spotter_item['real_arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
@@ -624,7 +650,9 @@  discard block
 block discarded – undo
624 650
 					$longitude = $spotter_item['longitude'];
625 651
 				}
626 652
 				$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude);
627
-			} else $distance = '';
653
+			} else {
654
+				$distance = '';
655
+			}
628 656
 			if ($distance != '') {
629 657
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
630 658
 					echo '<br/><i>'.round($distance*0.539957).' nm</i>';
Please login to merge, or discard this patch.
accident-latest.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 $page_url = $globalURL.'/accident-latest';
10 10
 
11
-if(!isset($_GET['limit']))
11
+if (!isset($_GET['limit']))
12 12
 {
13 13
 	$limit_start = 0;
14 14
 	$limit_end = 25;
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
 print '<div class="table column">';
35 35
 print '<p>'._("The table below shows the latest Accidents.").'</p>';
36
-$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference,'accident');
36
+$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference, 'accident');
37 37
 //print_r($spotter_array);
38 38
 if (!empty($spotter_array) && isset($spotter_array[0]['query_number_rows']) && $spotter_array[0]['query_number_rows'] != 0) {
39 39
 	include('table-output.php');
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,8 +58,12 @@
 block discarded – undo
58 58
 if (!empty($spotter_array) && isset($spotter_array[0]['query_number_rows']) && $spotter_array[0]['query_number_rows'] != 0) {
59 59
 	include('table-output.php');
60 60
 	print '<div class="pagination">';
61
-	if ($limit_previous_1 >= 0) print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("Previous Page").'</a>';
62
-	if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
61
+	if ($limit_previous_1 >= 0) {
62
+		print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("Previous Page").'</a>';
63
+	}
64
+	if ($spotter_array[0]['query_number_rows'] == $absolute_difference) {
65
+		print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
66
+	}
63 67
 	print '</div>';
64 68
 }
65 69
 print '</div>';
Please login to merge, or discard this patch.
install/class.update_db.php 4 patches
Doc Comments   +42 added lines patch added patch discarded remove patch
@@ -10,6 +10,9 @@  discard block
 block discarded – undo
10 10
 class update_db {
11 11
 	public static $db_sqlite;
12 12
 
13
+	/**
14
+	 * @param string $file
15
+	 */
13 16
 	public static function download($url, $file, $referer = '') {
14 17
 		$fp = fopen($file, 'w+');
15 18
 		$ch = curl_init();
@@ -24,6 +27,9 @@  discard block
 block discarded – undo
24 27
 		fclose($fp);
25 28
 	}
26 29
 
30
+	/**
31
+	 * @param string $in_file
32
+	 */
27 33
 	public static function gunzip($in_file,$out_file_name = '') {
28 34
 		//echo $in_file.' -> '.$out_file_name."\n";
29 35
 		$buffer_size = 4096; // read 4kb at a time
@@ -45,6 +51,9 @@  discard block
 block discarded – undo
45 51
 		}
46 52
 	}
47 53
 
54
+	/**
55
+	 * @param string $in_file
56
+	 */
48 57
 	public static function unzip($in_file) {
49 58
 		if ($in_file != '' && file_exists($in_file)) {
50 59
 			$path = pathinfo(realpath($in_file), PATHINFO_DIRNAME);
@@ -66,6 +75,9 @@  discard block
 block discarded – undo
66 75
 		}
67 76
 	}
68 77
 	
78
+	/**
79
+	 * @param string $database_file
80
+	 */
69 81
 	public static function retrieve_route_sqlite_to_dest($database_file) {
70 82
 		global $globalDebug, $globalTransaction;
71 83
 		//$query = 'TRUNCATE TABLE routes';
@@ -108,6 +120,10 @@  discard block
 block discarded – undo
108 120
 		}
109 121
                 return '';
110 122
 	}
123
+
124
+	/**
125
+	 * @param string $database_file
126
+	 */
111 127
 	public static function retrieve_route_oneworld($database_file) {
112 128
 		global $globalDebug, $globalTransaction;
113 129
 		//$query = 'TRUNCATE TABLE routes';
@@ -149,6 +165,9 @@  discard block
 block discarded – undo
149 165
                 return '';
150 166
 	}
151 167
 	
168
+	/**
169
+	 * @param string $database_file
170
+	 */
152 171
 	public static function retrieve_route_skyteam($database_file) {
153 172
 		global $globalDebug, $globalTransaction;
154 173
 		//$query = 'TRUNCATE TABLE routes';
@@ -191,6 +210,10 @@  discard block
 block discarded – undo
191 210
 		}
192 211
                 return '';
193 212
 	}
213
+
214
+	/**
215
+	 * @param string $database_file
216
+	 */
194 217
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
195 218
 		global $globalTransaction;
196 219
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -257,6 +280,9 @@  discard block
 block discarded – undo
257 280
 		return '';
258 281
 	}
259 282
 
283
+	/**
284
+	 * @param string $database_file
285
+	 */
260 286
 	public static function retrieve_modes_flarmnet($database_file) {
261 287
 		global $globalTransaction;
262 288
 		$Common = new Common();
@@ -327,6 +353,9 @@  discard block
 block discarded – undo
327 353
 		return '';
328 354
 	}
329 355
 
356
+	/**
357
+	 * @param string $database_file
358
+	 */
330 359
 	public static function retrieve_modes_ogn($database_file) {
331 360
 		global $globalTransaction;
332 361
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -395,6 +424,9 @@  discard block
 block discarded – undo
395 424
 		return '';
396 425
 	}
397 426
 
427
+	/**
428
+	 * @param string $database_file
429
+	 */
398 430
 	public static function retrieve_owner($database_file,$country = 'F') {
399 431
 		global $globalTransaction, $globalMasterSource;
400 432
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -1235,6 +1267,10 @@  discard block
 block discarded – undo
1235 1267
 		return '';
1236 1268
         }
1237 1269
 
1270
+	/**
1271
+	 * @param string $filename
1272
+	 * @param string $tletype
1273
+	 */
1238 1274
 	public static function tle($filename,$tletype) {
1239 1275
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1240 1276
 		global $tmp_dir, $globalTransaction;
@@ -1367,6 +1403,9 @@  discard block
 block discarded – undo
1367 1403
 
1368 1404
 	}
1369 1405
 */
1406
+	/**
1407
+	 * @param string $filename
1408
+	 */
1370 1409
 	public static function waypoints($filename) {
1371 1410
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1372 1411
 		global $tmp_dir, $globalTransaction;
@@ -1414,6 +1453,9 @@  discard block
 block discarded – undo
1414 1453
 		return '';
1415 1454
         }
1416 1455
 
1456
+	/**
1457
+	 * @param string $filename
1458
+	 */
1417 1459
 	public static function ivao_airlines($filename) {
1418 1460
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1419 1461
 		global $tmp_dir, $globalTransaction;
Please login to merge, or discard this patch.
Indentation   +432 added lines, -432 removed lines patch added patch discarded remove patch
@@ -75,38 +75,38 @@  discard block
 block discarded – undo
75 75
 		try {
76 76
 			//$Connection = new Connection();
77 77
 			$sth = $Connection->db->prepare($query);
78
-                        $sth->execute(array(':source' => $database_file));
79
-                } catch(PDOException $e) {
80
-                        return "error : ".$e->getMessage();
81
-                }
78
+						$sth->execute(array(':source' => $database_file));
79
+				} catch(PDOException $e) {
80
+						return "error : ".$e->getMessage();
81
+				}
82 82
 
83
-    		if ($globalDebug) echo " - Add routes to DB -";
84
-    		update_db::connect_sqlite($database_file);
83
+			if ($globalDebug) echo " - Add routes to DB -";
84
+			update_db::connect_sqlite($database_file);
85 85
 		//$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';
86 86
 		$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";
87 87
 		try {
88
-                        $sth = update_db::$db_sqlite->prepare($query);
89
-                        $sth->execute();
90
-                } catch(PDOException $e) {
91
-                        return "error : ".$e->getMessage();
92
-                }
88
+						$sth = update_db::$db_sqlite->prepare($query);
89
+						$sth->execute();
90
+				} catch(PDOException $e) {
91
+						return "error : ".$e->getMessage();
92
+				}
93 93
 		//$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)';
94 94
 		$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
95 95
 		$Connection = new Connection();
96 96
 		$sth_dest = $Connection->db->prepare($query_dest);
97 97
 		try {
98 98
 			if ($globalTransaction) $Connection->db->beginTransaction();
99
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
99
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 100
 				//$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);
101 101
 				$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);
102 102
 				$sth_dest->execute($query_dest_values);
103
-            		}
103
+					}
104 104
 			if ($globalTransaction) $Connection->db->commit();
105 105
 		} catch(PDOException $e) {
106 106
 			if ($globalTransaction) $Connection->db->rollBack(); 
107 107
 			return "error : ".$e->getMessage();
108 108
 		}
109
-                return '';
109
+				return '';
110 110
 	}
111 111
 	public static function retrieve_route_oneworld($database_file) {
112 112
 		global $globalDebug, $globalTransaction;
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
 		try {
118 118
 			//$Connection = new Connection();
119 119
 			$sth = $Connection->db->prepare($query);
120
-                        $sth->execute(array(':source' => 'oneworld'));
121
-                } catch(PDOException $e) {
122
-                        return "error : ".$e->getMessage();
123
-                }
120
+						$sth->execute(array(':source' => 'oneworld'));
121
+				} catch(PDOException $e) {
122
+						return "error : ".$e->getMessage();
123
+				}
124 124
 
125
-    		if ($globalDebug) echo " - Add routes to DB -";
125
+			if ($globalDebug) echo " - Add routes to DB -";
126 126
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 127
 		$Spotter = new Spotter();
128 128
 		if ($fh = fopen($database_file,"r")) {
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 			}
147 147
 			if ($globalTransaction) $Connection->db->commit();
148 148
 		}
149
-                return '';
149
+				return '';
150 150
 	}
151 151
 	
152 152
 	public static function retrieve_route_skyteam($database_file) {
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
 		try {
159 159
 			//$Connection = new Connection();
160 160
 			$sth = $Connection->db->prepare($query);
161
-                        $sth->execute(array(':source' => 'skyteam'));
162
-                } catch(PDOException $e) {
163
-                        return "error : ".$e->getMessage();
164
-                }
161
+						$sth->execute(array(':source' => 'skyteam'));
162
+				} catch(PDOException $e) {
163
+						return "error : ".$e->getMessage();
164
+				}
165 165
 
166
-    		if ($globalDebug) echo " - Add routes to DB -";
166
+			if ($globalDebug) echo " - Add routes to DB -";
167 167
 
168 168
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 169
 		$Spotter = new Spotter();
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 				return "error : ".$e->getMessage();
190 190
 			}
191 191
 		}
192
-                return '';
192
+				return '';
193 193
 	}
194 194
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
195 195
 		global $globalTransaction;
@@ -198,27 +198,27 @@  discard block
 block discarded – undo
198 198
 		try {
199 199
 			$Connection = new Connection();
200 200
 			$sth = $Connection->db->prepare($query);
201
-                        $sth->execute(array(':source' => $database_file));
202
-                } catch(PDOException $e) {
203
-                        return "error : ".$e->getMessage();
204
-                }
201
+						$sth->execute(array(':source' => $database_file));
202
+				} catch(PDOException $e) {
203
+						return "error : ".$e->getMessage();
204
+				}
205 205
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
206 206
 		try {
207 207
 			$Connection = new Connection();
208 208
 			$sth = $Connection->db->prepare($query);
209
-                        $sth->execute(array(':source' => $database_file));
210
-                } catch(PDOException $e) {
211
-                        return "error : ".$e->getMessage();
212
-                }
209
+						$sth->execute(array(':source' => $database_file));
210
+				} catch(PDOException $e) {
211
+						return "error : ".$e->getMessage();
212
+				}
213 213
 
214
-    		update_db::connect_sqlite($database_file);
214
+			update_db::connect_sqlite($database_file);
215 215
 		$query = 'select * from Aircraft';
216 216
 		try {
217
-                        $sth = update_db::$db_sqlite->prepare($query);
218
-                        $sth->execute();
219
-                } catch(PDOException $e) {
220
-                        return "error : ".$e->getMessage();
221
-                }
217
+						$sth = update_db::$db_sqlite->prepare($query);
218
+						$sth->execute();
219
+				} catch(PDOException $e) {
220
+						return "error : ".$e->getMessage();
221
+				}
222 222
 		//$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)';
223 223
 		$query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)';
224 224
 		
@@ -229,17 +229,17 @@  discard block
 block discarded – undo
229 229
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
230 230
 		try {
231 231
 			if ($globalTransaction) $Connection->db->beginTransaction();
232
-            		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
232
+					while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233 233
 			//$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']);
234 234
 				if ($values['UserString4'] == 'M') $type = 'military';
235 235
 				else $type = null;
236 236
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237 237
 				$sth_dest->execute($query_dest_values);
238 238
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
239
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
-				    $sth_dest_owner->execute($query_dest_owner_values);
239
+					$query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
+					$sth_dest_owner->execute($query_dest_owner_values);
241 241
 				}
242
-            		}
242
+					}
243 243
 			if ($globalTransaction) $Connection->db->commit();
244 244
 		} catch(PDOException $e) {
245 245
 			return "error : ".$e->getMessage();
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
 		try {
251 251
 			$Connection = new Connection();
252 252
 			$sth = $Connection->db->prepare($query);
253
-                        $sth->execute(array(':source' => $database_file));
254
-                } catch(PDOException $e) {
255
-                        return "error : ".$e->getMessage();
256
-                }
253
+						$sth->execute(array(':source' => $database_file));
254
+				} catch(PDOException $e) {
255
+						return "error : ".$e->getMessage();
256
+				}
257 257
 		return '';
258 258
 	}
259 259
 
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 		try {
266 266
 			$Connection = new Connection();
267 267
 			$sth = $Connection->db->prepare($query);
268
-                        $sth->execute(array(':source' => $database_file));
269
-                } catch(PDOException $e) {
270
-                        return "error : ".$e->getMessage();
271
-                }
268
+						$sth->execute(array(':source' => $database_file));
269
+				} catch(PDOException $e) {
270
+						return "error : ".$e->getMessage();
271
+				}
272 272
 		
273 273
 		if ($fh = fopen($database_file,"r")) {
274 274
 			//$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)';
@@ -278,26 +278,26 @@  discard block
 block discarded – undo
278 278
 			$sth_dest = $Connection->db->prepare($query_dest);
279 279
 			try {
280 280
 				if ($globalTransaction) $Connection->db->beginTransaction();
281
-            			while (!feof($fh)) {
282
-            				$values = array();
283
-            				$line = $Common->hex2str(fgets($fh,9999));
281
+						while (!feof($fh)) {
282
+							$values = array();
283
+							$line = $Common->hex2str(fgets($fh,9999));
284 284
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
285
-            				$values['ModeS'] = substr($line,0,6);
286
-            				$values['Registration'] = trim(substr($line,69,6));
287
-            				$aircraft_name = trim(substr($line,48,6));
288
-            				// Check if we can find ICAO, else set it to GLID
289
-            				$aircraft_name_split = explode(' ',$aircraft_name);
290
-            				$search_more = '';
291
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
292
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
293
-            				$sth_search = $Connection->db->prepare($query_search);
285
+							$values['ModeS'] = substr($line,0,6);
286
+							$values['Registration'] = trim(substr($line,69,6));
287
+							$aircraft_name = trim(substr($line,48,6));
288
+							// Check if we can find ICAO, else set it to GLID
289
+							$aircraft_name_split = explode(' ',$aircraft_name);
290
+							$search_more = '';
291
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
292
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
293
+							$sth_search = $Connection->db->prepare($query_search);
294 294
 					try {
295
-                                    		$sth_search->execute();
296
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
297
-	            				//if (count($result) > 0) {
298
-	            				if (isset($result['icao']) && $result['icao'] != '') {
299
-	            				    $values['ICAOTypeCode'] = $result['icao'];
300
-	            				} 
295
+											$sth_search->execute();
296
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
297
+								//if (count($result) > 0) {
298
+								if (isset($result['icao']) && $result['icao'] != '') {
299
+									$values['ICAOTypeCode'] = $result['icao'];
300
+								} 
301 301
 					} catch(PDOException $e) {
302 302
 						return "error : ".$e->getMessage();
303 303
 					}
@@ -320,10 +320,10 @@  discard block
 block discarded – undo
320 320
 		try {
321 321
 			$Connection = new Connection();
322 322
 			$sth = $Connection->db->prepare($query);
323
-                        $sth->execute(array(':source' => $database_file));
324
-                } catch(PDOException $e) {
325
-                        return "error : ".$e->getMessage();
326
-                }
323
+						$sth->execute(array(':source' => $database_file));
324
+				} catch(PDOException $e) {
325
+						return "error : ".$e->getMessage();
326
+				}
327 327
 		return '';
328 328
 	}
329 329
 
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
 		try {
335 335
 			$Connection = new Connection();
336 336
 			$sth = $Connection->db->prepare($query);
337
-                        $sth->execute(array(':source' => $database_file));
338
-                } catch(PDOException $e) {
339
-                        return "error : ".$e->getMessage();
340
-                }
337
+						$sth->execute(array(':source' => $database_file));
338
+				} catch(PDOException $e) {
339
+						return "error : ".$e->getMessage();
340
+				}
341 341
 		
342 342
 		if ($fh = fopen($database_file,"r")) {
343 343
 			//$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)';
@@ -348,24 +348,24 @@  discard block
 block discarded – undo
348 348
 			try {
349 349
 				if ($globalTransaction) $Connection->db->beginTransaction();
350 350
 				$tmp = fgetcsv($fh,9999,',',"'");
351
-            			while (!feof($fh)) {
352
-            				$line = fgetcsv($fh,9999,',',"'");
351
+						while (!feof($fh)) {
352
+							$line = fgetcsv($fh,9999,',',"'");
353 353
             				
354 354
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
355 355
 					//print_r($line);
356
-            				$values['ModeS'] = $line[1];
357
-            				$values['Registration'] = $line[3];
358
-            				$aircraft_name = $line[2];
359
-            				// Check if we can find ICAO, else set it to GLID
360
-            				$aircraft_name_split = explode(' ',$aircraft_name);
361
-            				$search_more = '';
362
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
363
-            				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
364
-            				$sth_search = $Connection->db->prepare($query_search);
356
+							$values['ModeS'] = $line[1];
357
+							$values['Registration'] = $line[3];
358
+							$aircraft_name = $line[2];
359
+							// Check if we can find ICAO, else set it to GLID
360
+							$aircraft_name_split = explode(' ',$aircraft_name);
361
+							$search_more = '';
362
+							if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
363
+							$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
364
+							$sth_search = $Connection->db->prepare($query_search);
365 365
 					try {
366
-                                    		$sth_search->execute();
367
-	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
366
+											$sth_search->execute();
367
+								$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368
+								if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
369 369
 					} catch(PDOException $e) {
370 370
 						return "error : ".$e->getMessage();
371 371
 					}
@@ -388,10 +388,10 @@  discard block
 block discarded – undo
388 388
 		try {
389 389
 			$Connection = new Connection();
390 390
 			$sth = $Connection->db->prepare($query);
391
-                        $sth->execute(array(':source' => $database_file));
392
-                } catch(PDOException $e) {
393
-                        return "error : ".$e->getMessage();
394
-                }
391
+						$sth->execute(array(':source' => $database_file));
392
+				} catch(PDOException $e) {
393
+						return "error : ".$e->getMessage();
394
+				}
395 395
 		return '';
396 396
 	}
397 397
 
@@ -402,16 +402,16 @@  discard block
 block discarded – undo
402 402
 		try {
403 403
 			$Connection = new Connection();
404 404
 			$sth = $Connection->db->prepare($query);
405
-                        $sth->execute(array(':source' => $database_file));
406
-                } catch(PDOException $e) {
407
-                        return "error : ".$e->getMessage();
408
-                }
405
+						$sth->execute(array(':source' => $database_file));
406
+				} catch(PDOException $e) {
407
+						return "error : ".$e->getMessage();
408
+				}
409 409
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
410 410
 		$Spotter = new Spotter();
411 411
 		if ($fh = fopen($database_file,"r")) {
412 412
 			//$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)';
413 413
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
414
-		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
414
+				$query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
415 415
 		        
416 416
 			$Connection = new Connection();
417 417
 			$sth_dest = $Connection->db->prepare($query_dest);
@@ -419,126 +419,126 @@  discard block
 block discarded – undo
419 419
 			try {
420 420
 				if ($globalTransaction) $Connection->db->beginTransaction();
421 421
 				$tmp = fgetcsv($fh,9999,',','"');
422
-            			while (!feof($fh)) {
423
-            				$line = fgetcsv($fh,9999,',','"');
424
-            				$values = array();
425
-            				//print_r($line);
426
-            				if ($country == 'F') {
427
-            				    $values['registration'] = $line[0];
428
-            				    $values['base'] = $line[4];
429
-            				    $values['owner'] = $line[5];
430
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
431
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
432
-					    $values['cancel'] = $line[7];
422
+						while (!feof($fh)) {
423
+							$line = fgetcsv($fh,9999,',','"');
424
+							$values = array();
425
+							//print_r($line);
426
+							if ($country == 'F') {
427
+								$values['registration'] = $line[0];
428
+								$values['base'] = $line[4];
429
+								$values['owner'] = $line[5];
430
+								if ($line[6] == '') $values['date_first_reg'] = null;
431
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
432
+						$values['cancel'] = $line[7];
433 433
 					} elseif ($country == 'EI') {
434
-					    // TODO : add modeS & reg to aircraft_modes
435
-            				    $values['registration'] = $line[0];
436
-            				    $values['base'] = $line[3];
437
-            				    $values['owner'] = $line[2];
438
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
439
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
440
-					    $values['cancel'] = '';
441
-					    $values['modes'] = $line[7];
442
-					    $values['icao'] = $line[8];
434
+						// TODO : add modeS & reg to aircraft_modes
435
+								$values['registration'] = $line[0];
436
+								$values['base'] = $line[3];
437
+								$values['owner'] = $line[2];
438
+								if ($line[1] == '') $values['date_first_reg'] = null;
439
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
440
+						$values['cancel'] = '';
441
+						$values['modes'] = $line[7];
442
+						$values['icao'] = $line[8];
443 443
 					    
444 444
 					} elseif ($country == 'HB') {
445
-					    // TODO : add modeS & reg to aircraft_modes
446
-            				    $values['registration'] = $line[0];
447
-            				    $values['base'] = null;
448
-            				    $values['owner'] = $line[5];
449
-            				    $values['date_first_reg'] = null;
450
-					    $values['cancel'] = '';
451
-					    $values['modes'] = $line[4];
452
-					    $values['icao'] = $line[7];
445
+						// TODO : add modeS & reg to aircraft_modes
446
+								$values['registration'] = $line[0];
447
+								$values['base'] = null;
448
+								$values['owner'] = $line[5];
449
+								$values['date_first_reg'] = null;
450
+						$values['cancel'] = '';
451
+						$values['modes'] = $line[4];
452
+						$values['icao'] = $line[7];
453 453
 					} elseif ($country == 'OK') {
454
-					    // TODO : add modeS & reg to aircraft_modes
455
-            				    $values['registration'] = $line[3];
456
-            				    $values['base'] = null;
457
-            				    $values['owner'] = $line[5];
458
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
460
-					    $values['cancel'] = '';
454
+						// TODO : add modeS & reg to aircraft_modes
455
+								$values['registration'] = $line[3];
456
+								$values['base'] = null;
457
+								$values['owner'] = $line[5];
458
+								if ($line[18] == '') $values['date_first_reg'] = null;
459
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
460
+						$values['cancel'] = '';
461 461
 					} elseif ($country == 'VH') {
462
-					    // TODO : add modeS & reg to aircraft_modes
463
-            				    $values['registration'] = $line[0];
464
-            				    $values['base'] = null;
465
-            				    $values['owner'] = $line[12];
466
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
467
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
468
-
469
-					    $values['cancel'] = $line[39];
462
+						// TODO : add modeS & reg to aircraft_modes
463
+								$values['registration'] = $line[0];
464
+								$values['base'] = null;
465
+								$values['owner'] = $line[12];
466
+								if ($line[28] == '') $values['date_first_reg'] = null;
467
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
468
+
469
+						$values['cancel'] = $line[39];
470 470
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
471
-            				    $values['registration'] = $line[0];
472
-            				    $values['base'] = null;
473
-            				    $values['owner'] = $line[4];
474
-            				    $values['date_first_reg'] = null;
475
-					    $values['cancel'] = '';
471
+								$values['registration'] = $line[0];
472
+								$values['base'] = null;
473
+								$values['owner'] = $line[4];
474
+								$values['date_first_reg'] = null;
475
+						$values['cancel'] = '';
476 476
 					} elseif ($country == 'CC') {
477
-            				    $values['registration'] = $line[0];
478
-            				    $values['base'] = null;
479
-            				    $values['owner'] = $line[6];
480
-            				    $values['date_first_reg'] = null;
481
-					    $values['cancel'] = '';
477
+								$values['registration'] = $line[0];
478
+								$values['base'] = null;
479
+								$values['owner'] = $line[6];
480
+								$values['date_first_reg'] = null;
481
+						$values['cancel'] = '';
482 482
 					} elseif ($country == 'HJ') {
483
-            				    $values['registration'] = $line[0];
484
-            				    $values['base'] = null;
485
-            				    $values['owner'] = $line[8];
486
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
487
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
488
-					    $values['cancel'] = '';
483
+								$values['registration'] = $line[0];
484
+								$values['base'] = null;
485
+								$values['owner'] = $line[8];
486
+								if ($line[7] == '') $values['date_first_reg'] = null;
487
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
488
+						$values['cancel'] = '';
489 489
 					} elseif ($country == 'PP') {
490
-            				    $values['registration'] = $line[0];
491
-            				    $values['base'] = null;
492
-            				    $values['owner'] = $line[4];
493
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
494
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
495
-					    $values['cancel'] = $line[7];
490
+								$values['registration'] = $line[0];
491
+								$values['base'] = null;
492
+								$values['owner'] = $line[4];
493
+								if ($line[6] == '') $values['date_first_reg'] = null;
494
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
495
+						$values['cancel'] = $line[7];
496 496
 					} elseif ($country == 'E7') {
497
-            				    $values['registration'] = $line[0];
498
-            				    $values['base'] = null;
499
-            				    $values['owner'] = $line[4];
500
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
501
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
502
-					    $values['cancel'] = '';
497
+								$values['registration'] = $line[0];
498
+								$values['base'] = null;
499
+								$values['owner'] = $line[4];
500
+								if ($line[5] == '') $values['date_first_reg'] = null;
501
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
502
+						$values['cancel'] = '';
503 503
 					} elseif ($country == '8Q') {
504
-            				    $values['registration'] = $line[0];
505
-            				    $values['base'] = null;
506
-            				    $values['owner'] = $line[3];
507
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
508
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
509
-					    $values['cancel'] = '';
504
+								$values['registration'] = $line[0];
505
+								$values['base'] = null;
506
+								$values['owner'] = $line[3];
507
+								if ($line[7] == '') $values['date_first_reg'] = null;
508
+						else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
509
+						$values['cancel'] = '';
510 510
 					} elseif ($country == 'ZK') {
511
-            				    $values['registration'] = $line[0];
512
-            				    $values['base'] = null;
513
-            				    $values['owner'] = $line[3];
514
-            				    $values['date_first_reg'] = null;
515
-					    $values['cancel'] = '';
516
-					    $values['modes'] = $line[5];
517
-					    $values['icao'] = $line[9];
511
+								$values['registration'] = $line[0];
512
+								$values['base'] = null;
513
+								$values['owner'] = $line[3];
514
+								$values['date_first_reg'] = null;
515
+						$values['cancel'] = '';
516
+						$values['modes'] = $line[5];
517
+						$values['icao'] = $line[9];
518 518
 					} elseif ($country == 'M') {
519
-            				    $values['registration'] = $line[0];
520
-            				    $values['base'] = null;
521
-            				    $values['owner'] = $line[6];
522
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
523
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
524
-					    $values['modes'] = $line[4];
525
-					    $values['icao'] = $line[10];
519
+								$values['registration'] = $line[0];
520
+								$values['base'] = null;
521
+								$values['owner'] = $line[6];
522
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
523
+						$values['cancel'] = date("Y-m-d",strtotime($line[8]));
524
+						$values['modes'] = $line[4];
525
+						$values['icao'] = $line[10];
526 526
 					} elseif ($country == 'OY') {
527
-            				    $values['registration'] = $line[0];
528
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
529
-					    $values['modes'] = $line[5];
530
-					    $values['icao'] = $line[6];
527
+								$values['registration'] = $line[0];
528
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
529
+						$values['modes'] = $line[5];
530
+						$values['icao'] = $line[6];
531 531
 					} elseif ($country == 'PH') {
532
-            				    $values['registration'] = $line[0];
533
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
534
-					    $values['modes'] = $line[4];
535
-					    $values['icao'] = $line[5];
532
+								$values['registration'] = $line[0];
533
+								$values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
534
+						$values['modes'] = $line[4];
535
+						$values['icao'] = $line[5];
536 536
 					} elseif ($country == 'OM' || $country == 'TF') {
537
-            				    $values['registration'] = $line[0];
538
-            				    $values['base'] = null;
539
-            				    $values['owner'] = $line[3];
540
-            				    $values['date_first_reg'] = null;
541
-					    $values['cancel'] = '';
537
+								$values['registration'] = $line[0];
538
+								$values['base'] = null;
539
+								$values['owner'] = $line[3];
540
+								$values['date_first_reg'] = null;
541
+						$values['cancel'] = '';
542 542
 					}
543 543
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
544 544
 						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
@@ -665,20 +665,20 @@  discard block
 block discarded – undo
665 665
 		try {
666 666
 			$Connection = new Connection();
667 667
 			$sth = $Connection->db->prepare($query);
668
-                        $sth->execute();
669
-                } catch(PDOException $e) {
670
-                        return "error : ".$e->getMessage();
671
-                }
668
+						$sth->execute();
669
+				} catch(PDOException $e) {
670
+						return "error : ".$e->getMessage();
671
+				}
672 672
 
673 673
 
674 674
 		$query = 'ALTER TABLE airport DROP INDEX icaoidx';
675 675
 		try {
676 676
 			$Connection = new Connection();
677 677
 			$sth = $Connection->db->prepare($query);
678
-                        $sth->execute();
679
-                } catch(PDOException $e) {
680
-                        return "error : ".$e->getMessage();
681
-                }
678
+						$sth->execute();
679
+				} catch(PDOException $e) {
680
+						return "error : ".$e->getMessage();
681
+				}
682 682
 
683 683
 		$query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`)
684 684
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
@@ -744,10 +744,10 @@  discard block
 block discarded – undo
744 744
 		try {
745 745
 			$Connection = new Connection();
746 746
 			$sth = $Connection->db->prepare($query);
747
-                        $sth->execute();
748
-                } catch(PDOException $e) {
749
-                        return "error : ".$e->getMessage();
750
-                }
747
+						$sth->execute();
748
+				} catch(PDOException $e) {
749
+						return "error : ".$e->getMessage();
750
+				}
751 751
 
752 752
 
753 753
 		if ($globalDebug) echo "Insert Not available Airport...\n";
@@ -757,10 +757,10 @@  discard block
 block discarded – undo
757 757
 		try {
758 758
 			$Connection = new Connection();
759 759
 			$sth = $Connection->db->prepare($query);
760
-                        $sth->execute($query_values);
761
-                } catch(PDOException $e) {
762
-                        return "error : ".$e->getMessage();
763
-                }
760
+						$sth->execute($query_values);
761
+				} catch(PDOException $e) {
762
+						return "error : ".$e->getMessage();
763
+				}
764 764
 		$i++;
765 765
 /*
766 766
 		$query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)';
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 
875 875
 
876 876
 
877
-                return "success";
877
+				return "success";
878 878
 	}
879 879
 	
880 880
 	public static function translation() {
@@ -890,10 +890,10 @@  discard block
 block discarded – undo
890 890
 		try {
891 891
 			$Connection = new Connection();
892 892
 			$sth = $Connection->db->prepare($query);
893
-                        $sth->execute(array(':source' => 'translation.csv'));
894
-                } catch(PDOException $e) {
895
-                        return "error : ".$e->getMessage();
896
-                }
893
+						$sth->execute(array(':source' => 'translation.csv'));
894
+				} catch(PDOException $e) {
895
+						return "error : ".$e->getMessage();
896
+				}
897 897
 
898 898
 		
899 899
 		//update_db::unzip($out_file);
@@ -912,21 +912,21 @@  discard block
 block discarded – undo
912 912
 					$data = $row;
913 913
 					$operator = $data[2];
914 914
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
915
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
916
-                                                //echo substr($operator, 0, 2)."\n";;
917
-                                                if (count($airline_array) > 0) {
915
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2));
916
+												//echo substr($operator, 0, 2)."\n";;
917
+												if (count($airline_array) > 0) {
918 918
 							//print_r($airline_array);
919 919
 							$operator = $airline_array[0]['icao'].substr($operator,2);
920
-                                                }
921
-                                        }
920
+												}
921
+										}
922 922
 					
923 923
 					$operator_correct = $data[3];
924 924
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
925
-                                                $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
926
-                                                if (count($airline_array) > 0) {
927
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
928
-                                            	}
929
-                                        }
925
+												$airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
926
+												if (count($airline_array) > 0) {
927
+													$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
928
+												}
929
+										}
930 930
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
931 931
 					try {
932 932
 						$sth = $Connection->db->prepare($query);
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 			//$Connection->db->commit();
941 941
 		}
942 942
 		return '';
943
-        }
943
+		}
944 944
 	
945 945
 	public static function translation_fam() {
946 946
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -950,10 +950,10 @@  discard block
 block discarded – undo
950 950
 		try {
951 951
 			$Connection = new Connection();
952 952
 			$sth = $Connection->db->prepare($query);
953
-                        $sth->execute(array(':source' => 'website_fam'));
954
-                } catch(PDOException $e) {
955
-                        return "error : ".$e->getMessage();
956
-                }
953
+						$sth->execute(array(':source' => 'website_fam'));
954
+				} catch(PDOException $e) {
955
+						return "error : ".$e->getMessage();
956
+				}
957 957
 
958 958
 		
959 959
 		//update_db::unzip($out_file);
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 			//$Connection->db->commit();
983 983
 		}
984 984
 		return '';
985
-        }
985
+		}
986 986
 
987 987
 	/*
988 988
 	* This function use FAA public data.
@@ -994,19 +994,19 @@  discard block
 block discarded – undo
994 994
 		try {
995 995
 			$Connection = new Connection();
996 996
 			$sth = $Connection->db->prepare($query);
997
-                        $sth->execute(array(':source' => 'website_faa'));
998
-                } catch(PDOException $e) {
999
-                        return "error : ".$e->getMessage();
1000
-                }
997
+						$sth->execute(array(':source' => 'website_faa'));
998
+				} catch(PDOException $e) {
999
+						return "error : ".$e->getMessage();
1000
+				}
1001 1001
 
1002 1002
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source = :source";
1003 1003
 		try {
1004 1004
 			$Connection = new Connection();
1005 1005
 			$sth = $Connection->db->prepare($query);
1006
-                        $sth->execute(array(':source' => 'website_faa'));
1007
-                } catch(PDOException $e) {
1008
-                        return "error : ".$e->getMessage();
1009
-                }
1006
+						$sth->execute(array(':source' => 'website_faa'));
1007
+				} catch(PDOException $e) {
1008
+						return "error : ".$e->getMessage();
1009
+				}
1010 1010
 
1011 1011
 		$delimiter = ",";
1012 1012
 		$mfr = array();
@@ -1082,17 +1082,17 @@  discard block
 block discarded – undo
1082 1082
 		}
1083 1083
 		print_r($mfr);
1084 1084
 		return '';
1085
-        }
1085
+		}
1086 1086
 	public static function modes_fam() {
1087 1087
 		global $tmp_dir, $globalTransaction;
1088 1088
 		$query = "DELETE FROM aircraft_modes WHERE Source = '' OR Source = :source";
1089 1089
 		try {
1090 1090
 			$Connection = new Connection();
1091 1091
 			$sth = $Connection->db->prepare($query);
1092
-                        $sth->execute(array(':source' => 'website_fam'));
1093
-                } catch(PDOException $e) {
1094
-                        return "error : ".$e->getMessage();
1095
-                }
1092
+						$sth->execute(array(':source' => 'website_fam'));
1093
+				} catch(PDOException $e) {
1094
+						return "error : ".$e->getMessage();
1095
+				}
1096 1096
 
1097 1097
 		
1098 1098
 		//update_db::unzip($out_file);
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
 			if ($globalTransaction) $Connection->db->commit();
1123 1123
 		}
1124 1124
 		return '';
1125
-        }
1125
+		}
1126 1126
         
1127 1127
 	public static function owner_fam() {
1128 1128
 		global $tmp_dir, $globalTransaction;
@@ -1130,10 +1130,10 @@  discard block
 block discarded – undo
1130 1130
 		try {
1131 1131
 			$Connection = new Connection();
1132 1132
 			$sth = $Connection->db->prepare($query);
1133
-                        $sth->execute(array(':source' => 'website_fam'));
1134
-                } catch(PDOException $e) {
1135
-                        return "error : ".$e->getMessage();
1136
-                }
1133
+						$sth->execute(array(':source' => 'website_fam'));
1134
+				} catch(PDOException $e) {
1135
+						return "error : ".$e->getMessage();
1136
+				}
1137 1137
 
1138 1138
 		$delimiter = "\t";
1139 1139
 		$Connection = new Connection();
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
 			if ($globalTransaction) $Connection->db->commit();
1160 1160
 		}
1161 1161
 		return '';
1162
-        }
1162
+		}
1163 1163
 
1164 1164
 	public static function routes_fam() {
1165 1165
 		global $tmp_dir, $globalTransaction;
@@ -1167,10 +1167,10 @@  discard block
 block discarded – undo
1167 1167
 		try {
1168 1168
 			$Connection = new Connection();
1169 1169
 			$sth = $Connection->db->prepare($query);
1170
-                        $sth->execute(array(':source' => 'website_fam'));
1171
-                } catch(PDOException $e) {
1172
-                        return "error : ".$e->getMessage();
1173
-                }
1170
+						$sth->execute(array(':source' => 'website_fam'));
1171
+				} catch(PDOException $e) {
1172
+						return "error : ".$e->getMessage();
1173
+				}
1174 1174
 
1175 1175
 		
1176 1176
 		//update_db::unzip($out_file);
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
 			if ($globalTransaction) $Connection->db->commit();
1200 1200
 		}
1201 1201
 		return '';
1202
-        }
1202
+		}
1203 1203
 
1204 1204
 	public static function banned_fam() {
1205 1205
 		global $tmp_dir, $globalTransaction;
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
 			if ($globalTransaction) $Connection->db->commit();
1234 1234
 		}
1235 1235
 		return '';
1236
-        }
1236
+		}
1237 1237
 
1238 1238
 	public static function tle($filename,$tletype) {
1239 1239
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1244,10 +1244,10 @@  discard block
 block discarded – undo
1244 1244
 		try {
1245 1245
 			$Connection = new Connection();
1246 1246
 			$sth = $Connection->db->prepare($query);
1247
-                        $sth->execute(array(':source' => $filename));
1248
-                } catch(PDOException $e) {
1249
-                        return "error : ".$e->getMessage();
1250
-                }
1247
+						$sth->execute(array(':source' => $filename));
1248
+				} catch(PDOException $e) {
1249
+						return "error : ".$e->getMessage();
1250
+				}
1251 1251
 		
1252 1252
 		$Connection = new Connection();
1253 1253
 		if (($handle = fopen($filename, 'r')) !== FALSE)
@@ -1282,54 +1282,54 @@  discard block
 block discarded – undo
1282 1282
 			//$Connection->db->commit();
1283 1283
 		}
1284 1284
 		return '';
1285
-        }
1285
+		}
1286 1286
 
1287 1287
 	/**
1288
-        * Convert a HTML table to an array
1289
-        * @param String $data HTML page
1290
-        * @return Array array of the tables in HTML page
1291
-        */
1292
-        private static function table2array($data) {
1293
-                $html = str_get_html($data);
1294
-                $tabledata=array();
1295
-                foreach($html->find('tr') as $element)
1296
-                {
1297
-                        $td = array();
1298
-                        foreach( $element->find('th') as $row)
1299
-                        {
1300
-                                $td [] = trim($row->plaintext);
1301
-                        }
1302
-                        $td=array_filter($td);
1303
-                        $tabledata[] = $td;
1304
-
1305
-                        $td = array();
1306
-                        $tdi = array();
1307
-                        foreach( $element->find('td') as $row)
1308
-                        {
1309
-                                $td [] = trim($row->plaintext);
1310
-                                $tdi [] = trim($row->innertext);
1311
-                        }
1312
-                        $td=array_filter($td);
1313
-                        $tdi=array_filter($tdi);
1314
-                    //    $tabledata[]=array_merge($td,$tdi);
1315
-                        $tabledata[]=$td;
1316
-                }
1317
-                return(array_filter($tabledata));
1318
-        }
1319
-
1320
-       /**
1321
-        * Get data from form result
1322
-        * @param String $url form URL
1323
-        * @return String the result
1324
-        */
1325
-        private static function getData($url) {
1326
-                $ch = curl_init();
1327
-                curl_setopt($ch, CURLOPT_URL, $url);
1328
-                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1329
-                curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1330
-                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');
1331
-                return curl_exec($ch);
1332
-        }
1288
+	 * Convert a HTML table to an array
1289
+	 * @param String $data HTML page
1290
+	 * @return Array array of the tables in HTML page
1291
+	 */
1292
+		private static function table2array($data) {
1293
+				$html = str_get_html($data);
1294
+				$tabledata=array();
1295
+				foreach($html->find('tr') as $element)
1296
+				{
1297
+						$td = array();
1298
+						foreach( $element->find('th') as $row)
1299
+						{
1300
+								$td [] = trim($row->plaintext);
1301
+						}
1302
+						$td=array_filter($td);
1303
+						$tabledata[] = $td;
1304
+
1305
+						$td = array();
1306
+						$tdi = array();
1307
+						foreach( $element->find('td') as $row)
1308
+						{
1309
+								$td [] = trim($row->plaintext);
1310
+								$tdi [] = trim($row->innertext);
1311
+						}
1312
+						$td=array_filter($td);
1313
+						$tdi=array_filter($tdi);
1314
+					//    $tabledata[]=array_merge($td,$tdi);
1315
+						$tabledata[]=$td;
1316
+				}
1317
+				return(array_filter($tabledata));
1318
+		}
1319
+
1320
+	   /**
1321
+	    * Get data from form result
1322
+	    * @param String $url form URL
1323
+	    * @return String the result
1324
+	    */
1325
+		private static function getData($url) {
1326
+				$ch = curl_init();
1327
+				curl_setopt($ch, CURLOPT_URL, $url);
1328
+				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1329
+				curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1330
+				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');
1331
+				return curl_exec($ch);
1332
+		}
1333 1333
 /*
1334 1334
 	public static function waypoints() {
1335 1335
 		$data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html');
@@ -1412,7 +1412,7 @@  discard block
 block discarded – undo
1412 1412
 			if ($globalTransaction) $Connection->db->commit();
1413 1413
 		}
1414 1414
 		return '';
1415
-        }
1415
+		}
1416 1416
 
1417 1417
 	public static function ivao_airlines($filename) {
1418 1418
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
@@ -1422,10 +1422,10 @@  discard block
 block discarded – undo
1422 1422
 		try {
1423 1423
 			$Connection = new Connection();
1424 1424
 			$sth = $Connection->db->prepare($query);
1425
-                        $sth->execute();
1426
-                } catch(PDOException $e) {
1427
-                        return "error : ".$e->getMessage();
1428
-                }
1425
+						$sth->execute();
1426
+				} catch(PDOException $e) {
1427
+						return "error : ".$e->getMessage();
1428
+				}
1429 1429
 
1430 1430
 		$header = NULL;
1431 1431
 		$delimiter = ':';
@@ -1449,7 +1449,7 @@  discard block
 block discarded – undo
1449 1449
 			if ($globalTransaction) $Connection->db->commit();
1450 1450
 		}
1451 1451
 		return '';
1452
-        }
1452
+		}
1453 1453
 	
1454 1454
 	public static function update_airspace() {
1455 1455
 		global $tmp_dir, $globalDBdriver;
@@ -1459,11 +1459,11 @@  discard block
 block discarded – undo
1459 1459
 			$query = 'DROP TABLE airspace';
1460 1460
 			try {
1461 1461
 				$sth = $Connection->db->prepare($query);
1462
-                    		$sth->execute();
1463
-	                } catch(PDOException $e) {
1462
+							$sth->execute();
1463
+					} catch(PDOException $e) {
1464 1464
 				return "error : ".$e->getMessage();
1465
-	                }
1466
-	        }
1465
+					}
1466
+			}
1467 1467
 
1468 1468
 
1469 1469
 		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
@@ -1518,10 +1518,10 @@  discard block
 block discarded – undo
1518 1518
 			$query = 'DROP TABLE countries';
1519 1519
 			try {
1520 1520
 				$sth = $Connection->db->prepare($query);
1521
-            	        	$sth->execute();
1522
-	                } catch(PDOException $e) {
1523
-    	                	echo "error : ".$e->getMessage();
1524
-	                }
1521
+							$sth->execute();
1522
+					} catch(PDOException $e) {
1523
+							echo "error : ".$e->getMessage();
1524
+					}
1525 1525
 		}
1526 1526
 		if ($globalDBdriver == 'mysql') {
1527 1527
 			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
@@ -2025,11 +2025,11 @@  discard block
 block discarded – undo
2025 2025
 						$query = 'DROP TABLE airspace';
2026 2026
 						try {
2027 2027
 							$sth = $Connection->db->prepare($query);
2028
-    	    	    					$sth->execute();
2029
-			            		} catch(PDOException $e) {
2028
+										$sth->execute();
2029
+								} catch(PDOException $e) {
2030 2030
 							return "error : ".$e->getMessage();
2031
-		            			}
2032
-		    			}
2031
+								}
2032
+						}
2033 2033
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2034 2034
 					update_db::insert_airspace_version($airspace_md5);
2035 2035
 				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
@@ -2149,12 +2149,12 @@  discard block
 block discarded – undo
2149 2149
 		echo $data;
2150 2150
 		*/
2151 2151
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2152
-		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2153
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2154
-		    $result = fread($fh,100000000);
2155
-		    //echo $result;
2156
-		    //var_dump(str_get_html($result));
2157
-		    //print_r(self::table2array($result));
2152
+			//var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2153
+			$fh = fopen($tmp_dir.'aircrafts.html',"r");
2154
+			$result = fread($fh,100000000);
2155
+			//echo $result;
2156
+			//var_dump(str_get_html($result));
2157
+			//print_r(self::table2array($result));
2158 2158
 		}
2159 2159
 
2160 2160
 	}
@@ -2168,10 +2168,10 @@  discard block
 block discarded – undo
2168 2168
 		try {
2169 2169
 			$Connection = new Connection();
2170 2170
 			$sth = $Connection->db->prepare($query);
2171
-                        $sth->execute();
2172
-                } catch(PDOException $e) {
2173
-                        return "error : ".$e->getMessage();
2174
-                }
2171
+						$sth->execute();
2172
+				} catch(PDOException $e) {
2173
+						return "error : ".$e->getMessage();
2174
+				}
2175 2175
 
2176 2176
 		$error = '';
2177 2177
 		if ($globalDebug) echo "Notam : Download...";
@@ -2227,8 +2227,8 @@  discard block
 block discarded – undo
2227 2227
 					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2228 2228
 					$data['permanent'] = 0;
2229 2229
 				} else {
2230
-				    $data['date_end'] = NULL;
2231
-				    $data['permanent'] = 1;
2230
+					$data['date_end'] = NULL;
2231
+					$data['permanent'] = 1;
2232 2232
 				}
2233 2233
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2234 2234
 				$NOTAM = new NOTAM();
@@ -2302,13 +2302,13 @@  discard block
 block discarded – undo
2302 2302
 		try {
2303 2303
 			$Connection = new Connection();
2304 2304
 			$sth = $Connection->db->prepare($query);
2305
-                        $sth->execute();
2306
-                } catch(PDOException $e) {
2307
-                        return "error : ".$e->getMessage();
2308
-                }
2309
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2310
-                if ($row['nb'] > 0) return false;
2311
-                else return true;
2305
+						$sth->execute();
2306
+				} catch(PDOException $e) {
2307
+						return "error : ".$e->getMessage();
2308
+				}
2309
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2310
+				if ($row['nb'] > 0) return false;
2311
+				else return true;
2312 2312
 	}
2313 2313
 
2314 2314
 	public static function insert_last_update() {
@@ -2317,10 +2317,10 @@  discard block
 block discarded – undo
2317 2317
 		try {
2318 2318
 			$Connection = new Connection();
2319 2319
 			$sth = $Connection->db->prepare($query);
2320
-                        $sth->execute();
2321
-                } catch(PDOException $e) {
2322
-                        return "error : ".$e->getMessage();
2323
-                }
2320
+						$sth->execute();
2321
+				} catch(PDOException $e) {
2322
+						return "error : ".$e->getMessage();
2323
+				}
2324 2324
 	}
2325 2325
 
2326 2326
 	public static function check_airspace_version($version) {
@@ -2328,13 +2328,13 @@  discard block
 block discarded – undo
2328 2328
 		try {
2329 2329
 			$Connection = new Connection();
2330 2330
 			$sth = $Connection->db->prepare($query);
2331
-                        $sth->execute(array(':version' => $version));
2332
-                } catch(PDOException $e) {
2333
-                        return "error : ".$e->getMessage();
2334
-                }
2335
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2336
-                if ($row['nb'] > 0) return true;
2337
-                else return false;
2331
+						$sth->execute(array(':version' => $version));
2332
+				} catch(PDOException $e) {
2333
+						return "error : ".$e->getMessage();
2334
+				}
2335
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2336
+				if ($row['nb'] > 0) return true;
2337
+				else return false;
2338 2338
 	}
2339 2339
 
2340 2340
 
@@ -2344,10 +2344,10 @@  discard block
 block discarded – undo
2344 2344
 		try {
2345 2345
 			$Connection = new Connection();
2346 2346
 			$sth = $Connection->db->prepare($query);
2347
-                        $sth->execute(array(':version' => $version));
2348
-                } catch(PDOException $e) {
2349
-                        return "error : ".$e->getMessage();
2350
-                }
2347
+						$sth->execute(array(':version' => $version));
2348
+				} catch(PDOException $e) {
2349
+						return "error : ".$e->getMessage();
2350
+				}
2351 2351
 	}
2352 2352
 
2353 2353
 	public static function check_last_notam_update() {
@@ -2360,13 +2360,13 @@  discard block
 block discarded – undo
2360 2360
 		try {
2361 2361
 			$Connection = new Connection();
2362 2362
 			$sth = $Connection->db->prepare($query);
2363
-                        $sth->execute();
2364
-                } catch(PDOException $e) {
2365
-                        return "error : ".$e->getMessage();
2366
-                }
2367
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2368
-                if ($row['nb'] > 0) return false;
2369
-                else return true;
2363
+						$sth->execute();
2364
+				} catch(PDOException $e) {
2365
+						return "error : ".$e->getMessage();
2366
+				}
2367
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2368
+				if ($row['nb'] > 0) return false;
2369
+				else return true;
2370 2370
 	}
2371 2371
 
2372 2372
 	public static function insert_last_notam_update() {
@@ -2375,10 +2375,10 @@  discard block
 block discarded – undo
2375 2375
 		try {
2376 2376
 			$Connection = new Connection();
2377 2377
 			$sth = $Connection->db->prepare($query);
2378
-                        $sth->execute();
2379
-                } catch(PDOException $e) {
2380
-                        return "error : ".$e->getMessage();
2381
-                }
2378
+						$sth->execute();
2379
+				} catch(PDOException $e) {
2380
+						return "error : ".$e->getMessage();
2381
+				}
2382 2382
 	}
2383 2383
 	public static function check_last_airspace_update() {
2384 2384
 		global $globalDBdriver;
@@ -2390,13 +2390,13 @@  discard block
 block discarded – undo
2390 2390
 		try {
2391 2391
 			$Connection = new Connection();
2392 2392
 			$sth = $Connection->db->prepare($query);
2393
-                        $sth->execute();
2394
-                } catch(PDOException $e) {
2395
-                        return "error : ".$e->getMessage();
2396
-                }
2397
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2398
-                if ($row['nb'] > 0) return false;
2399
-                else return true;
2393
+						$sth->execute();
2394
+				} catch(PDOException $e) {
2395
+						return "error : ".$e->getMessage();
2396
+				}
2397
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2398
+				if ($row['nb'] > 0) return false;
2399
+				else return true;
2400 2400
 	}
2401 2401
 
2402 2402
 	public static function insert_last_airspace_update() {
@@ -2405,10 +2405,10 @@  discard block
 block discarded – undo
2405 2405
 		try {
2406 2406
 			$Connection = new Connection();
2407 2407
 			$sth = $Connection->db->prepare($query);
2408
-                        $sth->execute();
2409
-                } catch(PDOException $e) {
2410
-                        return "error : ".$e->getMessage();
2411
-                }
2408
+						$sth->execute();
2409
+				} catch(PDOException $e) {
2410
+						return "error : ".$e->getMessage();
2411
+				}
2412 2412
 	}
2413 2413
 
2414 2414
 	public static function check_last_owner_update() {
@@ -2421,13 +2421,13 @@  discard block
 block discarded – undo
2421 2421
 		try {
2422 2422
 			$Connection = new Connection();
2423 2423
 			$sth = $Connection->db->prepare($query);
2424
-                        $sth->execute();
2425
-                } catch(PDOException $e) {
2426
-                        return "error : ".$e->getMessage();
2427
-                }
2428
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2429
-                if ($row['nb'] > 0) return false;
2430
-                else return true;
2424
+						$sth->execute();
2425
+				} catch(PDOException $e) {
2426
+						return "error : ".$e->getMessage();
2427
+				}
2428
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2429
+				if ($row['nb'] > 0) return false;
2430
+				else return true;
2431 2431
 	}
2432 2432
 
2433 2433
 	public static function insert_last_owner_update() {
@@ -2436,10 +2436,10 @@  discard block
 block discarded – undo
2436 2436
 		try {
2437 2437
 			$Connection = new Connection();
2438 2438
 			$sth = $Connection->db->prepare($query);
2439
-                        $sth->execute();
2440
-                } catch(PDOException $e) {
2441
-                        return "error : ".$e->getMessage();
2442
-                }
2439
+						$sth->execute();
2440
+				} catch(PDOException $e) {
2441
+						return "error : ".$e->getMessage();
2442
+				}
2443 2443
 	}
2444 2444
 	public static function check_last_schedules_update() {
2445 2445
 		global $globalDBdriver;
@@ -2451,13 +2451,13 @@  discard block
 block discarded – undo
2451 2451
 		try {
2452 2452
 			$Connection = new Connection();
2453 2453
 			$sth = $Connection->db->prepare($query);
2454
-                        $sth->execute();
2455
-                } catch(PDOException $e) {
2456
-                        return "error : ".$e->getMessage();
2457
-                }
2458
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2459
-                if ($row['nb'] > 0) return false;
2460
-                else return true;
2454
+						$sth->execute();
2455
+				} catch(PDOException $e) {
2456
+						return "error : ".$e->getMessage();
2457
+				}
2458
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2459
+				if ($row['nb'] > 0) return false;
2460
+				else return true;
2461 2461
 	}
2462 2462
 
2463 2463
 	public static function insert_last_schedules_update() {
@@ -2466,10 +2466,10 @@  discard block
 block discarded – undo
2466 2466
 		try {
2467 2467
 			$Connection = new Connection();
2468 2468
 			$sth = $Connection->db->prepare($query);
2469
-                        $sth->execute();
2470
-                } catch(PDOException $e) {
2471
-                        return "error : ".$e->getMessage();
2472
-                }
2469
+						$sth->execute();
2470
+				} catch(PDOException $e) {
2471
+						return "error : ".$e->getMessage();
2472
+				}
2473 2473
 	}
2474 2474
 	public static function check_last_tle_update() {
2475 2475
 		global $globalDBdriver;
@@ -2481,13 +2481,13 @@  discard block
 block discarded – undo
2481 2481
 		try {
2482 2482
 			$Connection = new Connection();
2483 2483
 			$sth = $Connection->db->prepare($query);
2484
-                        $sth->execute();
2485
-                } catch(PDOException $e) {
2486
-                        return "error : ".$e->getMessage();
2487
-                }
2488
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
2489
-                if ($row['nb'] > 0) return false;
2490
-                else return true;
2484
+						$sth->execute();
2485
+				} catch(PDOException $e) {
2486
+						return "error : ".$e->getMessage();
2487
+				}
2488
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
2489
+				if ($row['nb'] > 0) return false;
2490
+				else return true;
2491 2491
 	}
2492 2492
 
2493 2493
 	public static function insert_last_tle_update() {
@@ -2496,10 +2496,10 @@  discard block
 block discarded – undo
2496 2496
 		try {
2497 2497
 			$Connection = new Connection();
2498 2498
 			$sth = $Connection->db->prepare($query);
2499
-                        $sth->execute();
2500
-                } catch(PDOException $e) {
2501
-                        return "error : ".$e->getMessage();
2502
-                }
2499
+						$sth->execute();
2500
+				} catch(PDOException $e) {
2501
+						return "error : ".$e->getMessage();
2502
+				}
2503 2503
 	}
2504 2504
 	public static function delete_duplicatemodes() {
2505 2505
 		global $globalDBdriver;
@@ -2511,10 +2511,10 @@  discard block
 block discarded – undo
2511 2511
 		try {
2512 2512
 			$Connection = new Connection();
2513 2513
 			$sth = $Connection->db->prepare($query);
2514
-                        $sth->execute();
2515
-                } catch(PDOException $e) {
2516
-                        return "error : ".$e->getMessage();
2517
-                }
2514
+						$sth->execute();
2515
+				} catch(PDOException $e) {
2516
+						return "error : ".$e->getMessage();
2517
+				}
2518 2518
 	}
2519 2519
 	public static function delete_duplicateowner() {
2520 2520
 		global $globalDBdriver;
@@ -2526,10 +2526,10 @@  discard block
 block discarded – undo
2526 2526
 		try {
2527 2527
 			$Connection = new Connection();
2528 2528
 			$sth = $Connection->db->prepare($query);
2529
-                        $sth->execute();
2530
-                } catch(PDOException $e) {
2531
-                        return "error : ".$e->getMessage();
2532
-                }
2529
+						$sth->execute();
2530
+				} catch(PDOException $e) {
2531
+						return "error : ".$e->getMessage();
2532
+				}
2533 2533
 	}
2534 2534
 	
2535 2535
 	public static function update_all() {
Please login to merge, or discard this patch.
Spacing   +288 added lines, -288 removed lines patch added patch discarded remove patch
@@ -24,20 +24,20 @@  discard block
 block discarded – undo
24 24
 		fclose($fp);
25 25
 	}
26 26
 
27
-	public static function gunzip($in_file,$out_file_name = '') {
27
+	public static function gunzip($in_file, $out_file_name = '') {
28 28
 		//echo $in_file.' -> '.$out_file_name."\n";
29 29
 		$buffer_size = 4096; // read 4kb at a time
30 30
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
31 31
 		if ($in_file != '' && file_exists($in_file)) {
32 32
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
33
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
34
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
33
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
34
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
35 35
 			else {
36 36
 				echo 'gzopen not available';
37 37
 				die;
38 38
 			}
39 39
 			$out_file = fopen($out_file_name, 'wb'); 
40
-			while(!gzeof($file)) {
40
+			while (!gzeof($file)) {
41 41
 				fwrite($out_file, gzread($file, $buffer_size));
42 42
 			}  
43 43
 			fclose($out_file);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		try {
62 62
 			self::$db_sqlite = new PDO('sqlite:'.$database);
63 63
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
64
-		} catch(PDOException $e) {
64
+		} catch (PDOException $e) {
65 65
 			return "error : ".$e->getMessage();
66 66
 		}
67 67
 	}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			//$Connection = new Connection();
77 77
 			$sth = $Connection->db->prepare($query);
78 78
                         $sth->execute(array(':source' => $database_file));
79
-                } catch(PDOException $e) {
79
+                } catch (PDOException $e) {
80 80
                         return "error : ".$e->getMessage();
81 81
                 }
82 82
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		try {
88 88
                         $sth = update_db::$db_sqlite->prepare($query);
89 89
                         $sth->execute();
90
-                } catch(PDOException $e) {
90
+                } catch (PDOException $e) {
91 91
                         return "error : ".$e->getMessage();
92 92
                 }
93 93
 		//$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)';
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 			if ($globalTransaction) $Connection->db->beginTransaction();
99 99
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 100
 				//$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);
101
-				$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);
101
+				$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);
102 102
 				$sth_dest->execute($query_dest_values);
103 103
             		}
104 104
 			if ($globalTransaction) $Connection->db->commit();
105
-		} catch(PDOException $e) {
105
+		} catch (PDOException $e) {
106 106
 			if ($globalTransaction) $Connection->db->rollBack(); 
107 107
 			return "error : ".$e->getMessage();
108 108
 		}
@@ -118,26 +118,26 @@  discard block
 block discarded – undo
118 118
 			//$Connection = new Connection();
119 119
 			$sth = $Connection->db->prepare($query);
120 120
                         $sth->execute(array(':source' => 'oneworld'));
121
-                } catch(PDOException $e) {
121
+                } catch (PDOException $e) {
122 122
                         return "error : ".$e->getMessage();
123 123
                 }
124 124
 
125 125
     		if ($globalDebug) echo " - Add routes to DB -";
126 126
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 127
 		$Spotter = new Spotter();
128
-		if ($fh = fopen($database_file,"r")) {
128
+		if ($fh = fopen($database_file, "r")) {
129 129
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
130 130
 			$Connection = new Connection();
131 131
 			$sth_dest = $Connection->db->prepare($query_dest);
132 132
 			if ($globalTransaction) $Connection->db->beginTransaction();
133 133
 			while (!feof($fh)) {
134
-				$line = fgetcsv($fh,9999,',');
134
+				$line = fgetcsv($fh, 9999, ',');
135 135
 				if ($line[0] != '') {
136 136
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
137 137
 						try {
138
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
138
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld');
139 139
 							$sth_dest->execute($query_dest_values);
140
-						} catch(PDOException $e) {
140
+						} catch (PDOException $e) {
141 141
 							if ($globalTransaction) $Connection->db->rollBack(); 
142 142
 							return "error : ".$e->getMessage();
143 143
 						}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			//$Connection = new Connection();
160 160
 			$sth = $Connection->db->prepare($query);
161 161
                         $sth->execute(array(':source' => 'skyteam'));
162
-                } catch(PDOException $e) {
162
+                } catch (PDOException $e) {
163 163
                         return "error : ".$e->getMessage();
164 164
                 }
165 165
 
@@ -167,24 +167,24 @@  discard block
 block discarded – undo
167 167
 
168 168
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 169
 		$Spotter = new Spotter();
170
-		if ($fh = fopen($database_file,"r")) {
170
+		if ($fh = fopen($database_file, "r")) {
171 171
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
172 172
 			$Connection = new Connection();
173 173
 			$sth_dest = $Connection->db->prepare($query_dest);
174 174
 			try {
175 175
 				if ($globalTransaction) $Connection->db->beginTransaction();
176 176
 				while (!feof($fh)) {
177
-					$line = fgetcsv($fh,9999,',');
177
+					$line = fgetcsv($fh, 9999, ',');
178 178
 					if ($line[0] != '') {
179
-						$datebe = explode('  -  ',$line[2]);
179
+						$datebe = explode('  -  ', $line[2]);
180 180
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
181
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam');
181
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam');
182 182
 							$sth_dest->execute($query_dest_values);
183 183
 						}
184 184
 					}
185 185
 				}
186 186
 				if ($globalTransaction) $Connection->db->commit();
187
-			} catch(PDOException $e) {
187
+			} catch (PDOException $e) {
188 188
 				if ($globalTransaction) $Connection->db->rollBack(); 
189 189
 				return "error : ".$e->getMessage();
190 190
 			}
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 			$Connection = new Connection();
200 200
 			$sth = $Connection->db->prepare($query);
201 201
                         $sth->execute(array(':source' => $database_file));
202
-                } catch(PDOException $e) {
202
+                } catch (PDOException $e) {
203 203
                         return "error : ".$e->getMessage();
204 204
                 }
205 205
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 			$Connection = new Connection();
208 208
 			$sth = $Connection->db->prepare($query);
209 209
                         $sth->execute(array(':source' => $database_file));
210
-                } catch(PDOException $e) {
210
+                } catch (PDOException $e) {
211 211
                         return "error : ".$e->getMessage();
212 212
                 }
213 213
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		try {
217 217
                         $sth = update_db::$db_sqlite->prepare($query);
218 218
                         $sth->execute();
219
-                } catch(PDOException $e) {
219
+                } catch (PDOException $e) {
220 220
                         return "error : ".$e->getMessage();
221 221
                 }
222 222
 		//$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)';
@@ -233,15 +233,15 @@  discard block
 block discarded – undo
233 233
 			//$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']);
234 234
 				if ($values['UserString4'] == 'M') $type = 'military';
235 235
 				else $type = null;
236
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
236
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
237 237
 				$sth_dest->execute($query_dest_values);
238 238
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
239
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
239
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
240 240
 				    $sth_dest_owner->execute($query_dest_owner_values);
241 241
 				}
242 242
             		}
243 243
 			if ($globalTransaction) $Connection->db->commit();
244
-		} catch(PDOException $e) {
244
+		} catch (PDOException $e) {
245 245
 			return "error : ".$e->getMessage();
246 246
 		}
247 247
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 			$Connection = new Connection();
252 252
 			$sth = $Connection->db->prepare($query);
253 253
                         $sth->execute(array(':source' => $database_file));
254
-                } catch(PDOException $e) {
254
+                } catch (PDOException $e) {
255 255
                         return "error : ".$e->getMessage();
256 256
                 }
257 257
 		return '';
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
 			$Connection = new Connection();
267 267
 			$sth = $Connection->db->prepare($query);
268 268
                         $sth->execute(array(':source' => $database_file));
269
-                } catch(PDOException $e) {
269
+                } catch (PDOException $e) {
270 270
                         return "error : ".$e->getMessage();
271 271
                 }
272 272
 		
273
-		if ($fh = fopen($database_file,"r")) {
273
+		if ($fh = fopen($database_file, "r")) {
274 274
 			//$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)';
275 275
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)';
276 276
 		
@@ -280,13 +280,13 @@  discard block
 block discarded – undo
280 280
 				if ($globalTransaction) $Connection->db->beginTransaction();
281 281
             			while (!feof($fh)) {
282 282
             				$values = array();
283
-            				$line = $Common->hex2str(fgets($fh,9999));
283
+            				$line = $Common->hex2str(fgets($fh, 9999));
284 284
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
285
-            				$values['ModeS'] = substr($line,0,6);
286
-            				$values['Registration'] = trim(substr($line,69,6));
287
-            				$aircraft_name = trim(substr($line,48,6));
285
+            				$values['ModeS'] = substr($line, 0, 6);
286
+            				$values['Registration'] = trim(substr($line, 69, 6));
287
+            				$aircraft_name = trim(substr($line, 48, 6));
288 288
             				// Check if we can find ICAO, else set it to GLID
289
-            				$aircraft_name_split = explode(' ',$aircraft_name);
289
+            				$aircraft_name_split = explode(' ', $aircraft_name);
290 290
             				$search_more = '';
291 291
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
292 292
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -298,20 +298,20 @@  discard block
 block discarded – undo
298 298
 	            				if (isset($result['icao']) && $result['icao'] != '') {
299 299
 	            				    $values['ICAOTypeCode'] = $result['icao'];
300 300
 	            				} 
301
-					} catch(PDOException $e) {
301
+					} catch (PDOException $e) {
302 302
 						return "error : ".$e->getMessage();
303 303
 					}
304 304
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
305 305
 					// Add data to db
306 306
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
307 307
 						//$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']);
308
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file);
308
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file);
309 309
 						//print_r($query_dest_values);
310 310
 						$sth_dest->execute($query_dest_values);
311 311
 					}
312 312
 				}
313 313
 				if ($globalTransaction) $Connection->db->commit();
314
-			} catch(PDOException $e) {
314
+			} catch (PDOException $e) {
315 315
 				return "error : ".$e->getMessage();
316 316
 			}
317 317
 		}
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 			$Connection = new Connection();
322 322
 			$sth = $Connection->db->prepare($query);
323 323
                         $sth->execute(array(':source' => $database_file));
324
-                } catch(PDOException $e) {
324
+                } catch (PDOException $e) {
325 325
                         return "error : ".$e->getMessage();
326 326
                 }
327 327
 		return '';
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 			$Connection = new Connection();
336 336
 			$sth = $Connection->db->prepare($query);
337 337
                         $sth->execute(array(':source' => $database_file));
338
-                } catch(PDOException $e) {
338
+                } catch (PDOException $e) {
339 339
                         return "error : ".$e->getMessage();
340 340
                 }
341 341
 		
342
-		if ($fh = fopen($database_file,"r")) {
342
+		if ($fh = fopen($database_file, "r")) {
343 343
 			//$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)';
344 344
 			$query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source)';
345 345
 		
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 			$sth_dest = $Connection->db->prepare($query_dest);
348 348
 			try {
349 349
 				if ($globalTransaction) $Connection->db->beginTransaction();
350
-				$tmp = fgetcsv($fh,9999,',',"'");
350
+				$tmp = fgetcsv($fh, 9999, ',', "'");
351 351
             			while (!feof($fh)) {
352
-            				$line = fgetcsv($fh,9999,',',"'");
352
+            				$line = fgetcsv($fh, 9999, ',', "'");
353 353
             				
354 354
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
355 355
 					//print_r($line);
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
             				$values['Registration'] = $line[3];
358 358
             				$aircraft_name = $line[2];
359 359
             				// Check if we can find ICAO, else set it to GLID
360
-            				$aircraft_name_split = explode(' ',$aircraft_name);
360
+            				$aircraft_name_split = explode(' ', $aircraft_name);
361 361
             				$search_more = '';
362 362
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
363 363
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -366,20 +366,20 @@  discard block
 block discarded – undo
366 366
                                     		$sth_search->execute();
367 367
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368 368
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
369
-					} catch(PDOException $e) {
369
+					} catch (PDOException $e) {
370 370
 						return "error : ".$e->getMessage();
371 371
 					}
372 372
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
373 373
 					// Add data to db
374 374
 					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
375 375
 						//$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']);
376
-						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file);
376
+						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file);
377 377
 						//print_r($query_dest_values);
378 378
 						$sth_dest->execute($query_dest_values);
379 379
 					}
380 380
 				}
381 381
 				if ($globalTransaction) $Connection->db->commit();
382
-			} catch(PDOException $e) {
382
+			} catch (PDOException $e) {
383 383
 				return "error : ".$e->getMessage();
384 384
 			}
385 385
 		}
@@ -389,13 +389,13 @@  discard block
 block discarded – undo
389 389
 			$Connection = new Connection();
390 390
 			$sth = $Connection->db->prepare($query);
391 391
                         $sth->execute(array(':source' => $database_file));
392
-                } catch(PDOException $e) {
392
+                } catch (PDOException $e) {
393 393
                         return "error : ".$e->getMessage();
394 394
                 }
395 395
 		return '';
396 396
 	}
397 397
 
398
-	public static function retrieve_owner($database_file,$country = 'F') {
398
+	public static function retrieve_owner($database_file, $country = 'F') {
399 399
 		global $globalTransaction, $globalMasterSource;
400 400
 		//$query = 'TRUNCATE TABLE aircraft_modes';
401 401
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;";
@@ -403,12 +403,12 @@  discard block
 block discarded – undo
403 403
 			$Connection = new Connection();
404 404
 			$sth = $Connection->db->prepare($query);
405 405
                         $sth->execute(array(':source' => $database_file));
406
-                } catch(PDOException $e) {
406
+                } catch (PDOException $e) {
407 407
                         return "error : ".$e->getMessage();
408 408
                 }
409 409
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
410 410
 		$Spotter = new Spotter();
411
-		if ($fh = fopen($database_file,"r")) {
411
+		if ($fh = fopen($database_file, "r")) {
412 412
 			//$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)';
413 413
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
414 414
 		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
 			$sth_modes = $Connection->db->prepare($query_modes);
419 419
 			try {
420 420
 				if ($globalTransaction) $Connection->db->beginTransaction();
421
-				$tmp = fgetcsv($fh,9999,',','"');
421
+				$tmp = fgetcsv($fh, 9999, ',', '"');
422 422
             			while (!feof($fh)) {
423
-            				$line = fgetcsv($fh,9999,',','"');
423
+            				$line = fgetcsv($fh, 9999, ',', '"');
424 424
             				$values = array();
425 425
             				//print_r($line);
426 426
             				if ($country == 'F') {
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
             				    $values['base'] = $line[4];
429 429
             				    $values['owner'] = $line[5];
430 430
             				    if ($line[6] == '') $values['date_first_reg'] = null;
431
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
431
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
432 432
 					    $values['cancel'] = $line[7];
433 433
 					} elseif ($country == 'EI') {
434 434
 					    // TODO : add modeS & reg to aircraft_modes
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
             				    $values['base'] = $line[3];
437 437
             				    $values['owner'] = $line[2];
438 438
             				    if ($line[1] == '') $values['date_first_reg'] = null;
439
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
439
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
440 440
 					    $values['cancel'] = '';
441 441
 					    $values['modes'] = $line[7];
442 442
 					    $values['icao'] = $line[8];
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
             				    $values['base'] = null;
457 457
             				    $values['owner'] = $line[5];
458 458
             				    if ($line[18] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
459
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
460 460
 					    $values['cancel'] = '';
461 461
 					} elseif ($country == 'VH') {
462 462
 					    // TODO : add modeS & reg to aircraft_modes
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
             				    $values['base'] = null;
465 465
             				    $values['owner'] = $line[12];
466 466
             				    if ($line[28] == '') $values['date_first_reg'] = null;
467
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
467
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
468 468
 
469 469
 					    $values['cancel'] = $line[39];
470 470
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -484,28 +484,28 @@  discard block
 block discarded – undo
484 484
             				    $values['base'] = null;
485 485
             				    $values['owner'] = $line[8];
486 486
             				    if ($line[7] == '') $values['date_first_reg'] = null;
487
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
487
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
488 488
 					    $values['cancel'] = '';
489 489
 					} elseif ($country == 'PP') {
490 490
             				    $values['registration'] = $line[0];
491 491
             				    $values['base'] = null;
492 492
             				    $values['owner'] = $line[4];
493 493
             				    if ($line[6] == '') $values['date_first_reg'] = null;
494
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
494
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
495 495
 					    $values['cancel'] = $line[7];
496 496
 					} elseif ($country == 'E7') {
497 497
             				    $values['registration'] = $line[0];
498 498
             				    $values['base'] = null;
499 499
             				    $values['owner'] = $line[4];
500 500
             				    if ($line[5] == '') $values['date_first_reg'] = null;
501
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
501
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
502 502
 					    $values['cancel'] = '';
503 503
 					} elseif ($country == '8Q') {
504 504
             				    $values['registration'] = $line[0];
505 505
             				    $values['base'] = null;
506 506
             				    $values['owner'] = $line[3];
507 507
             				    if ($line[7] == '') $values['date_first_reg'] = null;
508
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
508
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
509 509
 					    $values['cancel'] = '';
510 510
 					} elseif ($country == 'ZK') {
511 511
             				    $values['registration'] = $line[0];
@@ -519,18 +519,18 @@  discard block
 block discarded – undo
519 519
             				    $values['registration'] = $line[0];
520 520
             				    $values['base'] = null;
521 521
             				    $values['owner'] = $line[6];
522
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
523
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
522
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
523
+					    $values['cancel'] = date("Y-m-d", strtotime($line[8]));
524 524
 					    $values['modes'] = $line[4];
525 525
 					    $values['icao'] = $line[10];
526 526
 					} elseif ($country == 'OY') {
527 527
             				    $values['registration'] = $line[0];
528
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
528
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[4]));
529 529
 					    $values['modes'] = $line[5];
530 530
 					    $values['icao'] = $line[6];
531 531
 					} elseif ($country == 'PH') {
532 532
             				    $values['registration'] = $line[0];
533
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
533
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[3]));
534 534
 					    $values['modes'] = $line[4];
535 535
 					    $values['icao'] = $line[5];
536 536
 					} elseif ($country == 'OM' || $country == 'TF') {
@@ -541,17 +541,17 @@  discard block
 block discarded – undo
541 541
 					    $values['cancel'] = '';
542 542
 					}
543 543
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
544
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
544
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
545 545
 						$sth_dest->execute($query_dest_values);
546 546
 					}
547 547
 					if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') {
548 548
 						$modescountry = $Spotter->countryFromAircraftRegistration($values['registration']);
549
-						$query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file);
549
+						$query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file);
550 550
 						$sth_modes->execute($query_modes_values);
551 551
 					}
552 552
 				}
553 553
 				if ($globalTransaction) $Connection->db->commit();
554
-			} catch(PDOException $e) {
554
+			} catch (PDOException $e) {
555 555
 				return "error : ".$e->getMessage();
556 556
 			}
557 557
 		}
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 			$Connection = new Connection();
667 667
 			$sth = $Connection->db->prepare($query);
668 668
                         $sth->execute();
669
-                } catch(PDOException $e) {
669
+                } catch (PDOException $e) {
670 670
                         return "error : ".$e->getMessage();
671 671
                 }
672 672
 
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 			$Connection = new Connection();
677 677
 			$sth = $Connection->db->prepare($query);
678 678
                         $sth->execute();
679
-                } catch(PDOException $e) {
679
+                } catch (PDOException $e) {
680 680
                         return "error : ".$e->getMessage();
681 681
                 }
682 682
 
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 		if ($globalTransaction) $Connection->db->beginTransaction();
688 688
   
689 689
 		$i = 0;
690
-		while($row = sparql_fetch_array($result))
690
+		while ($row = sparql_fetch_array($result))
691 691
 		{
692 692
 			if ($i >= 1) {
693 693
 			//print_r($row);
@@ -707,31 +707,31 @@  discard block
 block discarded – undo
707 707
 				$row['image'] = '';
708 708
 				$row['image_thumb'] = '';
709 709
 			} else {
710
-				$image = str_replace(' ','_',$row['image']);
710
+				$image = str_replace(' ', '_', $row['image']);
711 711
 				$digest = md5($image);
712
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
713
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
714
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
715
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
712
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
713
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
714
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
715
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
716 716
 			}
717 717
 			
718
-			$country = explode('-',$row['country']);
718
+			$country = explode('-', $row['country']);
719 719
 			$row['country'] = $country[0];
720 720
 			
721 721
 			$row['type'] = trim($row['type']);
722
-			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) {
722
+			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) {
723 723
 				$row['type'] = 'Military';
724 724
 			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') {
725 725
 				$row['type'] = 'small_airport';
726 726
 			}
727 727
 			
728
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
729
-			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']);
728
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
729
+			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $row['altitude'], ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']);
730 730
 			//print_r($query_dest_values);
731 731
 			
732 732
 			try {
733 733
 				$sth_dest->execute($query_dest_values);
734
-			} catch(PDOException $e) {
734
+			} catch (PDOException $e) {
735 735
 				return "error : ".$e->getMessage();
736 736
 			}
737 737
 			}
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 			$Connection = new Connection();
746 746
 			$sth = $Connection->db->prepare($query);
747 747
                         $sth->execute();
748
-                } catch(PDOException $e) {
748
+                } catch (PDOException $e) {
749 749
                         return "error : ".$e->getMessage();
750 750
                 }
751 751
 
@@ -753,12 +753,12 @@  discard block
 block discarded – undo
753 753
 		if ($globalDebug) echo "Insert Not available Airport...\n";
754 754
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
755 755
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
756
-		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
756
+		$query_values = array(':airport_id' => $i, ':name' => 'Not available', ':iata' => 'NA', ':icao' => 'NA', ':latitude' => '0', ':longitude' => '0', ':altitude' => '0', ':type' => 'NA', ':city' => 'N/A', ':country' => 'N/A', ':home_link' => '', ':wikipedia_link' => '', ':image' => '', ':image_thumb' => '');
757 757
 		try {
758 758
 			$Connection = new Connection();
759 759
 			$sth = $Connection->db->prepare($query);
760 760
                         $sth->execute($query_values);
761
-                } catch(PDOException $e) {
761
+                } catch (PDOException $e) {
762 762
                         return "error : ".$e->getMessage();
763 763
                 }
764 764
 		$i++;
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 		echo "Download data from ourairports.com...\n";
777 777
 		$delimiter = ',';
778 778
 		$out_file = $tmp_dir.'airports.csv';
779
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
779
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
780 780
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
781 781
 		echo "Add data from ourairports.com...\n";
782 782
 
@@ -787,32 +787,32 @@  discard block
 block discarded – undo
787 787
 			//$Connection->db->beginTransaction();
788 788
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
789 789
 			{
790
-				if(!$header) $header = $row;
790
+				if (!$header) $header = $row;
791 791
 				else {
792 792
 					$data = array();
793 793
 					$data = array_combine($header, $row);
794 794
 					try {
795 795
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao');
796 796
 						$sth->execute(array(':icao' => $data['gps_code']));
797
-					} catch(PDOException $e) {
797
+					} catch (PDOException $e) {
798 798
 						return "error : ".$e->getMessage();
799 799
 					}
800 800
 					if ($sth->fetchColumn() > 0) {
801 801
 						$query = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
802 802
 						try {
803 803
 							$sth = $Connection->db->prepare($query);
804
-							$sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type']));
805
-						} catch(PDOException $e) {
804
+							$sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type']));
805
+						} catch (PDOException $e) {
806 806
 							return "error : ".$e->getMessage();
807 807
 						}
808 808
 					} else {
809 809
 						$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`)
810 810
 						    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
811
-						$query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
811
+						$query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
812 812
 						try {
813 813
 							$sth = $Connection->db->prepare($query);
814 814
 							$sth->execute($query_values);
815
-						} catch(PDOException $e) {
815
+						} catch (PDOException $e) {
816 816
 							return "error : ".$e->getMessage();
817 817
 						}
818 818
 						$i++;
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 
826 826
 		echo "Download data from another free database...\n";
827 827
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
828
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
828
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
829 829
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
830 830
 		update_db::unzip($out_file);
831 831
 		$header = NULL;
@@ -837,15 +837,15 @@  discard block
 block discarded – undo
837 837
 			//$Connection->db->beginTransaction();
838 838
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
839 839
 			{
840
-				if(!$header) $header = $row;
840
+				if (!$header) $header = $row;
841 841
 				else {
842 842
 					$data = $row;
843 843
 
844 844
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
845 845
 					try {
846 846
 						$sth = $Connection->db->prepare($query);
847
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
848
-					} catch(PDOException $e) {
847
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
848
+					} catch (PDOException $e) {
849 849
 						return "error : ".$e->getMessage();
850 850
 					}
851 851
 				}
@@ -859,15 +859,15 @@  discard block
 block discarded – undo
859 859
 		try {
860 860
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'");
861 861
 			$sth->execute();
862
-		} catch(PDOException $e) {
862
+		} catch (PDOException $e) {
863 863
 			return "error : ".$e->getMessage();
864 864
 		}
865 865
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
866 866
 			$query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
867 867
 			try {
868 868
 				$sth2 = $Connection->db->prepare($query2);
869
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
870
-			} catch(PDOException $e) {
869
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
870
+			} catch (PDOException $e) {
871 871
 				return "error : ".$e->getMessage();
872 872
 			}
873 873
 		}
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 			$Connection = new Connection();
892 892
 			$sth = $Connection->db->prepare($query);
893 893
                         $sth->execute(array(':source' => 'translation.csv'));
894
-                } catch(PDOException $e) {
894
+                } catch (PDOException $e) {
895 895
                         return "error : ".$e->getMessage();
896 896
                 }
897 897
 
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
909 909
 			{
910 910
 				$i++;
911
-				if($i > 12) {
911
+				if ($i > 12) {
912 912
 					$data = $row;
913 913
 					$operator = $data[2];
914 914
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
                                                 //echo substr($operator, 0, 2)."\n";;
917 917
                                                 if (count($airline_array) > 0) {
918 918
 							//print_r($airline_array);
919
-							$operator = $airline_array[0]['icao'].substr($operator,2);
919
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
920 920
                                                 }
921 921
                                         }
922 922
 					
@@ -924,14 +924,14 @@  discard block
 block discarded – undo
924 924
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
925 925
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
926 926
                                                 if (count($airline_array) > 0) {
927
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
927
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
928 928
                                             	}
929 929
                                         }
930 930
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
931 931
 					try {
932 932
 						$sth = $Connection->db->prepare($query);
933
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
934
-					} catch(PDOException $e) {
933
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
934
+					} catch (PDOException $e) {
935 935
 						return "error : ".$e->getMessage();
936 936
 					}
937 937
 				}
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
 			$Connection = new Connection();
952 952
 			$sth = $Connection->db->prepare($query);
953 953
                         $sth->execute(array(':source' => 'website_fam'));
954
-                } catch(PDOException $e) {
954
+                } catch (PDOException $e) {
955 955
                         return "error : ".$e->getMessage();
956 956
                 }
957 957
 
@@ -971,8 +971,8 @@  discard block
 block discarded – undo
971 971
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
972 972
 					try {
973 973
 						$sth = $Connection->db->prepare($query);
974
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
975
-					} catch(PDOException $e) {
974
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
975
+					} catch (PDOException $e) {
976 976
 						return "error : ".$e->getMessage();
977 977
 					}
978 978
 				}
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 			$Connection = new Connection();
996 996
 			$sth = $Connection->db->prepare($query);
997 997
                         $sth->execute(array(':source' => 'website_faa'));
998
-                } catch(PDOException $e) {
998
+                } catch (PDOException $e) {
999 999
                         return "error : ".$e->getMessage();
1000 1000
                 }
1001 1001
 
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
 			$Connection = new Connection();
1005 1005
 			$sth = $Connection->db->prepare($query);
1006 1006
                         $sth->execute(array(':source' => 'website_faa'));
1007
-                } catch(PDOException $e) {
1007
+                } catch (PDOException $e) {
1008 1008
                         return "error : ".$e->getMessage();
1009 1009
                 }
1010 1010
 
@@ -1021,8 +1021,8 @@  discard block
 block discarded – undo
1021 1021
 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';
1022 1022
 					try {
1023 1023
 						$sths = $Connection->db->prepare($query_search);
1024
-						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa'));
1025
-					} catch(PDOException $e) {
1024
+						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa'));
1025
+					} catch (PDOException $e) {
1026 1026
 						return "error s : ".$e->getMessage();
1027 1027
 					}
1028 1028
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
@@ -1035,8 +1035,8 @@  discard block
 block discarded – undo
1035 1035
 							//}
1036 1036
 						try {
1037 1037
 							$sthi = $Connection->db->prepare($queryi);
1038
-							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode']));
1039
-						} catch(PDOException $e) {
1038
+							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode']));
1039
+						} catch (PDOException $e) {
1040 1040
 							return "error u : ".$e->getMessage();
1041 1041
 						}
1042 1042
 					} else {
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 						try {
1045 1045
 							$sthsm = $Connection->db->prepare($query_search_mfr);
1046 1046
 							$sthsm->execute(array(':mfr' => $data[2]));
1047
-						} catch(PDOException $e) {
1047
+						} catch (PDOException $e) {
1048 1048
 							return "error mfr : ".$e->getMessage();
1049 1049
 						}
1050 1050
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1055 1055
 							try {
1056 1056
 								$sthf = $Connection->db->prepare($queryf);
1057
-								$sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa'));
1058
-							} catch(PDOException $e) {
1057
+								$sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa'));
1058
+							} catch (PDOException $e) {
1059 1059
 								return "error f : ".$e->getMessage();
1060 1060
 							}
1061 1061
 						}
@@ -1065,13 +1065,13 @@  discard block
 block discarded – undo
1065 1065
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1066 1066
 						try {
1067 1067
 							$sth = $Connection->db->prepare($query);
1068
-							$sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa'));
1069
-						} catch(PDOException $e) {
1068
+							$sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa'));
1069
+						} catch (PDOException $e) {
1070 1070
 							return "error i : ".$e->getMessage();
1071 1071
 						}
1072 1072
 					}
1073 1073
 				}
1074
-				if ($i % 90 == 0) {
1074
+				if ($i%90 == 0) {
1075 1075
 					if ($globalTransaction) $Connection->db->commit();
1076 1076
 					if ($globalTransaction) $Connection->db->beginTransaction();
1077 1077
 				}
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 			$Connection = new Connection();
1091 1091
 			$sth = $Connection->db->prepare($query);
1092 1092
                         $sth->execute(array(':source' => 'website_fam'));
1093
-                } catch(PDOException $e) {
1093
+                } catch (PDOException $e) {
1094 1094
                         return "error : ".$e->getMessage();
1095 1095
                 }
1096 1096
 
@@ -1111,8 +1111,8 @@  discard block
 block discarded – undo
1111 1111
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1112 1112
 					try {
1113 1113
 						$sth = $Connection->db->prepare($query);
1114
-						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam'));
1115
-					} catch(PDOException $e) {
1114
+						$sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam'));
1115
+					} catch (PDOException $e) {
1116 1116
 						return "error : ".$e->getMessage();
1117 1117
 					}
1118 1118
 				}
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
 			$Connection = new Connection();
1132 1132
 			$sth = $Connection->db->prepare($query);
1133 1133
                         $sth->execute(array(':source' => 'website_fam'));
1134
-                } catch(PDOException $e) {
1134
+                } catch (PDOException $e) {
1135 1135
                         return "error : ".$e->getMessage();
1136 1136
                 }
1137 1137
 
@@ -1147,8 +1147,8 @@  discard block
 block discarded – undo
1147 1147
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1148 1148
 					try {
1149 1149
 						$sth = $Connection->db->prepare($query);
1150
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1151
-					} catch(PDOException $e) {
1150
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1151
+					} catch (PDOException $e) {
1152 1152
 						print_r($data);
1153 1153
 						return "error : ".$e->getMessage();
1154 1154
 					}
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
 			$Connection = new Connection();
1169 1169
 			$sth = $Connection->db->prepare($query);
1170 1170
                         $sth->execute(array(':source' => 'website_fam'));
1171
-                } catch(PDOException $e) {
1171
+                } catch (PDOException $e) {
1172 1172
                         return "error : ".$e->getMessage();
1173 1173
                 }
1174 1174
 
@@ -1188,8 +1188,8 @@  discard block
 block discarded – undo
1188 1188
 					$query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)';
1189 1189
 					try {
1190 1190
 						$sth = $Connection->db->prepare($query);
1191
-						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1192
-					} catch(PDOException $e) {
1191
+						$sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam'));
1192
+					} catch (PDOException $e) {
1193 1193
 						return "error : ".$e->getMessage();
1194 1194
 					}
1195 1195
 				}
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
 			$Connection = new Connection();
1209 1209
 			$sth = $Connection->db->prepare($query);
1210 1210
 			$sth->execute();
1211
-		} catch(PDOException $e) {
1211
+		} catch (PDOException $e) {
1212 1212
 			return "error : ".$e->getMessage();
1213 1213
 		}
1214 1214
 
@@ -1224,7 +1224,7 @@  discard block
 block discarded – undo
1224 1224
 					try {
1225 1225
 						$sth = $Connection->db->prepare($query);
1226 1226
 						$sth->execute(array(':icao' => $icao));
1227
-					} catch(PDOException $e) {
1227
+					} catch (PDOException $e) {
1228 1228
 						return "error : ".$e->getMessage();
1229 1229
 					}
1230 1230
 				}
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
 		return '';
1236 1236
         }
1237 1237
 
1238
-	public static function tle($filename,$tletype) {
1238
+	public static function tle($filename, $tletype) {
1239 1239
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1240 1240
 		global $tmp_dir, $globalTransaction;
1241 1241
 		//$Spotter = new Spotter();
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
 			$Connection = new Connection();
1246 1246
 			$sth = $Connection->db->prepare($query);
1247 1247
                         $sth->execute(array(':source' => $filename));
1248
-                } catch(PDOException $e) {
1248
+                } catch (PDOException $e) {
1249 1249
                         return "error : ".$e->getMessage();
1250 1250
                 }
1251 1251
 		
@@ -1270,8 +1270,8 @@  discard block
 block discarded – undo
1270 1270
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1271 1271
 					try {
1272 1272
 						$sth = $Connection->db->prepare($query);
1273
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1274
-					} catch(PDOException $e) {
1273
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1274
+					} catch (PDOException $e) {
1275 1275
 						return "error : ".$e->getMessage();
1276 1276
 					}
1277 1277
 
@@ -1291,28 +1291,28 @@  discard block
 block discarded – undo
1291 1291
         */
1292 1292
         private static function table2array($data) {
1293 1293
                 $html = str_get_html($data);
1294
-                $tabledata=array();
1295
-                foreach($html->find('tr') as $element)
1294
+                $tabledata = array();
1295
+                foreach ($html->find('tr') as $element)
1296 1296
                 {
1297 1297
                         $td = array();
1298
-                        foreach( $element->find('th') as $row)
1298
+                        foreach ($element->find('th') as $row)
1299 1299
                         {
1300 1300
                                 $td [] = trim($row->plaintext);
1301 1301
                         }
1302
-                        $td=array_filter($td);
1302
+                        $td = array_filter($td);
1303 1303
                         $tabledata[] = $td;
1304 1304
 
1305 1305
                         $td = array();
1306 1306
                         $tdi = array();
1307
-                        foreach( $element->find('td') as $row)
1307
+                        foreach ($element->find('td') as $row)
1308 1308
                         {
1309 1309
                                 $td [] = trim($row->plaintext);
1310 1310
                                 $tdi [] = trim($row->innertext);
1311 1311
                         }
1312
-                        $td=array_filter($td);
1313
-                        $tdi=array_filter($tdi);
1312
+                        $td = array_filter($td);
1313
+                        $tdi = array_filter($tdi);
1314 1314
                     //    $tabledata[]=array_merge($td,$tdi);
1315
-                        $tabledata[]=$td;
1315
+                        $tabledata[] = $td;
1316 1316
                 }
1317 1317
                 return(array_filter($tabledata));
1318 1318
         }
@@ -1385,13 +1385,13 @@  discard block
 block discarded – undo
1385 1385
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1386 1386
 			{
1387 1387
 				$i++;
1388
-				if($i > 3 && count($row) > 2) {
1388
+				if ($i > 3 && count($row) > 2) {
1389 1389
 					$data = array_values(array_filter($row));
1390 1390
 					$cntdata = count($data);
1391 1391
 					if ($cntdata > 10) {
1392 1392
 						$value = $data[9];
1393 1393
 						
1394
-						for ($i =10;$i < $cntdata;$i++) {
1394
+						for ($i = 10; $i < $cntdata; $i++) {
1395 1395
 							$value .= ' '.$data[$i];
1396 1396
 						}
1397 1397
 						$data[9] = $value;
@@ -1401,8 +1401,8 @@  discard block
 block discarded – undo
1401 1401
 						$query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)';
1402 1402
 						try {
1403 1403
 							$sth = $Connection->db->prepare($query);
1404
-							$sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1405
-						} catch(PDOException $e) {
1404
+							$sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1405
+						} catch (PDOException $e) {
1406 1406
 							return "error : ".$e->getMessage();
1407 1407
 						}
1408 1408
 					}
@@ -1423,7 +1423,7 @@  discard block
 block discarded – undo
1423 1423
 			$Connection = new Connection();
1424 1424
 			$sth = $Connection->db->prepare($query);
1425 1425
                         $sth->execute();
1426
-                } catch(PDOException $e) {
1426
+                } catch (PDOException $e) {
1427 1427
                         return "error : ".$e->getMessage();
1428 1428
                 }
1429 1429
 
@@ -1435,12 +1435,12 @@  discard block
 block discarded – undo
1435 1435
 			if ($globalTransaction) $Connection->db->beginTransaction();
1436 1436
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1437 1437
 			{
1438
-				if(count($row) > 1) {
1438
+				if (count($row) > 1) {
1439 1439
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1440 1440
 					try {
1441 1441
 						$sth = $Connection->db->prepare($query);
1442
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1443
-					} catch(PDOException $e) {
1442
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1443
+					} catch (PDOException $e) {
1444 1444
 						return "error : ".$e->getMessage();
1445 1445
 					}
1446 1446
 				}
@@ -1460,21 +1460,21 @@  discard block
 block discarded – undo
1460 1460
 			try {
1461 1461
 				$sth = $Connection->db->prepare($query);
1462 1462
                     		$sth->execute();
1463
-	                } catch(PDOException $e) {
1463
+	                } catch (PDOException $e) {
1464 1464
 				return "error : ".$e->getMessage();
1465 1465
 	                }
1466 1466
 	        }
1467 1467
 
1468 1468
 
1469
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1469
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1470 1470
 		else {
1471
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1471
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1472 1472
 			$query = "CREATE EXTENSION postgis";
1473
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1473
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1474 1474
 			try {
1475 1475
 				$sth = $Connection->db->prepare($query);
1476 1476
 				$sth->execute();
1477
-			} catch(PDOException $e) {
1477
+			} catch (PDOException $e) {
1478 1478
 				return "error : ".$e->getMessage();
1479 1479
 			}
1480 1480
 		}
@@ -1487,7 +1487,7 @@  discard block
 block discarded – undo
1487 1487
 		include_once('class.create_db.php');
1488 1488
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1489 1489
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1490
-		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1490
+		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1491 1491
 		$error = '';
1492 1492
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1493 1493
 			if ($globalDebug) echo "Gunzip...";
@@ -1519,14 +1519,14 @@  discard block
 block discarded – undo
1519 1519
 			try {
1520 1520
 				$sth = $Connection->db->prepare($query);
1521 1521
             	        	$sth->execute();
1522
-	                } catch(PDOException $e) {
1522
+	                } catch (PDOException $e) {
1523 1523
     	                	echo "error : ".$e->getMessage();
1524 1524
 	                }
1525 1525
 		}
1526 1526
 		if ($globalDBdriver == 'mysql') {
1527
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1527
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1528 1528
 		} else {
1529
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1529
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1530 1530
 		}
1531 1531
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1532 1532
 		return $error;
@@ -1539,7 +1539,7 @@  discard block
 block discarded – undo
1539 1539
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1540 1540
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1541 1541
 //		update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1542
-		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1542
+		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net');
1543 1543
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1544 1544
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1545 1545
 		return $error;
@@ -1559,7 +1559,7 @@  discard block
 block discarded – undo
1559 1559
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1560 1560
 			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1561 1561
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1562
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1562
+				if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1563 1563
 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1564 1564
 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1565 1565
 		if ($error != '') {
@@ -1572,7 +1572,7 @@  discard block
 block discarded – undo
1572 1572
 		global $tmp_dir, $globalDebug;
1573 1573
 		$error = '';
1574 1574
 		if ($globalDebug) echo "Routes : Download...";
1575
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1575
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
1576 1576
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1577 1577
 			if ($globalDebug) echo "Gunzip...";
1578 1578
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -1588,7 +1588,7 @@  discard block
 block discarded – undo
1588 1588
 		global $tmp_dir, $globalDebug;
1589 1589
 		$error = '';
1590 1590
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
1591
-		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1591
+		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
1592 1592
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1593 1593
 			if ($globalDebug) echo "Gunzip...";
1594 1594
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -1604,7 +1604,7 @@  discard block
 block discarded – undo
1604 1604
 		global $tmp_dir, $globalDebug;
1605 1605
 		$error = '';
1606 1606
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
1607
-		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1607
+		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
1608 1608
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1609 1609
 			if ($globalDebug) echo "Gunzip...";
1610 1610
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
 */
1633 1633
 		if ($globalDebug) echo "Modes : Download...";
1634 1634
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1635
-		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1635
+		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
1636 1636
 
1637 1637
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1638 1638
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -1652,7 +1652,7 @@  discard block
 block discarded – undo
1652 1652
 	public static function update_ModeS_faa() {
1653 1653
 		global $tmp_dir, $globalDebug;
1654 1654
 		if ($globalDebug) echo "Modes FAA: Download...";
1655
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1655
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
1656 1656
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1657 1657
 			if ($globalDebug) echo "Unzip...";
1658 1658
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -1668,7 +1668,7 @@  discard block
 block discarded – undo
1668 1668
 	public static function update_ModeS_flarm() {
1669 1669
 		global $tmp_dir, $globalDebug;
1670 1670
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
1671
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1671
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
1672 1672
 		if (file_exists($tmp_dir.'data.fln')) {
1673 1673
 			if ($globalDebug) echo "Add to DB...";
1674 1674
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -1682,7 +1682,7 @@  discard block
 block discarded – undo
1682 1682
 	public static function update_ModeS_ogn() {
1683 1683
 		global $tmp_dir, $globalDebug;
1684 1684
 		if ($globalDebug) echo "Modes OGN: Download...";
1685
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1685
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
1686 1686
 		if (file_exists($tmp_dir.'ogn.csv')) {
1687 1687
 			if ($globalDebug) echo "Add to DB...";
1688 1688
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -1697,201 +1697,201 @@  discard block
 block discarded – undo
1697 1697
 		global $tmp_dir, $globalDebug, $globalMasterSource;
1698 1698
 		
1699 1699
 		if ($globalDebug) echo "Owner France: Download...";
1700
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1700
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
1701 1701
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1702 1702
 			if ($globalDebug) echo "Add to DB...";
1703
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1703
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
1704 1704
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1705 1705
 		if ($error != '') {
1706 1706
 			return $error;
1707 1707
 		} elseif ($globalDebug) echo "Done\n";
1708 1708
 		
1709 1709
 		if ($globalDebug) echo "Owner Ireland: Download...";
1710
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1710
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
1711 1711
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1712 1712
 			if ($globalDebug) echo "Add to DB...";
1713
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1713
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
1714 1714
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1715 1715
 		if ($error != '') {
1716 1716
 			return $error;
1717 1717
 		} elseif ($globalDebug) echo "Done\n";
1718 1718
 		if ($globalDebug) echo "Owner Switzerland: Download...";
1719
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1719
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
1720 1720
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1721 1721
 			if ($globalDebug) echo "Add to DB...";
1722
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1722
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
1723 1723
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1724 1724
 		if ($error != '') {
1725 1725
 			return $error;
1726 1726
 		} elseif ($globalDebug) echo "Done\n";
1727 1727
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
1728
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1728
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
1729 1729
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1730 1730
 			if ($globalDebug) echo "Add to DB...";
1731
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1731
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
1732 1732
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1733 1733
 		if ($error != '') {
1734 1734
 			return $error;
1735 1735
 		} elseif ($globalDebug) echo "Done\n";
1736 1736
 		if ($globalDebug) echo "Owner Australia: Download...";
1737
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1737
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
1738 1738
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1739 1739
 			if ($globalDebug) echo "Add to DB...";
1740
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1740
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
1741 1741
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1742 1742
 		if ($error != '') {
1743 1743
 			return $error;
1744 1744
 		} elseif ($globalDebug) echo "Done\n";
1745 1745
 		if ($globalDebug) echo "Owner Austria: Download...";
1746
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1746
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
1747 1747
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1748 1748
 			if ($globalDebug) echo "Add to DB...";
1749
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1749
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
1750 1750
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1751 1751
 		if ($error != '') {
1752 1752
 			return $error;
1753 1753
 		} elseif ($globalDebug) echo "Done\n";
1754 1754
 		if ($globalDebug) echo "Owner Chile: Download...";
1755
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1755
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
1756 1756
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1757 1757
 			if ($globalDebug) echo "Add to DB...";
1758
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1758
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
1759 1759
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1760 1760
 		if ($error != '') {
1761 1761
 			return $error;
1762 1762
 		} elseif ($globalDebug) echo "Done\n";
1763 1763
 		if ($globalDebug) echo "Owner Colombia: Download...";
1764
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1764
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
1765 1765
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1766 1766
 			if ($globalDebug) echo "Add to DB...";
1767
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1767
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
1768 1768
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1769 1769
 		if ($error != '') {
1770 1770
 			return $error;
1771 1771
 		} elseif ($globalDebug) echo "Done\n";
1772 1772
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1773
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1773
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
1774 1774
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1775 1775
 			if ($globalDebug) echo "Add to DB...";
1776
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1776
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
1777 1777
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1778 1778
 		if ($error != '') {
1779 1779
 			return $error;
1780 1780
 		} elseif ($globalDebug) echo "Done\n";
1781 1781
 		if ($globalDebug) echo "Owner Brazil: Download...";
1782
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1782
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
1783 1783
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1784 1784
 			if ($globalDebug) echo "Add to DB...";
1785
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1785
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
1786 1786
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1787 1787
 		if ($error != '') {
1788 1788
 			return $error;
1789 1789
 		} elseif ($globalDebug) echo "Done\n";
1790 1790
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1791
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1791
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
1792 1792
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1793 1793
 			if ($globalDebug) echo "Add to DB...";
1794
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1794
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
1795 1795
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1796 1796
 		if ($error != '') {
1797 1797
 			return $error;
1798 1798
 		} elseif ($globalDebug) echo "Done\n";
1799 1799
 		if ($globalDebug) echo "Owner Croatia: Download...";
1800
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1800
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
1801 1801
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1802 1802
 			if ($globalDebug) echo "Add to DB...";
1803
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1803
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
1804 1804
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1805 1805
 		if ($error != '') {
1806 1806
 			return $error;
1807 1807
 		} elseif ($globalDebug) echo "Done\n";
1808 1808
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
1809
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1809
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
1810 1810
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1811 1811
 			if ($globalDebug) echo "Add to DB...";
1812
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1812
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
1813 1813
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1814 1814
 		if ($error != '') {
1815 1815
 			return $error;
1816 1816
 		} elseif ($globalDebug) echo "Done\n";
1817 1817
 		if ($globalDebug) echo "Owner Maldives: Download...";
1818
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1818
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
1819 1819
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1820 1820
 			if ($globalDebug) echo "Add to DB...";
1821
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1821
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
1822 1822
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1823 1823
 		if ($error != '') {
1824 1824
 			return $error;
1825 1825
 		} elseif ($globalDebug) echo "Done\n";
1826 1826
 		if ($globalDebug) echo "Owner New Zealand: Download...";
1827
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1827
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
1828 1828
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1829 1829
 			if ($globalDebug) echo "Add to DB...";
1830
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1830
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
1831 1831
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1832 1832
 		if ($error != '') {
1833 1833
 			return $error;
1834 1834
 		} elseif ($globalDebug) echo "Done\n";
1835 1835
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1836
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1836
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
1837 1837
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1838 1838
 			if ($globalDebug) echo "Add to DB...";
1839
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1839
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
1840 1840
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1841 1841
 		if ($error != '') {
1842 1842
 			return $error;
1843 1843
 		} elseif ($globalDebug) echo "Done\n";
1844 1844
 		if ($globalDebug) echo "Owner Slovakia: Download...";
1845
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1845
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
1846 1846
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1847 1847
 			if ($globalDebug) echo "Add to DB...";
1848
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1848
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
1849 1849
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1850 1850
 		if ($error != '') {
1851 1851
 			return $error;
1852 1852
 		} elseif ($globalDebug) echo "Done\n";
1853 1853
 		if ($globalDebug) echo "Owner Ecuador: Download...";
1854
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1854
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
1855 1855
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1856 1856
 			if ($globalDebug) echo "Add to DB...";
1857
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1857
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
1858 1858
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1859 1859
 		if ($error != '') {
1860 1860
 			return $error;
1861 1861
 		} elseif ($globalDebug) echo "Done\n";
1862 1862
 		if ($globalDebug) echo "Owner Iceland: Download...";
1863
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1863
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
1864 1864
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1865 1865
 			if ($globalDebug) echo "Add to DB...";
1866
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1866
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
1867 1867
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1868 1868
 		if ($error != '') {
1869 1869
 			return $error;
1870 1870
 		} elseif ($globalDebug) echo "Done\n";
1871 1871
 		if ($globalDebug) echo "Owner Isle of Man: Download...";
1872
-		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
1872
+		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv');
1873 1873
 		if (file_exists($tmp_dir.'owner_m.csv')) {
1874 1874
 			if ($globalDebug) echo "Add to DB...";
1875
-			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
1875
+			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M');
1876 1876
 		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
1877 1877
 		if ($error != '') {
1878 1878
 			return $error;
1879 1879
 		} elseif ($globalDebug) echo "Done\n";
1880 1880
 		if ($globalMasterSource) {
1881 1881
 			if ($globalDebug) echo "ModeS Netherlands: Download...";
1882
-			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
1882
+			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv');
1883 1883
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
1884 1884
 				if ($globalDebug) echo "Add to DB...";
1885
-				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
1885
+				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH');
1886 1886
 			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
1887 1887
 			if ($error != '') {
1888 1888
 				return $error;
1889 1889
 			} elseif ($globalDebug) echo "Done\n";
1890 1890
 			if ($globalDebug) echo "ModeS Denmark: Download...";
1891
-			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
1891
+			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv');
1892 1892
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
1893 1893
 				if ($globalDebug) echo "Add to DB...";
1894
-				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
1894
+				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY');
1895 1895
 			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
1896 1896
 			if ($error != '') {
1897 1897
 				return $error;
@@ -1904,7 +1904,7 @@  discard block
 block discarded – undo
1904 1904
 		global $tmp_dir, $globalDebug;
1905 1905
 		$error = '';
1906 1906
 		if ($globalDebug) echo "Translation : Download...";
1907
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1907
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
1908 1908
 		if (file_exists($tmp_dir.'translation.zip')) {
1909 1909
 			if ($globalDebug) echo "Unzip...";
1910 1910
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -1920,7 +1920,7 @@  discard block
 block discarded – undo
1920 1920
 	public static function update_translation_fam() {
1921 1921
 		global $tmp_dir, $globalDebug;
1922 1922
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1923
-		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1923
+		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
1924 1924
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1925 1925
 			if ($globalDebug) echo "Gunzip...";
1926 1926
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
@@ -1935,7 +1935,7 @@  discard block
 block discarded – undo
1935 1935
 	public static function update_ModeS_fam() {
1936 1936
 		global $tmp_dir, $globalDebug;
1937 1937
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
1938
-		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1938
+		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
1939 1939
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1940 1940
 			if ($globalDebug) echo "Gunzip...";
1941 1941
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
@@ -1951,9 +1951,9 @@  discard block
 block discarded – undo
1951 1951
 		global $tmp_dir, $globalDebug, $globalOwner;
1952 1952
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
1953 1953
 		if ($globalOwner === TRUE) {
1954
-			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
1954
+			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
1955 1955
 		} else {
1956
-			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
1956
+			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
1957 1957
 		}
1958 1958
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
1959 1959
 			if ($globalDebug) echo "Gunzip...";
@@ -1969,7 +1969,7 @@  discard block
 block discarded – undo
1969 1969
 	public static function update_routes_fam() {
1970 1970
 		global $tmp_dir, $globalDebug;
1971 1971
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
1972
-		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
1972
+		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
1973 1973
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
1974 1974
 			if ($globalDebug) echo "Gunzip...";
1975 1975
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
@@ -1984,7 +1984,7 @@  discard block
 block discarded – undo
1984 1984
 	public static function update_banned_fam() {
1985 1985
 		global $tmp_dir, $globalDebug;
1986 1986
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
1987
-		update_db::download('http://data.flightairmap.fr/data/ban_eu.csv',$tmp_dir.'ban_eu.csv');
1987
+		update_db::download('http://data.flightairmap.fr/data/ban_eu.csv', $tmp_dir.'ban_eu.csv');
1988 1988
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
1989 1989
 			//if ($globalDebug) echo "Gunzip...";
1990 1990
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -2003,18 +2003,18 @@  discard block
 block discarded – undo
2003 2003
 		$error = '';
2004 2004
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2005 2005
 		if ($globalDBdriver == 'mysql') {
2006
-			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2006
+			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2007 2007
 		} else {
2008
-			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2008
+			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2009 2009
 		}
2010 2010
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
2011
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2011
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2012 2012
 			$airspace_md5 = $airspace_md5_file[0];
2013 2013
 			if (!update_db::check_airspace_version($airspace_md5)) {
2014 2014
 				if ($globalDBdriver == 'mysql') {
2015
-					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
2015
+					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
2016 2016
 				} else {
2017
-					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2017
+					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
2018 2018
 				}
2019 2019
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2020 2020
 					if ($globalDebug) echo "Gunzip...";
@@ -2026,7 +2026,7 @@  discard block
 block discarded – undo
2026 2026
 						try {
2027 2027
 							$sth = $Connection->db->prepare($query);
2028 2028
     	    	    					$sth->execute();
2029
-			            		} catch(PDOException $e) {
2029
+			            		} catch (PDOException $e) {
2030 2030
 							return "error : ".$e->getMessage();
2031 2031
 		            			}
2032 2032
 		    			}
@@ -2044,15 +2044,15 @@  discard block
 block discarded – undo
2044 2044
 	public static function update_tle() {
2045 2045
 		global $tmp_dir, $globalDebug;
2046 2046
 		if ($globalDebug) echo "Download TLE : Download...";
2047
-		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2048
-		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2049
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
2047
+		$alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt',
2048
+		'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt',
2049
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt');
2050 2050
 		foreach ($alltle as $filename) {
2051 2051
 			if ($globalDebug) echo "downloading ".$filename.'...';
2052
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2052
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
2053 2053
 			if (file_exists($tmp_dir.$filename)) {
2054 2054
 				if ($globalDebug) echo "Add to DB ".$filename."...";
2055
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2055
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
2056 2056
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2057 2057
 			if ($error != '') {
2058 2058
 				echo $error."\n";
@@ -2065,32 +2065,32 @@  discard block
 block discarded – undo
2065 2065
 		global $tmp_dir, $globalDebug;
2066 2066
 		$error = '';
2067 2067
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2068
-		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2068
+		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2069 2069
 		if (file_exists($tmp_dir.'models.md5sum')) {
2070 2070
 			if ($globalDebug) echo "Check files...\n";
2071 2071
 			$newmodelsdb = array();
2072
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2073
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2072
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2073
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2074 2074
 					$model = trim($row[2]);
2075 2075
 					$newmodelsdb[$model] = trim($row[0]);
2076 2076
 				}
2077 2077
 			}
2078 2078
 			$modelsdb = array();
2079 2079
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2080
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2081
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2080
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2081
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2082 2082
 						$model = trim($row[2]);
2083 2083
 						$modelsdb[$model] = trim($row[0]);
2084 2084
 					}
2085 2085
 				}
2086 2086
 			}
2087
-			$diff = array_diff($newmodelsdb,$modelsdb);
2087
+			$diff = array_diff($newmodelsdb, $modelsdb);
2088 2088
 			foreach ($diff as $key => $value) {
2089 2089
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2090
-				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2090
+				update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2091 2091
 				
2092 2092
 			}
2093
-			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2093
+			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2094 2094
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2095 2095
 		if ($error != '') {
2096 2096
 			return $error;
@@ -2102,32 +2102,32 @@  discard block
 block discarded – undo
2102 2102
 		global $tmp_dir, $globalDebug;
2103 2103
 		$error = '';
2104 2104
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2105
-		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2105
+		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
2106 2106
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2107 2107
 			if ($globalDebug) echo "Check files...\n";
2108 2108
 			$newmodelsdb = array();
2109
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2110
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2109
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
2110
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2111 2111
 					$model = trim($row[2]);
2112 2112
 					$newmodelsdb[$model] = trim($row[0]);
2113 2113
 				}
2114 2114
 			}
2115 2115
 			$modelsdb = array();
2116 2116
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
2117
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
2118
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2117
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
2118
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2119 2119
 						$model = trim($row[2]);
2120 2120
 						$modelsdb[$model] = trim($row[0]);
2121 2121
 					}
2122 2122
 				}
2123 2123
 			}
2124
-			$diff = array_diff($newmodelsdb,$modelsdb);
2124
+			$diff = array_diff($newmodelsdb, $modelsdb);
2125 2125
 			foreach ($diff as $key => $value) {
2126 2126
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2127
-				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2127
+				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2128 2128
 				
2129 2129
 			}
2130
-			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2130
+			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2131 2131
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2132 2132
 		if ($error != '') {
2133 2133
 			return $error;
@@ -2150,8 +2150,8 @@  discard block
 block discarded – undo
2150 2150
 		*/
2151 2151
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2152 2152
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2153
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2154
-		    $result = fread($fh,100000000);
2153
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
2154
+		    $result = fread($fh, 100000000);
2155 2155
 		    //echo $result;
2156 2156
 		    //var_dump(str_get_html($result));
2157 2157
 		    //print_r(self::table2array($result));
@@ -2169,23 +2169,23 @@  discard block
 block discarded – undo
2169 2169
 			$Connection = new Connection();
2170 2170
 			$sth = $Connection->db->prepare($query);
2171 2171
                         $sth->execute();
2172
-                } catch(PDOException $e) {
2172
+                } catch (PDOException $e) {
2173 2173
                         return "error : ".$e->getMessage();
2174 2174
                 }
2175 2175
 
2176 2176
 		$error = '';
2177 2177
 		if ($globalDebug) echo "Notam : Download...";
2178
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2178
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
2179 2179
 		if (file_exists($tmp_dir.'notam.rss')) {
2180
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
2180
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
2181 2181
 			foreach ($notams['channel']['item'] as $notam) {
2182
-				$title = explode(':',$notam['title']);
2182
+				$title = explode(':', $notam['title']);
2183 2183
 				$data['ref'] = trim($title[0]);
2184 2184
 				unset($title[0]);
2185
-				$data['title'] = trim(implode(':',$title));
2186
-				$description = strip_tags($notam['description'],'<pre>');
2187
-				preg_match(':^(.*?)<pre>:',$description,$match);
2188
-				$q = explode('/',$match[1]);
2185
+				$data['title'] = trim(implode(':', $title));
2186
+				$description = strip_tags($notam['description'], '<pre>');
2187
+				preg_match(':^(.*?)<pre>:', $description, $match);
2188
+				$q = explode('/', $match[1]);
2189 2189
 				$data['fir'] = $q[0];
2190 2190
 				$data['code'] = $q[1];
2191 2191
 				$ifrvfr = $q[2];
@@ -2201,30 +2201,30 @@  discard block
 block discarded – undo
2201 2201
 				$data['lower_limit'] = $q[5];
2202 2202
 				$data['upper_limit'] = $q[6];
2203 2203
 				$latlonrad = $q[7];
2204
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2205
-				$latitude = $Common->convertDec($las,'latitude');
2206
-				$longitude = $Common->convertDec($lns,'longitude');
2204
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
2205
+				$latitude = $Common->convertDec($las, 'latitude');
2206
+				$longitude = $Common->convertDec($lns, 'longitude');
2207 2207
 				if ($lac == 'S') $latitude = '-'.$latitude;
2208 2208
 				if ($lnc == 'W') $longitude = '-'.$longitude;
2209 2209
 				$data['center_latitude'] = $latitude;
2210 2210
 				$data['center_longitude'] = $longitude;
2211 2211
 				$data['radius'] = intval($radius);
2212 2212
 				
2213
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
2213
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
2214 2214
 				$data['text'] = $match[1];
2215
-				preg_match(':</pre>(.*?)$:',$description,$match);
2215
+				preg_match(':</pre>(.*?)$:', $description, $match);
2216 2216
 				$fromto = $match[1];
2217
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
2217
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
2218 2218
 				$fromall = trim($match[1]);
2219
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
2219
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
2220 2220
 				$from = trim($match[1]);
2221
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
2222
-				preg_match('#TO:(.*?)$#',$fromto,$match);
2221
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
2222
+				preg_match('#TO:(.*?)$#', $fromto, $match);
2223 2223
 				$toall = trim($match[1]);
2224
-				if (!preg_match(':Permanent:',$toall)) {
2225
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
2224
+				if (!preg_match(':Permanent:', $toall)) {
2225
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
2226 2226
 					$to = trim($match[1]);
2227
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2227
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
2228 2228
 					$data['permanent'] = 0;
2229 2229
 				} else {
2230 2230
 				    $data['date_end'] = NULL;
@@ -2232,7 +2232,7 @@  discard block
 block discarded – undo
2232 2232
 				}
2233 2233
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2234 2234
 				$NOTAM = new NOTAM();
2235
-				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
2235
+				$NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
2236 2236
 				unset($data);
2237 2237
 			} 
2238 2238
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -2255,16 +2255,16 @@  discard block
 block discarded – undo
2255 2255
 				$Connection = new Connection();
2256 2256
 				$sth = $Connection->db->prepare($query);
2257 2257
 				$sth->execute();
2258
-			} catch(PDOException $e) {
2258
+			} catch (PDOException $e) {
2259 2259
 				return "error : ".$e->getMessage();
2260 2260
 			}
2261 2261
 		}
2262 2262
 		$Common = new Common();
2263 2263
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2264
-		$airspace_json = json_decode($airspace_lst,true);
2264
+		$airspace_json = json_decode($airspace_lst, true);
2265 2265
 		foreach ($airspace_json['records'] as $airspace) {
2266 2266
 			if ($globalDebug) echo $airspace['name']."...\n";
2267
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2267
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
2268 2268
 			if (file_exists($tmp_dir.$airspace['name'])) {
2269 2269
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
2270 2270
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -2286,7 +2286,7 @@  discard block
 block discarded – undo
2286 2286
 				$Connection = new Connection();
2287 2287
 				$sth = $Connection->db->prepare($query);
2288 2288
 				$sth->execute(array(':new' => $new, ':old' => $old));
2289
-			} catch(PDOException $e) {
2289
+			} catch (PDOException $e) {
2290 2290
 				return "error : ".$e->getMessage();
2291 2291
 			}
2292 2292
 		}
@@ -2303,7 +2303,7 @@  discard block
 block discarded – undo
2303 2303
 			$Connection = new Connection();
2304 2304
 			$sth = $Connection->db->prepare($query);
2305 2305
                         $sth->execute();
2306
-                } catch(PDOException $e) {
2306
+                } catch (PDOException $e) {
2307 2307
                         return "error : ".$e->getMessage();
2308 2308
                 }
2309 2309
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2318,7 +2318,7 @@  discard block
 block discarded – undo
2318 2318
 			$Connection = new Connection();
2319 2319
 			$sth = $Connection->db->prepare($query);
2320 2320
                         $sth->execute();
2321
-                } catch(PDOException $e) {
2321
+                } catch (PDOException $e) {
2322 2322
                         return "error : ".$e->getMessage();
2323 2323
                 }
2324 2324
 	}
@@ -2329,7 +2329,7 @@  discard block
 block discarded – undo
2329 2329
 			$Connection = new Connection();
2330 2330
 			$sth = $Connection->db->prepare($query);
2331 2331
                         $sth->execute(array(':version' => $version));
2332
-                } catch(PDOException $e) {
2332
+                } catch (PDOException $e) {
2333 2333
                         return "error : ".$e->getMessage();
2334 2334
                 }
2335 2335
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2345,7 +2345,7 @@  discard block
 block discarded – undo
2345 2345
 			$Connection = new Connection();
2346 2346
 			$sth = $Connection->db->prepare($query);
2347 2347
                         $sth->execute(array(':version' => $version));
2348
-                } catch(PDOException $e) {
2348
+                } catch (PDOException $e) {
2349 2349
                         return "error : ".$e->getMessage();
2350 2350
                 }
2351 2351
 	}
@@ -2361,7 +2361,7 @@  discard block
 block discarded – undo
2361 2361
 			$Connection = new Connection();
2362 2362
 			$sth = $Connection->db->prepare($query);
2363 2363
                         $sth->execute();
2364
-                } catch(PDOException $e) {
2364
+                } catch (PDOException $e) {
2365 2365
                         return "error : ".$e->getMessage();
2366 2366
                 }
2367 2367
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2376,7 +2376,7 @@  discard block
 block discarded – undo
2376 2376
 			$Connection = new Connection();
2377 2377
 			$sth = $Connection->db->prepare($query);
2378 2378
                         $sth->execute();
2379
-                } catch(PDOException $e) {
2379
+                } catch (PDOException $e) {
2380 2380
                         return "error : ".$e->getMessage();
2381 2381
                 }
2382 2382
 	}
@@ -2391,7 +2391,7 @@  discard block
 block discarded – undo
2391 2391
 			$Connection = new Connection();
2392 2392
 			$sth = $Connection->db->prepare($query);
2393 2393
                         $sth->execute();
2394
-                } catch(PDOException $e) {
2394
+                } catch (PDOException $e) {
2395 2395
                         return "error : ".$e->getMessage();
2396 2396
                 }
2397 2397
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2406,7 +2406,7 @@  discard block
 block discarded – undo
2406 2406
 			$Connection = new Connection();
2407 2407
 			$sth = $Connection->db->prepare($query);
2408 2408
                         $sth->execute();
2409
-                } catch(PDOException $e) {
2409
+                } catch (PDOException $e) {
2410 2410
                         return "error : ".$e->getMessage();
2411 2411
                 }
2412 2412
 	}
@@ -2422,7 +2422,7 @@  discard block
 block discarded – undo
2422 2422
 			$Connection = new Connection();
2423 2423
 			$sth = $Connection->db->prepare($query);
2424 2424
                         $sth->execute();
2425
-                } catch(PDOException $e) {
2425
+                } catch (PDOException $e) {
2426 2426
                         return "error : ".$e->getMessage();
2427 2427
                 }
2428 2428
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2437,7 +2437,7 @@  discard block
 block discarded – undo
2437 2437
 			$Connection = new Connection();
2438 2438
 			$sth = $Connection->db->prepare($query);
2439 2439
                         $sth->execute();
2440
-                } catch(PDOException $e) {
2440
+                } catch (PDOException $e) {
2441 2441
                         return "error : ".$e->getMessage();
2442 2442
                 }
2443 2443
 	}
@@ -2452,7 +2452,7 @@  discard block
 block discarded – undo
2452 2452
 			$Connection = new Connection();
2453 2453
 			$sth = $Connection->db->prepare($query);
2454 2454
                         $sth->execute();
2455
-                } catch(PDOException $e) {
2455
+                } catch (PDOException $e) {
2456 2456
                         return "error : ".$e->getMessage();
2457 2457
                 }
2458 2458
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2467,7 +2467,7 @@  discard block
 block discarded – undo
2467 2467
 			$Connection = new Connection();
2468 2468
 			$sth = $Connection->db->prepare($query);
2469 2469
                         $sth->execute();
2470
-                } catch(PDOException $e) {
2470
+                } catch (PDOException $e) {
2471 2471
                         return "error : ".$e->getMessage();
2472 2472
                 }
2473 2473
 	}
@@ -2482,7 +2482,7 @@  discard block
 block discarded – undo
2482 2482
 			$Connection = new Connection();
2483 2483
 			$sth = $Connection->db->prepare($query);
2484 2484
                         $sth->execute();
2485
-                } catch(PDOException $e) {
2485
+                } catch (PDOException $e) {
2486 2486
                         return "error : ".$e->getMessage();
2487 2487
                 }
2488 2488
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2497,7 +2497,7 @@  discard block
 block discarded – undo
2497 2497
 			$Connection = new Connection();
2498 2498
 			$sth = $Connection->db->prepare($query);
2499 2499
                         $sth->execute();
2500
-                } catch(PDOException $e) {
2500
+                } catch (PDOException $e) {
2501 2501
                         return "error : ".$e->getMessage();
2502 2502
                 }
2503 2503
 	}
@@ -2512,7 +2512,7 @@  discard block
 block discarded – undo
2512 2512
 			$Connection = new Connection();
2513 2513
 			$sth = $Connection->db->prepare($query);
2514 2514
                         $sth->execute();
2515
-                } catch(PDOException $e) {
2515
+                } catch (PDOException $e) {
2516 2516
                         return "error : ".$e->getMessage();
2517 2517
                 }
2518 2518
 	}
@@ -2527,7 +2527,7 @@  discard block
 block discarded – undo
2527 2527
 			$Connection = new Connection();
2528 2528
 			$sth = $Connection->db->prepare($query);
2529 2529
                         $sth->execute();
2530
-                } catch(PDOException $e) {
2530
+                } catch (PDOException $e) {
2531 2531
                         return "error : ".$e->getMessage();
2532 2532
                 }
2533 2533
 	}
Please login to merge, or discard this patch.
Braces   +888 added lines, -307 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 		curl_setopt($ch, CURLOPT_URL, $url);
17 17
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
18 18
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
19
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
19
+		if ($referer != '') {
20
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
21
+		}
20 22
 		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');
21 23
 		curl_setopt($ch, CURLOPT_FILE, $fp);
22 24
 		curl_exec($ch);
@@ -27,12 +29,16 @@  discard block
 block discarded – undo
27 29
 	public static function gunzip($in_file,$out_file_name = '') {
28 30
 		//echo $in_file.' -> '.$out_file_name."\n";
29 31
 		$buffer_size = 4096; // read 4kb at a time
30
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
32
+		if ($out_file_name == '') {
33
+			$out_file_name = str_replace('.gz', '', $in_file);
34
+		}
31 35
 		if ($in_file != '' && file_exists($in_file)) {
32 36
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
33
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
34
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
35
-			else {
37
+			if (function_exists('gzopen')) {
38
+				$file = gzopen($in_file,'rb');
39
+			} elseif (function_exists('gzopen64')) {
40
+				$file = gzopen64($in_file,'rb');
41
+			} else {
36 42
 				echo 'gzopen not available';
37 43
 				die;
38 44
 			}
@@ -53,8 +59,12 @@  discard block
 block discarded – undo
53 59
 			if ($res === TRUE) {
54 60
 				$zip->extractTo($path);
55 61
 				$zip->close();
56
-			} else return false;
57
-		} else return false;
62
+			} else {
63
+				return false;
64
+			}
65
+		} else {
66
+			return false;
67
+		}
58 68
 	}
59 69
 	
60 70
 	public static function connect_sqlite($database) {
@@ -69,7 +79,9 @@  discard block
 block discarded – undo
69 79
 	public static function retrieve_route_sqlite_to_dest($database_file) {
70 80
 		global $globalDebug, $globalTransaction;
71 81
 		//$query = 'TRUNCATE TABLE routes';
72
-		if ($globalDebug) echo " - Delete previous routes from DB -";
82
+		if ($globalDebug) {
83
+			echo " - Delete previous routes from DB -";
84
+		}
73 85
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
74 86
 		$Connection = new Connection();
75 87
 		try {
@@ -80,7 +92,9 @@  discard block
 block discarded – undo
80 92
                         return "error : ".$e->getMessage();
81 93
                 }
82 94
 
83
-    		if ($globalDebug) echo " - Add routes to DB -";
95
+    		if ($globalDebug) {
96
+    			echo " - Add routes to DB -";
97
+    		}
84 98
     		update_db::connect_sqlite($database_file);
85 99
 		//$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';
86 100
 		$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";
@@ -95,15 +109,21 @@  discard block
 block discarded – undo
95 109
 		$Connection = new Connection();
96 110
 		$sth_dest = $Connection->db->prepare($query_dest);
97 111
 		try {
98
-			if ($globalTransaction) $Connection->db->beginTransaction();
112
+			if ($globalTransaction) {
113
+				$Connection->db->beginTransaction();
114
+			}
99 115
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
100 116
 				//$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);
101 117
 				$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);
102 118
 				$sth_dest->execute($query_dest_values);
103 119
             		}
104
-			if ($globalTransaction) $Connection->db->commit();
120
+			if ($globalTransaction) {
121
+				$Connection->db->commit();
122
+			}
105 123
 		} catch(PDOException $e) {
106
-			if ($globalTransaction) $Connection->db->rollBack(); 
124
+			if ($globalTransaction) {
125
+				$Connection->db->rollBack();
126
+			}
107 127
 			return "error : ".$e->getMessage();
108 128
 		}
109 129
                 return '';
@@ -111,7 +131,9 @@  discard block
 block discarded – undo
111 131
 	public static function retrieve_route_oneworld($database_file) {
112 132
 		global $globalDebug, $globalTransaction;
113 133
 		//$query = 'TRUNCATE TABLE routes';
114
-		if ($globalDebug) echo " - Delete previous routes from DB -";
134
+		if ($globalDebug) {
135
+			echo " - Delete previous routes from DB -";
136
+		}
115 137
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
116 138
 		$Connection = new Connection();
117 139
 		try {
@@ -122,14 +144,18 @@  discard block
 block discarded – undo
122 144
                         return "error : ".$e->getMessage();
123 145
                 }
124 146
 
125
-    		if ($globalDebug) echo " - Add routes to DB -";
147
+    		if ($globalDebug) {
148
+    			echo " - Add routes to DB -";
149
+    		}
126 150
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
127 151
 		$Spotter = new Spotter();
128 152
 		if ($fh = fopen($database_file,"r")) {
129 153
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
130 154
 			$Connection = new Connection();
131 155
 			$sth_dest = $Connection->db->prepare($query_dest);
132
-			if ($globalTransaction) $Connection->db->beginTransaction();
156
+			if ($globalTransaction) {
157
+				$Connection->db->beginTransaction();
158
+			}
133 159
 			while (!feof($fh)) {
134 160
 				$line = fgetcsv($fh,9999,',');
135 161
 				if ($line[0] != '') {
@@ -138,13 +164,17 @@  discard block
 block discarded – undo
138 164
 							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
139 165
 							$sth_dest->execute($query_dest_values);
140 166
 						} catch(PDOException $e) {
141
-							if ($globalTransaction) $Connection->db->rollBack(); 
167
+							if ($globalTransaction) {
168
+								$Connection->db->rollBack();
169
+							}
142 170
 							return "error : ".$e->getMessage();
143 171
 						}
144 172
 					}
145 173
 				}
146 174
 			}
147
-			if ($globalTransaction) $Connection->db->commit();
175
+			if ($globalTransaction) {
176
+				$Connection->db->commit();
177
+			}
148 178
 		}
149 179
                 return '';
150 180
 	}
@@ -152,7 +182,9 @@  discard block
 block discarded – undo
152 182
 	public static function retrieve_route_skyteam($database_file) {
153 183
 		global $globalDebug, $globalTransaction;
154 184
 		//$query = 'TRUNCATE TABLE routes';
155
-		if ($globalDebug) echo " - Delete previous routes from DB -";
185
+		if ($globalDebug) {
186
+			echo " - Delete previous routes from DB -";
187
+		}
156 188
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
157 189
 		$Connection = new Connection();
158 190
 		try {
@@ -163,7 +195,9 @@  discard block
 block discarded – undo
163 195
                         return "error : ".$e->getMessage();
164 196
                 }
165 197
 
166
-    		if ($globalDebug) echo " - Add routes to DB -";
198
+    		if ($globalDebug) {
199
+    			echo " - Add routes to DB -";
200
+    		}
167 201
 
168 202
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
169 203
 		$Spotter = new Spotter();
@@ -172,7 +206,9 @@  discard block
 block discarded – undo
172 206
 			$Connection = new Connection();
173 207
 			$sth_dest = $Connection->db->prepare($query_dest);
174 208
 			try {
175
-				if ($globalTransaction) $Connection->db->beginTransaction();
209
+				if ($globalTransaction) {
210
+					$Connection->db->beginTransaction();
211
+				}
176 212
 				while (!feof($fh)) {
177 213
 					$line = fgetcsv($fh,9999,',');
178 214
 					if ($line[0] != '') {
@@ -183,9 +219,13 @@  discard block
 block discarded – undo
183 219
 						}
184 220
 					}
185 221
 				}
186
-				if ($globalTransaction) $Connection->db->commit();
222
+				if ($globalTransaction) {
223
+					$Connection->db->commit();
224
+				}
187 225
 			} catch(PDOException $e) {
188
-				if ($globalTransaction) $Connection->db->rollBack(); 
226
+				if ($globalTransaction) {
227
+					$Connection->db->rollBack();
228
+				}
189 229
 				return "error : ".$e->getMessage();
190 230
 			}
191 231
 		}
@@ -228,11 +268,16 @@  discard block
 block discarded – undo
228 268
 		$sth_dest = $Connection->db->prepare($query_dest);
229 269
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
230 270
 		try {
231
-			if ($globalTransaction) $Connection->db->beginTransaction();
271
+			if ($globalTransaction) {
272
+				$Connection->db->beginTransaction();
273
+			}
232 274
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
233 275
 			//$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']);
234
-				if ($values['UserString4'] == 'M') $type = 'military';
235
-				else $type = null;
276
+				if ($values['UserString4'] == 'M') {
277
+					$type = 'military';
278
+				} else {
279
+					$type = null;
280
+				}
236 281
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237 282
 				$sth_dest->execute($query_dest_values);
238 283
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -240,7 +285,9 @@  discard block
 block discarded – undo
240 285
 				    $sth_dest_owner->execute($query_dest_owner_values);
241 286
 				}
242 287
             		}
243
-			if ($globalTransaction) $Connection->db->commit();
288
+			if ($globalTransaction) {
289
+				$Connection->db->commit();
290
+			}
244 291
 		} catch(PDOException $e) {
245 292
 			return "error : ".$e->getMessage();
246 293
 		}
@@ -277,7 +324,9 @@  discard block
 block discarded – undo
277 324
 			$Connection = new Connection();
278 325
 			$sth_dest = $Connection->db->prepare($query_dest);
279 326
 			try {
280
-				if ($globalTransaction) $Connection->db->beginTransaction();
327
+				if ($globalTransaction) {
328
+					$Connection->db->beginTransaction();
329
+				}
281 330
             			while (!feof($fh)) {
282 331
             				$values = array();
283 332
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -288,7 +337,9 @@  discard block
 block discarded – undo
288 337
             				// Check if we can find ICAO, else set it to GLID
289 338
             				$aircraft_name_split = explode(' ',$aircraft_name);
290 339
             				$search_more = '';
291
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
340
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
341
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
342
+            				}
292 343
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
293 344
             				$sth_search = $Connection->db->prepare($query_search);
294 345
 					try {
@@ -301,7 +352,9 @@  discard block
 block discarded – undo
301 352
 					} catch(PDOException $e) {
302 353
 						return "error : ".$e->getMessage();
303 354
 					}
304
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
355
+					if (!isset($values['ICAOTypeCode'])) {
356
+						$values['ICAOTypeCode'] = 'GLID';
357
+					}
305 358
 					// Add data to db
306 359
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
307 360
 						//$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']);
@@ -310,7 +363,9 @@  discard block
 block discarded – undo
310 363
 						$sth_dest->execute($query_dest_values);
311 364
 					}
312 365
 				}
313
-				if ($globalTransaction) $Connection->db->commit();
366
+				if ($globalTransaction) {
367
+					$Connection->db->commit();
368
+				}
314 369
 			} catch(PDOException $e) {
315 370
 				return "error : ".$e->getMessage();
316 371
 			}
@@ -346,7 +401,9 @@  discard block
 block discarded – undo
346 401
 			$Connection = new Connection();
347 402
 			$sth_dest = $Connection->db->prepare($query_dest);
348 403
 			try {
349
-				if ($globalTransaction) $Connection->db->beginTransaction();
404
+				if ($globalTransaction) {
405
+					$Connection->db->beginTransaction();
406
+				}
350 407
 				$tmp = fgetcsv($fh,9999,',',"'");
351 408
             			while (!feof($fh)) {
352 409
             				$line = fgetcsv($fh,9999,',',"'");
@@ -359,13 +416,17 @@  discard block
 block discarded – undo
359 416
             				// Check if we can find ICAO, else set it to GLID
360 417
             				$aircraft_name_split = explode(' ',$aircraft_name);
361 418
             				$search_more = '';
362
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
419
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
420
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
421
+            				}
363 422
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
364 423
             				$sth_search = $Connection->db->prepare($query_search);
365 424
 					try {
366 425
                                     		$sth_search->execute();
367 426
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
368
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
427
+	            				if (isset($result['icao']) && $result['icao'] != '') {
428
+	            					$values['ICAOTypeCode'] = $result['icao'];
429
+	            				}
369 430
 					} catch(PDOException $e) {
370 431
 						return "error : ".$e->getMessage();
371 432
 					}
@@ -378,7 +439,9 @@  discard block
 block discarded – undo
378 439
 						$sth_dest->execute($query_dest_values);
379 440
 					}
380 441
 				}
381
-				if ($globalTransaction) $Connection->db->commit();
442
+				if ($globalTransaction) {
443
+					$Connection->db->commit();
444
+				}
382 445
 			} catch(PDOException $e) {
383 446
 				return "error : ".$e->getMessage();
384 447
 			}
@@ -417,7 +480,9 @@  discard block
 block discarded – undo
417 480
 			$sth_dest = $Connection->db->prepare($query_dest);
418 481
 			$sth_modes = $Connection->db->prepare($query_modes);
419 482
 			try {
420
-				if ($globalTransaction) $Connection->db->beginTransaction();
483
+				if ($globalTransaction) {
484
+					$Connection->db->beginTransaction();
485
+				}
421 486
 				$tmp = fgetcsv($fh,9999,',','"');
422 487
             			while (!feof($fh)) {
423 488
             				$line = fgetcsv($fh,9999,',','"');
@@ -427,16 +492,22 @@  discard block
 block discarded – undo
427 492
             				    $values['registration'] = $line[0];
428 493
             				    $values['base'] = $line[4];
429 494
             				    $values['owner'] = $line[5];
430
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
431
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
495
+            				    if ($line[6] == '') {
496
+            				    	$values['date_first_reg'] = null;
497
+            				    } else {
498
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
499
+					    }
432 500
 					    $values['cancel'] = $line[7];
433 501
 					} elseif ($country == 'EI') {
434 502
 					    // TODO : add modeS & reg to aircraft_modes
435 503
             				    $values['registration'] = $line[0];
436 504
             				    $values['base'] = $line[3];
437 505
             				    $values['owner'] = $line[2];
438
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
439
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
506
+            				    if ($line[1] == '') {
507
+            				    	$values['date_first_reg'] = null;
508
+            				    } else {
509
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
510
+					    }
440 511
 					    $values['cancel'] = '';
441 512
 					    $values['modes'] = $line[7];
442 513
 					    $values['icao'] = $line[8];
@@ -455,16 +526,22 @@  discard block
 block discarded – undo
455 526
             				    $values['registration'] = $line[3];
456 527
             				    $values['base'] = null;
457 528
             				    $values['owner'] = $line[5];
458
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
459
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
529
+            				    if ($line[18] == '') {
530
+            				    	$values['date_first_reg'] = null;
531
+            				    } else {
532
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
533
+					    }
460 534
 					    $values['cancel'] = '';
461 535
 					} elseif ($country == 'VH') {
462 536
 					    // TODO : add modeS & reg to aircraft_modes
463 537
             				    $values['registration'] = $line[0];
464 538
             				    $values['base'] = null;
465 539
             				    $values['owner'] = $line[12];
466
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
467
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
540
+            				    if ($line[28] == '') {
541
+            				    	$values['date_first_reg'] = null;
542
+            				    } else {
543
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
544
+					    }
468 545
 
469 546
 					    $values['cancel'] = $line[39];
470 547
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -483,29 +560,41 @@  discard block
 block discarded – undo
483 560
             				    $values['registration'] = $line[0];
484 561
             				    $values['base'] = null;
485 562
             				    $values['owner'] = $line[8];
486
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
487
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
563
+            				    if ($line[7] == '') {
564
+            				    	$values['date_first_reg'] = null;
565
+            				    } else {
566
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
567
+					    }
488 568
 					    $values['cancel'] = '';
489 569
 					} elseif ($country == 'PP') {
490 570
             				    $values['registration'] = $line[0];
491 571
             				    $values['base'] = null;
492 572
             				    $values['owner'] = $line[4];
493
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
494
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
573
+            				    if ($line[6] == '') {
574
+            				    	$values['date_first_reg'] = null;
575
+            				    } else {
576
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
577
+					    }
495 578
 					    $values['cancel'] = $line[7];
496 579
 					} elseif ($country == 'E7') {
497 580
             				    $values['registration'] = $line[0];
498 581
             				    $values['base'] = null;
499 582
             				    $values['owner'] = $line[4];
500
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
501
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
583
+            				    if ($line[5] == '') {
584
+            				    	$values['date_first_reg'] = null;
585
+            				    } else {
586
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
587
+					    }
502 588
 					    $values['cancel'] = '';
503 589
 					} elseif ($country == '8Q') {
504 590
             				    $values['registration'] = $line[0];
505 591
             				    $values['base'] = null;
506 592
             				    $values['owner'] = $line[3];
507
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
508
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
593
+            				    if ($line[7] == '') {
594
+            				    	$values['date_first_reg'] = null;
595
+            				    } else {
596
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
597
+					    }
509 598
 					    $values['cancel'] = '';
510 599
 					} elseif ($country == 'ZK') {
511 600
             				    $values['registration'] = $line[0];
@@ -550,7 +639,9 @@  discard block
 block discarded – undo
550 639
 						$sth_modes->execute($query_modes_values);
551 640
 					}
552 641
 				}
553
-				if ($globalTransaction) $Connection->db->commit();
642
+				if ($globalTransaction) {
643
+					$Connection->db->commit();
644
+				}
554 645
 			} catch(PDOException $e) {
555 646
 				return "error : ".$e->getMessage();
556 647
 			}
@@ -684,25 +775,45 @@  discard block
 block discarded – undo
684 775
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
685 776
 		$Connection = new Connection();
686 777
 		$sth_dest = $Connection->db->prepare($query_dest);
687
-		if ($globalTransaction) $Connection->db->beginTransaction();
778
+		if ($globalTransaction) {
779
+			$Connection->db->beginTransaction();
780
+		}
688 781
   
689 782
 		$i = 0;
690 783
 		while($row = sparql_fetch_array($result))
691 784
 		{
692 785
 			if ($i >= 1) {
693 786
 			//print_r($row);
694
-			if (!isset($row['iata'])) $row['iata'] = '';
695
-			if (!isset($row['icao'])) $row['icao'] = '';
696
-			if (!isset($row['type'])) $row['type'] = '';
697
-			if (!isset($row['altitude'])) $row['altitude'] = '';
787
+			if (!isset($row['iata'])) {
788
+				$row['iata'] = '';
789
+			}
790
+			if (!isset($row['icao'])) {
791
+				$row['icao'] = '';
792
+			}
793
+			if (!isset($row['type'])) {
794
+				$row['type'] = '';
795
+			}
796
+			if (!isset($row['altitude'])) {
797
+				$row['altitude'] = '';
798
+			}
698 799
 			if (isset($row['city_bis'])) {
699 800
 				$row['city'] = $row['city_bis'];
700 801
 			}
701
-			if (!isset($row['city'])) $row['city'] = '';
702
-			if (!isset($row['country'])) $row['country'] = '';
703
-			if (!isset($row['homepage'])) $row['homepage'] = '';
704
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
705
-			if (!isset($row['name'])) continue;
802
+			if (!isset($row['city'])) {
803
+				$row['city'] = '';
804
+			}
805
+			if (!isset($row['country'])) {
806
+				$row['country'] = '';
807
+			}
808
+			if (!isset($row['homepage'])) {
809
+				$row['homepage'] = '';
810
+			}
811
+			if (!isset($row['wikipedia_page'])) {
812
+				$row['wikipedia_page'] = '';
813
+			}
814
+			if (!isset($row['name'])) {
815
+				continue;
816
+			}
706 817
 			if (!isset($row['image'])) {
707 818
 				$row['image'] = '';
708 819
 				$row['image_thumb'] = '';
@@ -738,7 +849,9 @@  discard block
 block discarded – undo
738 849
 
739 850
 			$i++;
740 851
 		}
741
-		if ($globalTransaction) $Connection->db->commit();
852
+		if ($globalTransaction) {
853
+			$Connection->db->commit();
854
+		}
742 855
 		echo "Delete duplicate rows...\n";
743 856
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
744 857
 		try {
@@ -750,7 +863,9 @@  discard block
 block discarded – undo
750 863
                 }
751 864
 
752 865
 
753
-		if ($globalDebug) echo "Insert Not available Airport...\n";
866
+		if ($globalDebug) {
867
+			echo "Insert Not available Airport...\n";
868
+		}
754 869
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
755 870
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
756 871
 		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
@@ -777,7 +892,9 @@  discard block
 block discarded – undo
777 892
 		$delimiter = ',';
778 893
 		$out_file = $tmp_dir.'airports.csv';
779 894
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
780
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
895
+		if (!file_exists($out_file) || !is_readable($out_file)) {
896
+			return FALSE;
897
+		}
781 898
 		echo "Add data from ourairports.com...\n";
782 899
 
783 900
 		$header = NULL;
@@ -787,8 +904,9 @@  discard block
 block discarded – undo
787 904
 			//$Connection->db->beginTransaction();
788 905
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
789 906
 			{
790
-				if(!$header) $header = $row;
791
-				else {
907
+				if(!$header) {
908
+					$header = $row;
909
+				} else {
792 910
 					$data = array();
793 911
 					$data = array_combine($header, $row);
794 912
 					try {
@@ -826,7 +944,9 @@  discard block
 block discarded – undo
826 944
 		echo "Download data from another free database...\n";
827 945
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
828 946
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
829
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
947
+		if (!file_exists($out_file) || !is_readable($out_file)) {
948
+			return FALSE;
949
+		}
830 950
 		update_db::unzip($out_file);
831 951
 		$header = NULL;
832 952
 		echo "Add data from another free database...\n";
@@ -837,8 +957,9 @@  discard block
 block discarded – undo
837 957
 			//$Connection->db->beginTransaction();
838 958
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
839 959
 			{
840
-				if(!$header) $header = $row;
841
-				else {
960
+				if(!$header) {
961
+					$header = $row;
962
+				} else {
842 963
 					$data = $row;
843 964
 
844 965
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
@@ -1014,7 +1135,9 @@  discard block
 block discarded – undo
1014 1135
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1015 1136
 		{
1016 1137
 			$i = 0;
1017
-			if ($globalTransaction) $Connection->db->beginTransaction();
1138
+			if ($globalTransaction) {
1139
+				$Connection->db->beginTransaction();
1140
+			}
1018 1141
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1019 1142
 			{
1020 1143
 				if ($i > 0) {
@@ -1027,7 +1150,9 @@  discard block
 block discarded – undo
1027 1150
 					}
1028 1151
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1029 1152
 					if (!empty($result_search)) {
1030
-						if ($globalDebug) echo '.';
1153
+						if ($globalDebug) {
1154
+							echo '.';
1155
+						}
1031 1156
 							//if ($globalDBdriver == 'mysql') {
1032 1157
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1033 1158
 							//} else {
@@ -1049,8 +1174,12 @@  discard block
 block discarded – undo
1049 1174
 						}
1050 1175
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1051 1176
 						if (!empty($result_search_mfr)) {
1052
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1053
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1177
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1178
+								$data[16] = $data[23];
1179
+							}
1180
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1181
+								$data[16] = $data[15];
1182
+							}
1054 1183
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1055 1184
 							try {
1056 1185
 								$sthf = $Connection->db->prepare($queryf);
@@ -1061,7 +1190,9 @@  discard block
 block discarded – undo
1061 1190
 						}
1062 1191
 					}
1063 1192
 					if (strtotime($data[29]) > time()) {
1064
-						if ($globalDebug) echo 'i';
1193
+						if ($globalDebug) {
1194
+							echo 'i';
1195
+						}
1065 1196
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1066 1197
 						try {
1067 1198
 							$sth = $Connection->db->prepare($query);
@@ -1072,13 +1203,19 @@  discard block
 block discarded – undo
1072 1203
 					}
1073 1204
 				}
1074 1205
 				if ($i % 90 == 0) {
1075
-					if ($globalTransaction) $Connection->db->commit();
1076
-					if ($globalTransaction) $Connection->db->beginTransaction();
1206
+					if ($globalTransaction) {
1207
+						$Connection->db->commit();
1208
+					}
1209
+					if ($globalTransaction) {
1210
+						$Connection->db->beginTransaction();
1211
+					}
1077 1212
 				}
1078 1213
 				$i++;
1079 1214
 			}
1080 1215
 			fclose($handle);
1081
-			if ($globalTransaction) $Connection->db->commit();
1216
+			if ($globalTransaction) {
1217
+				$Connection->db->commit();
1218
+			}
1082 1219
 		}
1083 1220
 		print_r($mfr);
1084 1221
 		return '';
@@ -1103,11 +1240,15 @@  discard block
 block discarded – undo
1103 1240
 			$i = 0;
1104 1241
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1105 1242
 			//$Connection->db->beginTransaction();
1106
-			if ($globalTransaction) $Connection->db->beginTransaction();
1243
+			if ($globalTransaction) {
1244
+				$Connection->db->beginTransaction();
1245
+			}
1107 1246
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1108 1247
 			{
1109 1248
 				if ($i > 0) {
1110
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1249
+					if ($data[1] == 'NULL') {
1250
+						$data[1] = $data[0];
1251
+					}
1111 1252
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1112 1253
 					try {
1113 1254
 						$sth = $Connection->db->prepare($query);
@@ -1119,7 +1260,9 @@  discard block
 block discarded – undo
1119 1260
 				$i++;
1120 1261
 			}
1121 1262
 			fclose($handle);
1122
-			if ($globalTransaction) $Connection->db->commit();
1263
+			if ($globalTransaction) {
1264
+				$Connection->db->commit();
1265
+			}
1123 1266
 		}
1124 1267
 		return '';
1125 1268
         }
@@ -1140,7 +1283,9 @@  discard block
 block discarded – undo
1140 1283
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1141 1284
 		{
1142 1285
 			$i = 0;
1143
-			if ($globalTransaction) $Connection->db->beginTransaction();
1286
+			if ($globalTransaction) {
1287
+				$Connection->db->beginTransaction();
1288
+			}
1144 1289
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1145 1290
 			{
1146 1291
 				if ($i > 0) {
@@ -1156,7 +1301,9 @@  discard block
 block discarded – undo
1156 1301
 				$i++;
1157 1302
 			}
1158 1303
 			fclose($handle);
1159
-			if ($globalTransaction) $Connection->db->commit();
1304
+			if ($globalTransaction) {
1305
+				$Connection->db->commit();
1306
+			}
1160 1307
 		}
1161 1308
 		return '';
1162 1309
         }
@@ -1181,7 +1328,9 @@  discard block
 block discarded – undo
1181 1328
 			$i = 0;
1182 1329
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1183 1330
 			//$Connection->db->beginTransaction();
1184
-			if ($globalTransaction) $Connection->db->beginTransaction();
1331
+			if ($globalTransaction) {
1332
+				$Connection->db->beginTransaction();
1333
+			}
1185 1334
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1186 1335
 			{
1187 1336
 				if ($i > 0) {
@@ -1196,7 +1345,9 @@  discard block
 block discarded – undo
1196 1345
 				$i++;
1197 1346
 			}
1198 1347
 			fclose($handle);
1199
-			if ($globalTransaction) $Connection->db->commit();
1348
+			if ($globalTransaction) {
1349
+				$Connection->db->commit();
1350
+			}
1200 1351
 		}
1201 1352
 		return '';
1202 1353
         }
@@ -1215,7 +1366,9 @@  discard block
 block discarded – undo
1215 1366
 		$Connection = new Connection();
1216 1367
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1217 1368
 		{
1218
-			if ($globalTransaction) $Connection->db->beginTransaction();
1369
+			if ($globalTransaction) {
1370
+				$Connection->db->beginTransaction();
1371
+			}
1219 1372
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1220 1373
 			{
1221 1374
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1230,7 +1383,9 @@  discard block
 block discarded – undo
1230 1383
 				}
1231 1384
 			}
1232 1385
 			fclose($handle);
1233
-			if ($globalTransaction) $Connection->db->commit();
1386
+			if ($globalTransaction) {
1387
+				$Connection->db->commit();
1388
+			}
1234 1389
 		}
1235 1390
 		return '';
1236 1391
         }
@@ -1381,7 +1536,9 @@  discard block
 block discarded – undo
1381 1536
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1382 1537
 		{
1383 1538
 			$i = 0;
1384
-			if ($globalTransaction) $Connection->db->beginTransaction();
1539
+			if ($globalTransaction) {
1540
+				$Connection->db->beginTransaction();
1541
+			}
1385 1542
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1386 1543
 			{
1387 1544
 				$i++;
@@ -1409,7 +1566,9 @@  discard block
 block discarded – undo
1409 1566
 				}
1410 1567
 			}
1411 1568
 			fclose($handle);
1412
-			if ($globalTransaction) $Connection->db->commit();
1569
+			if ($globalTransaction) {
1570
+				$Connection->db->commit();
1571
+			}
1413 1572
 		}
1414 1573
 		return '';
1415 1574
         }
@@ -1432,7 +1591,9 @@  discard block
 block discarded – undo
1432 1591
 		$Connection = new Connection();
1433 1592
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1434 1593
 		{
1435
-			if ($globalTransaction) $Connection->db->beginTransaction();
1594
+			if ($globalTransaction) {
1595
+				$Connection->db->beginTransaction();
1596
+			}
1436 1597
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1437 1598
 			{
1438 1599
 				if(count($row) > 1) {
@@ -1446,7 +1607,9 @@  discard block
 block discarded – undo
1446 1607
 				}
1447 1608
 			}
1448 1609
 			fclose($handle);
1449
-			if ($globalTransaction) $Connection->db->commit();
1610
+			if ($globalTransaction) {
1611
+				$Connection->db->commit();
1612
+			}
1450 1613
 		}
1451 1614
 		return '';
1452 1615
         }
@@ -1466,8 +1629,9 @@  discard block
 block discarded – undo
1466 1629
 	        }
1467 1630
 
1468 1631
 
1469
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1470
-		else {
1632
+		if ($globalDBdriver == 'mysql') {
1633
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1634
+		} else {
1471 1635
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1472 1636
 			$query = "CREATE EXTENSION postgis";
1473 1637
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -1486,20 +1650,30 @@  discard block
 block discarded – undo
1486 1650
 		global $tmp_dir, $globalDebug;
1487 1651
 		include_once('class.create_db.php');
1488 1652
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1489
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1653
+		if ($globalDebug) {
1654
+			echo "NOTAM from FlightAirMap website : Download...";
1655
+		}
1490 1656
 		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1491 1657
 		$error = '';
1492 1658
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1493
-			if ($globalDebug) echo "Gunzip...";
1659
+			if ($globalDebug) {
1660
+				echo "Gunzip...";
1661
+			}
1494 1662
 			update_db::gunzip($tmp_dir.'notam.txt.gz');
1495
-			if ($globalDebug) echo "Add to DB...";
1663
+			if ($globalDebug) {
1664
+				echo "Add to DB...";
1665
+			}
1496 1666
 			//$error = create_db::import_file($tmp_dir.'notam.sql');
1497 1667
 			$NOTAM = new NOTAM();
1498 1668
 			$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
1499
-		} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1669
+		} else {
1670
+			$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
1671
+		}
1500 1672
 		if ($error != '') {
1501 1673
 			return $error;
1502
-		} elseif ($globalDebug) echo "Done\n";
1674
+		} elseif ($globalDebug) {
1675
+			echo "Done\n";
1676
+		}
1503 1677
 		return '';
1504 1678
 	}
1505 1679
 
@@ -1553,67 +1727,111 @@  discard block
 block discarded – undo
1553 1727
 		//if ($globalDebug) echo "IVAO : Download...";
1554 1728
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
1555 1729
 		if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
1556
-			if ($globalDebug) echo "Unzip...";
1730
+			if ($globalDebug) {
1731
+				echo "Unzip...";
1732
+			}
1557 1733
 			update_db::unzip($tmp_dir.'ivae_feb2013.zip');
1558
-			if ($globalDebug) echo "Add to DB...";
1734
+			if ($globalDebug) {
1735
+				echo "Add to DB...";
1736
+			}
1559 1737
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1560
-			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1738
+			if ($globalDebug) {
1739
+				echo "Copy airlines logos to airlines images directory...";
1740
+			}
1561 1741
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1562
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1563
-			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1564
-		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1742
+				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
1743
+					$error = "Failed to copy airlines logo.";
1744
+				}
1745
+			} else {
1746
+				$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1747
+			}
1748
+		} else {
1749
+			$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1750
+		}
1565 1751
 		if ($error != '') {
1566 1752
 			return $error;
1567
-		} elseif ($globalDebug) echo "Done\n";
1753
+		} elseif ($globalDebug) {
1754
+			echo "Done\n";
1755
+		}
1568 1756
 		return '';
1569 1757
 	}
1570 1758
 
1571 1759
 	public static function update_routes() {
1572 1760
 		global $tmp_dir, $globalDebug;
1573 1761
 		$error = '';
1574
-		if ($globalDebug) echo "Routes : Download...";
1762
+		if ($globalDebug) {
1763
+			echo "Routes : Download...";
1764
+		}
1575 1765
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1576 1766
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1577
-			if ($globalDebug) echo "Gunzip...";
1767
+			if ($globalDebug) {
1768
+				echo "Gunzip...";
1769
+			}
1578 1770
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1579
-			if ($globalDebug) echo "Add to DB...";
1771
+			if ($globalDebug) {
1772
+				echo "Add to DB...";
1773
+			}
1580 1774
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1581
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1775
+		} else {
1776
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1777
+		}
1582 1778
 		if ($error != '') {
1583 1779
 			return $error;
1584
-		} elseif ($globalDebug) echo "Done\n";
1780
+		} elseif ($globalDebug) {
1781
+			echo "Done\n";
1782
+		}
1585 1783
 		return '';
1586 1784
 	}
1587 1785
 	public static function update_oneworld() {
1588 1786
 		global $tmp_dir, $globalDebug;
1589 1787
 		$error = '';
1590
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
1788
+		if ($globalDebug) {
1789
+			echo "Schedules Oneworld : Download...";
1790
+		}
1591 1791
 		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1592 1792
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1593
-			if ($globalDebug) echo "Gunzip...";
1793
+			if ($globalDebug) {
1794
+				echo "Gunzip...";
1795
+			}
1594 1796
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1595
-			if ($globalDebug) echo "Add to DB...";
1797
+			if ($globalDebug) {
1798
+				echo "Add to DB...";
1799
+			}
1596 1800
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1597
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1801
+		} else {
1802
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1803
+		}
1598 1804
 		if ($error != '') {
1599 1805
 			return $error;
1600
-		} elseif ($globalDebug) echo "Done\n";
1806
+		} elseif ($globalDebug) {
1807
+			echo "Done\n";
1808
+		}
1601 1809
 		return '';
1602 1810
 	}
1603 1811
 	public static function update_skyteam() {
1604 1812
 		global $tmp_dir, $globalDebug;
1605 1813
 		$error = '';
1606
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
1814
+		if ($globalDebug) {
1815
+			echo "Schedules Skyteam : Download...";
1816
+		}
1607 1817
 		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1608 1818
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1609
-			if ($globalDebug) echo "Gunzip...";
1819
+			if ($globalDebug) {
1820
+				echo "Gunzip...";
1821
+			}
1610 1822
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1611
-			if ($globalDebug) echo "Add to DB...";
1823
+			if ($globalDebug) {
1824
+				echo "Add to DB...";
1825
+			}
1612 1826
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1613
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1827
+		} else {
1828
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1829
+		}
1614 1830
 		if ($error != '') {
1615 1831
 			return $error;
1616
-		} elseif ($globalDebug) echo "Done\n";
1832
+		} elseif ($globalDebug) {
1833
+			echo "Done\n";
1834
+		}
1617 1835
 		return '';
1618 1836
 	}
1619 1837
 	public static function update_ModeS() {
@@ -1630,370 +1848,642 @@  discard block
 block discarded – undo
1630 1848
 			exit;
1631 1849
 		} elseif ($globalDebug) echo "Done\n";
1632 1850
 */
1633
-		if ($globalDebug) echo "Modes : Download...";
1634
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1851
+		if ($globalDebug) {
1852
+			echo "Modes : Download...";
1853
+		}
1854
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1635 1855
 		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1636 1856
 
1637 1857
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1638 1858
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
1639
-			if ($globalDebug) echo "Unzip...";
1640
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1859
+			if ($globalDebug) {
1860
+				echo "Unzip...";
1861
+			}
1862
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
1641 1863
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
1642
-			if ($globalDebug) echo "Add to DB...";
1864
+			if ($globalDebug) {
1865
+				echo "Add to DB...";
1866
+			}
1643 1867
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
1644 1868
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
1645
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1869
+		} else {
1870
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1871
+		}
1646 1872
 		if ($error != '') {
1647 1873
 			return $error;
1648
-		} elseif ($globalDebug) echo "Done\n";
1874
+		} elseif ($globalDebug) {
1875
+			echo "Done\n";
1876
+		}
1649 1877
 		return '';
1650 1878
 	}
1651 1879
 
1652 1880
 	public static function update_ModeS_faa() {
1653 1881
 		global $tmp_dir, $globalDebug;
1654
-		if ($globalDebug) echo "Modes FAA: Download...";
1882
+		if ($globalDebug) {
1883
+			echo "Modes FAA: Download...";
1884
+		}
1655 1885
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1656 1886
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1657
-			if ($globalDebug) echo "Unzip...";
1887
+			if ($globalDebug) {
1888
+				echo "Unzip...";
1889
+			}
1658 1890
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
1659
-			if ($globalDebug) echo "Add to DB...";
1891
+			if ($globalDebug) {
1892
+				echo "Add to DB...";
1893
+			}
1660 1894
 			$error = update_db::modes_faa();
1661
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1895
+		} else {
1896
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
1897
+		}
1662 1898
 		if ($error != '') {
1663 1899
 			return $error;
1664
-		} elseif ($globalDebug) echo "Done\n";
1900
+		} elseif ($globalDebug) {
1901
+			echo "Done\n";
1902
+		}
1665 1903
 		return '';
1666 1904
 	}
1667 1905
 
1668 1906
 	public static function update_ModeS_flarm() {
1669 1907
 		global $tmp_dir, $globalDebug;
1670
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
1908
+		if ($globalDebug) {
1909
+			echo "Modes Flarmnet: Download...";
1910
+		}
1671 1911
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1672 1912
 		if (file_exists($tmp_dir.'data.fln')) {
1673
-			if ($globalDebug) echo "Add to DB...";
1913
+			if ($globalDebug) {
1914
+				echo "Add to DB...";
1915
+			}
1674 1916
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
1675
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1917
+		} else {
1918
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
1919
+		}
1676 1920
 		if ($error != '') {
1677 1921
 			return $error;
1678
-		} elseif ($globalDebug) echo "Done\n";
1922
+		} elseif ($globalDebug) {
1923
+			echo "Done\n";
1924
+		}
1679 1925
 		return '';
1680 1926
 	}
1681 1927
 
1682 1928
 	public static function update_ModeS_ogn() {
1683 1929
 		global $tmp_dir, $globalDebug;
1684
-		if ($globalDebug) echo "Modes OGN: Download...";
1930
+		if ($globalDebug) {
1931
+			echo "Modes OGN: Download...";
1932
+		}
1685 1933
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1686 1934
 		if (file_exists($tmp_dir.'ogn.csv')) {
1687
-			if ($globalDebug) echo "Add to DB...";
1935
+			if ($globalDebug) {
1936
+				echo "Add to DB...";
1937
+			}
1688 1938
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
1689
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1939
+		} else {
1940
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
1941
+		}
1690 1942
 		if ($error != '') {
1691 1943
 			return $error;
1692
-		} elseif ($globalDebug) echo "Done\n";
1944
+		} elseif ($globalDebug) {
1945
+			echo "Done\n";
1946
+		}
1693 1947
 		return '';
1694 1948
 	}
1695 1949
 
1696 1950
 	public static function update_owner() {
1697 1951
 		global $tmp_dir, $globalDebug, $globalMasterSource;
1698 1952
 		
1699
-		if ($globalDebug) echo "Owner France: Download...";
1953
+		if ($globalDebug) {
1954
+			echo "Owner France: Download...";
1955
+		}
1700 1956
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1701 1957
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1702
-			if ($globalDebug) echo "Add to DB...";
1958
+			if ($globalDebug) {
1959
+				echo "Add to DB...";
1960
+			}
1703 1961
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1704
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1962
+		} else {
1963
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1964
+		}
1705 1965
 		if ($error != '') {
1706 1966
 			return $error;
1707
-		} elseif ($globalDebug) echo "Done\n";
1967
+		} elseif ($globalDebug) {
1968
+			echo "Done\n";
1969
+		}
1708 1970
 		
1709
-		if ($globalDebug) echo "Owner Ireland: Download...";
1971
+		if ($globalDebug) {
1972
+			echo "Owner Ireland: Download...";
1973
+		}
1710 1974
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1711 1975
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1712
-			if ($globalDebug) echo "Add to DB...";
1976
+			if ($globalDebug) {
1977
+				echo "Add to DB...";
1978
+			}
1713 1979
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1714
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1980
+		} else {
1981
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1982
+		}
1715 1983
 		if ($error != '') {
1716 1984
 			return $error;
1717
-		} elseif ($globalDebug) echo "Done\n";
1718
-		if ($globalDebug) echo "Owner Switzerland: Download...";
1985
+		} elseif ($globalDebug) {
1986
+			echo "Done\n";
1987
+		}
1988
+		if ($globalDebug) {
1989
+			echo "Owner Switzerland: Download...";
1990
+		}
1719 1991
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1720 1992
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1721
-			if ($globalDebug) echo "Add to DB...";
1993
+			if ($globalDebug) {
1994
+				echo "Add to DB...";
1995
+			}
1722 1996
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1723
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1997
+		} else {
1998
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1999
+		}
1724 2000
 		if ($error != '') {
1725 2001
 			return $error;
1726
-		} elseif ($globalDebug) echo "Done\n";
1727
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2002
+		} elseif ($globalDebug) {
2003
+			echo "Done\n";
2004
+		}
2005
+		if ($globalDebug) {
2006
+			echo "Owner Czech Republic: Download...";
2007
+		}
1728 2008
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1729 2009
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1730
-			if ($globalDebug) echo "Add to DB...";
2010
+			if ($globalDebug) {
2011
+				echo "Add to DB...";
2012
+			}
1731 2013
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1732
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2014
+		} else {
2015
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2016
+		}
1733 2017
 		if ($error != '') {
1734 2018
 			return $error;
1735
-		} elseif ($globalDebug) echo "Done\n";
1736
-		if ($globalDebug) echo "Owner Australia: Download...";
2019
+		} elseif ($globalDebug) {
2020
+			echo "Done\n";
2021
+		}
2022
+		if ($globalDebug) {
2023
+			echo "Owner Australia: Download...";
2024
+		}
1737 2025
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1738 2026
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1739
-			if ($globalDebug) echo "Add to DB...";
2027
+			if ($globalDebug) {
2028
+				echo "Add to DB...";
2029
+			}
1740 2030
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1741
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2031
+		} else {
2032
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2033
+		}
1742 2034
 		if ($error != '') {
1743 2035
 			return $error;
1744
-		} elseif ($globalDebug) echo "Done\n";
1745
-		if ($globalDebug) echo "Owner Austria: Download...";
2036
+		} elseif ($globalDebug) {
2037
+			echo "Done\n";
2038
+		}
2039
+		if ($globalDebug) {
2040
+			echo "Owner Austria: Download...";
2041
+		}
1746 2042
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1747 2043
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1748
-			if ($globalDebug) echo "Add to DB...";
2044
+			if ($globalDebug) {
2045
+				echo "Add to DB...";
2046
+			}
1749 2047
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1750
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2048
+		} else {
2049
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2050
+		}
1751 2051
 		if ($error != '') {
1752 2052
 			return $error;
1753
-		} elseif ($globalDebug) echo "Done\n";
1754
-		if ($globalDebug) echo "Owner Chile: Download...";
2053
+		} elseif ($globalDebug) {
2054
+			echo "Done\n";
2055
+		}
2056
+		if ($globalDebug) {
2057
+			echo "Owner Chile: Download...";
2058
+		}
1755 2059
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1756 2060
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1757
-			if ($globalDebug) echo "Add to DB...";
2061
+			if ($globalDebug) {
2062
+				echo "Add to DB...";
2063
+			}
1758 2064
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1759
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2065
+		} else {
2066
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2067
+		}
1760 2068
 		if ($error != '') {
1761 2069
 			return $error;
1762
-		} elseif ($globalDebug) echo "Done\n";
1763
-		if ($globalDebug) echo "Owner Colombia: Download...";
2070
+		} elseif ($globalDebug) {
2071
+			echo "Done\n";
2072
+		}
2073
+		if ($globalDebug) {
2074
+			echo "Owner Colombia: Download...";
2075
+		}
1764 2076
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1765 2077
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1766
-			if ($globalDebug) echo "Add to DB...";
2078
+			if ($globalDebug) {
2079
+				echo "Add to DB...";
2080
+			}
1767 2081
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1768
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2082
+		} else {
2083
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2084
+		}
1769 2085
 		if ($error != '') {
1770 2086
 			return $error;
1771
-		} elseif ($globalDebug) echo "Done\n";
1772
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2087
+		} elseif ($globalDebug) {
2088
+			echo "Done\n";
2089
+		}
2090
+		if ($globalDebug) {
2091
+			echo "Owner Bosnia Herzegobina: Download...";
2092
+		}
1773 2093
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1774 2094
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1775
-			if ($globalDebug) echo "Add to DB...";
2095
+			if ($globalDebug) {
2096
+				echo "Add to DB...";
2097
+			}
1776 2098
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1777
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2099
+		} else {
2100
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2101
+		}
1778 2102
 		if ($error != '') {
1779 2103
 			return $error;
1780
-		} elseif ($globalDebug) echo "Done\n";
1781
-		if ($globalDebug) echo "Owner Brazil: Download...";
2104
+		} elseif ($globalDebug) {
2105
+			echo "Done\n";
2106
+		}
2107
+		if ($globalDebug) {
2108
+			echo "Owner Brazil: Download...";
2109
+		}
1782 2110
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1783 2111
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1784
-			if ($globalDebug) echo "Add to DB...";
2112
+			if ($globalDebug) {
2113
+				echo "Add to DB...";
2114
+			}
1785 2115
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1786
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2116
+		} else {
2117
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2118
+		}
1787 2119
 		if ($error != '') {
1788 2120
 			return $error;
1789
-		} elseif ($globalDebug) echo "Done\n";
1790
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2121
+		} elseif ($globalDebug) {
2122
+			echo "Done\n";
2123
+		}
2124
+		if ($globalDebug) {
2125
+			echo "Owner Cayman Islands: Download...";
2126
+		}
1791 2127
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1792 2128
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1793
-			if ($globalDebug) echo "Add to DB...";
2129
+			if ($globalDebug) {
2130
+				echo "Add to DB...";
2131
+			}
1794 2132
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1795
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2133
+		} else {
2134
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2135
+		}
1796 2136
 		if ($error != '') {
1797 2137
 			return $error;
1798
-		} elseif ($globalDebug) echo "Done\n";
1799
-		if ($globalDebug) echo "Owner Croatia: Download...";
2138
+		} elseif ($globalDebug) {
2139
+			echo "Done\n";
2140
+		}
2141
+		if ($globalDebug) {
2142
+			echo "Owner Croatia: Download...";
2143
+		}
1800 2144
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1801 2145
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1802
-			if ($globalDebug) echo "Add to DB...";
2146
+			if ($globalDebug) {
2147
+				echo "Add to DB...";
2148
+			}
1803 2149
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1804
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2150
+		} else {
2151
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2152
+		}
1805 2153
 		if ($error != '') {
1806 2154
 			return $error;
1807
-		} elseif ($globalDebug) echo "Done\n";
1808
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2155
+		} elseif ($globalDebug) {
2156
+			echo "Done\n";
2157
+		}
2158
+		if ($globalDebug) {
2159
+			echo "Owner Luxembourg: Download...";
2160
+		}
1809 2161
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1810 2162
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1811
-			if ($globalDebug) echo "Add to DB...";
2163
+			if ($globalDebug) {
2164
+				echo "Add to DB...";
2165
+			}
1812 2166
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1813
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2167
+		} else {
2168
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2169
+		}
1814 2170
 		if ($error != '') {
1815 2171
 			return $error;
1816
-		} elseif ($globalDebug) echo "Done\n";
1817
-		if ($globalDebug) echo "Owner Maldives: Download...";
2172
+		} elseif ($globalDebug) {
2173
+			echo "Done\n";
2174
+		}
2175
+		if ($globalDebug) {
2176
+			echo "Owner Maldives: Download...";
2177
+		}
1818 2178
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1819 2179
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1820
-			if ($globalDebug) echo "Add to DB...";
2180
+			if ($globalDebug) {
2181
+				echo "Add to DB...";
2182
+			}
1821 2183
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1822
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2184
+		} else {
2185
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2186
+		}
1823 2187
 		if ($error != '') {
1824 2188
 			return $error;
1825
-		} elseif ($globalDebug) echo "Done\n";
1826
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2189
+		} elseif ($globalDebug) {
2190
+			echo "Done\n";
2191
+		}
2192
+		if ($globalDebug) {
2193
+			echo "Owner New Zealand: Download...";
2194
+		}
1827 2195
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1828 2196
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1829
-			if ($globalDebug) echo "Add to DB...";
2197
+			if ($globalDebug) {
2198
+				echo "Add to DB...";
2199
+			}
1830 2200
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1831
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2201
+		} else {
2202
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2203
+		}
1832 2204
 		if ($error != '') {
1833 2205
 			return $error;
1834
-		} elseif ($globalDebug) echo "Done\n";
1835
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2206
+		} elseif ($globalDebug) {
2207
+			echo "Done\n";
2208
+		}
2209
+		if ($globalDebug) {
2210
+			echo "Owner Papua New Guinea: Download...";
2211
+		}
1836 2212
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1837 2213
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1838
-			if ($globalDebug) echo "Add to DB...";
2214
+			if ($globalDebug) {
2215
+				echo "Add to DB...";
2216
+			}
1839 2217
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1840
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2218
+		} else {
2219
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2220
+		}
1841 2221
 		if ($error != '') {
1842 2222
 			return $error;
1843
-		} elseif ($globalDebug) echo "Done\n";
1844
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2223
+		} elseif ($globalDebug) {
2224
+			echo "Done\n";
2225
+		}
2226
+		if ($globalDebug) {
2227
+			echo "Owner Slovakia: Download...";
2228
+		}
1845 2229
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1846 2230
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1847
-			if ($globalDebug) echo "Add to DB...";
2231
+			if ($globalDebug) {
2232
+				echo "Add to DB...";
2233
+			}
1848 2234
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1849
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2235
+		} else {
2236
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2237
+		}
1850 2238
 		if ($error != '') {
1851 2239
 			return $error;
1852
-		} elseif ($globalDebug) echo "Done\n";
1853
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2240
+		} elseif ($globalDebug) {
2241
+			echo "Done\n";
2242
+		}
2243
+		if ($globalDebug) {
2244
+			echo "Owner Ecuador: Download...";
2245
+		}
1854 2246
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1855 2247
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1856
-			if ($globalDebug) echo "Add to DB...";
2248
+			if ($globalDebug) {
2249
+				echo "Add to DB...";
2250
+			}
1857 2251
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1858
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2252
+		} else {
2253
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2254
+		}
1859 2255
 		if ($error != '') {
1860 2256
 			return $error;
1861
-		} elseif ($globalDebug) echo "Done\n";
1862
-		if ($globalDebug) echo "Owner Iceland: Download...";
2257
+		} elseif ($globalDebug) {
2258
+			echo "Done\n";
2259
+		}
2260
+		if ($globalDebug) {
2261
+			echo "Owner Iceland: Download...";
2262
+		}
1863 2263
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1864 2264
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1865
-			if ($globalDebug) echo "Add to DB...";
2265
+			if ($globalDebug) {
2266
+				echo "Add to DB...";
2267
+			}
1866 2268
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1867
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2269
+		} else {
2270
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2271
+		}
1868 2272
 		if ($error != '') {
1869 2273
 			return $error;
1870
-		} elseif ($globalDebug) echo "Done\n";
1871
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2274
+		} elseif ($globalDebug) {
2275
+			echo "Done\n";
2276
+		}
2277
+		if ($globalDebug) {
2278
+			echo "Owner Isle of Man: Download...";
2279
+		}
1872 2280
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
1873 2281
 		if (file_exists($tmp_dir.'owner_m.csv')) {
1874
-			if ($globalDebug) echo "Add to DB...";
2282
+			if ($globalDebug) {
2283
+				echo "Add to DB...";
2284
+			}
1875 2285
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
1876
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2286
+		} else {
2287
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2288
+		}
1877 2289
 		if ($error != '') {
1878 2290
 			return $error;
1879
-		} elseif ($globalDebug) echo "Done\n";
2291
+		} elseif ($globalDebug) {
2292
+			echo "Done\n";
2293
+		}
1880 2294
 		if ($globalMasterSource) {
1881
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2295
+			if ($globalDebug) {
2296
+				echo "ModeS Netherlands: Download...";
2297
+			}
1882 2298
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
1883 2299
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
1884
-				if ($globalDebug) echo "Add to DB...";
2300
+				if ($globalDebug) {
2301
+					echo "Add to DB...";
2302
+				}
1885 2303
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
1886
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2304
+			} else {
2305
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2306
+			}
1887 2307
 			if ($error != '') {
1888 2308
 				return $error;
1889
-			} elseif ($globalDebug) echo "Done\n";
1890
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2309
+			} elseif ($globalDebug) {
2310
+				echo "Done\n";
2311
+			}
2312
+			if ($globalDebug) {
2313
+				echo "ModeS Denmark: Download...";
2314
+			}
1891 2315
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
1892 2316
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
1893
-				if ($globalDebug) echo "Add to DB...";
2317
+				if ($globalDebug) {
2318
+					echo "Add to DB...";
2319
+				}
1894 2320
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
1895
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2321
+			} else {
2322
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2323
+			}
1896 2324
 			if ($error != '') {
1897 2325
 				return $error;
1898
-			} elseif ($globalDebug) echo "Done\n";
1899
-		} elseif ($globalDebug) echo "Done\n";
2326
+			} elseif ($globalDebug) {
2327
+				echo "Done\n";
2328
+			}
2329
+		} elseif ($globalDebug) {
2330
+			echo "Done\n";
2331
+		}
1900 2332
 		return '';
1901 2333
 	}
1902 2334
 
1903 2335
 	public static function update_translation() {
1904 2336
 		global $tmp_dir, $globalDebug;
1905 2337
 		$error = '';
1906
-		if ($globalDebug) echo "Translation : Download...";
2338
+		if ($globalDebug) {
2339
+			echo "Translation : Download...";
2340
+		}
1907 2341
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1908 2342
 		if (file_exists($tmp_dir.'translation.zip')) {
1909
-			if ($globalDebug) echo "Unzip...";
2343
+			if ($globalDebug) {
2344
+				echo "Unzip...";
2345
+			}
1910 2346
 			update_db::unzip($tmp_dir.'translation.zip');
1911
-			if ($globalDebug) echo "Add to DB...";
2347
+			if ($globalDebug) {
2348
+				echo "Add to DB...";
2349
+			}
1912 2350
 			$error = update_db::translation();
1913
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2351
+		} else {
2352
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2353
+		}
1914 2354
 		if ($error != '') {
1915 2355
 			return $error;
1916
-		} elseif ($globalDebug) echo "Done\n";
2356
+		} elseif ($globalDebug) {
2357
+			echo "Done\n";
2358
+		}
1917 2359
 		return '';
1918 2360
 	}
1919 2361
 
1920 2362
 	public static function update_translation_fam() {
1921 2363
 		global $tmp_dir, $globalDebug;
1922
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2364
+		if ($globalDebug) {
2365
+			echo "Translation from FlightAirMap website : Download...";
2366
+		}
1923 2367
 		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1924 2368
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1925
-			if ($globalDebug) echo "Gunzip...";
2369
+			if ($globalDebug) {
2370
+				echo "Gunzip...";
2371
+			}
1926 2372
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
1927
-			if ($globalDebug) echo "Add to DB...";
2373
+			if ($globalDebug) {
2374
+				echo "Add to DB...";
2375
+			}
1928 2376
 			$error = update_db::translation_fam();
1929
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2377
+		} else {
2378
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2379
+		}
1930 2380
 		if ($error != '') {
1931 2381
 			return $error;
1932
-		} elseif ($globalDebug) echo "Done\n";
2382
+		} elseif ($globalDebug) {
2383
+			echo "Done\n";
2384
+		}
1933 2385
 		return '';
1934 2386
 	}
1935 2387
 	public static function update_ModeS_fam() {
1936 2388
 		global $tmp_dir, $globalDebug;
1937
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2389
+		if ($globalDebug) {
2390
+			echo "ModeS from FlightAirMap website : Download...";
2391
+		}
1938 2392
 		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1939 2393
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1940
-			if ($globalDebug) echo "Gunzip...";
2394
+			if ($globalDebug) {
2395
+				echo "Gunzip...";
2396
+			}
1941 2397
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
1942
-			if ($globalDebug) echo "Add to DB...";
2398
+			if ($globalDebug) {
2399
+				echo "Add to DB...";
2400
+			}
1943 2401
 			$error = update_db::modes_fam();
1944
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2402
+		} else {
2403
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2404
+		}
1945 2405
 		if ($error != '') {
1946 2406
 			return $error;
1947
-		} elseif ($globalDebug) echo "Done\n";
2407
+		} elseif ($globalDebug) {
2408
+			echo "Done\n";
2409
+		}
1948 2410
 		return '';
1949 2411
 	}
1950 2412
 	public static function update_owner_fam() {
1951 2413
 		global $tmp_dir, $globalDebug, $globalOwner;
1952
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2414
+		if ($globalDebug) {
2415
+			echo "owner from FlightAirMap website : Download...";
2416
+		}
1953 2417
 		if ($globalOwner === TRUE) {
1954 2418
 			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
1955 2419
 		} else {
1956 2420
 			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
1957 2421
 		}
1958 2422
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
1959
-			if ($globalDebug) echo "Gunzip...";
2423
+			if ($globalDebug) {
2424
+				echo "Gunzip...";
2425
+			}
1960 2426
 			update_db::gunzip($tmp_dir.'owners.tsv.gz');
1961
-			if ($globalDebug) echo "Add to DB...";
2427
+			if ($globalDebug) {
2428
+				echo "Add to DB...";
2429
+			}
1962 2430
 			$error = update_db::owner_fam();
1963
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2431
+		} else {
2432
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
2433
+		}
1964 2434
 		if ($error != '') {
1965 2435
 			return $error;
1966
-		} elseif ($globalDebug) echo "Done\n";
2436
+		} elseif ($globalDebug) {
2437
+			echo "Done\n";
2438
+		}
1967 2439
 		return '';
1968 2440
 	}
1969 2441
 	public static function update_routes_fam() {
1970 2442
 		global $tmp_dir, $globalDebug;
1971
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2443
+		if ($globalDebug) {
2444
+			echo "Routes from FlightAirMap website : Download...";
2445
+		}
1972 2446
 		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
1973 2447
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
1974
-			if ($globalDebug) echo "Gunzip...";
2448
+			if ($globalDebug) {
2449
+				echo "Gunzip...";
2450
+			}
1975 2451
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
1976
-			if ($globalDebug) echo "Add to DB...";
2452
+			if ($globalDebug) {
2453
+				echo "Add to DB...";
2454
+			}
1977 2455
 			$error = update_db::routes_fam();
1978
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2456
+		} else {
2457
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
2458
+		}
1979 2459
 		if ($error != '') {
1980 2460
 			return $error;
1981
-		} elseif ($globalDebug) echo "Done\n";
2461
+		} elseif ($globalDebug) {
2462
+			echo "Done\n";
2463
+		}
1982 2464
 		return '';
1983 2465
 	}
1984 2466
 	public static function update_banned_fam() {
1985 2467
 		global $tmp_dir, $globalDebug;
1986
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2468
+		if ($globalDebug) {
2469
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
2470
+		}
1987 2471
 		update_db::download('http://data.flightairmap.fr/data/ban_eu.csv',$tmp_dir.'ban_eu.csv');
1988 2472
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
1989 2473
 			//if ($globalDebug) echo "Gunzip...";
1990 2474
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
1991
-			if ($globalDebug) echo "Add to DB...";
2475
+			if ($globalDebug) {
2476
+				echo "Add to DB...";
2477
+			}
1992 2478
 			$error = update_db::banned_fam();
1993
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2479
+		} else {
2480
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
2481
+		}
1994 2482
 		if ($error != '') {
1995 2483
 			return $error;
1996
-		} elseif ($globalDebug) echo "Done\n";
2484
+		} elseif ($globalDebug) {
2485
+			echo "Done\n";
2486
+		}
1997 2487
 		return '';
1998 2488
 	}
1999 2489
 
@@ -2001,7 +2491,9 @@  discard block
 block discarded – undo
2001 2491
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2002 2492
 		include_once('class.create_db.php');
2003 2493
 		$error = '';
2004
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2494
+		if ($globalDebug) {
2495
+			echo "Airspace from FlightAirMap website : Download...";
2496
+		}
2005 2497
 		if ($globalDBdriver == 'mysql') {
2006 2498
 			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2007 2499
 		} else {
@@ -2017,9 +2509,13 @@  discard block
 block discarded – undo
2017 2509
 					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2018 2510
 				}
2019 2511
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2020
-					if ($globalDebug) echo "Gunzip...";
2512
+					if ($globalDebug) {
2513
+						echo "Gunzip...";
2514
+					}
2021 2515
 					update_db::gunzip($tmp_dir.'airspace.sql.gz');
2022
-					if ($globalDebug) echo "Add to DB...";
2516
+					if ($globalDebug) {
2517
+						echo "Add to DB...";
2518
+					}
2023 2519
 					$Connection = new Connection();
2024 2520
 					if ($Connection->tableExists('airspace')) {
2025 2521
 						$query = 'DROP TABLE airspace';
@@ -2032,31 +2528,47 @@  discard block
 block discarded – undo
2032 2528
 		    			}
2033 2529
 					$error = create_db::import_file($tmp_dir.'airspace.sql');
2034 2530
 					update_db::insert_airspace_version($airspace_md5);
2035
-				} else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2531
+				} else {
2532
+					$error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed.";
2533
+				}
2036 2534
 			}
2037
-		} else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2535
+		} else {
2536
+			$error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed.";
2537
+		}
2038 2538
 		if ($error != '') {
2039 2539
 			return $error;
2040
-		} elseif ($globalDebug) echo "Done\n";
2540
+		} elseif ($globalDebug) {
2541
+			echo "Done\n";
2542
+		}
2041 2543
 		return '';
2042 2544
 	}
2043 2545
 
2044 2546
 	public static function update_tle() {
2045 2547
 		global $tmp_dir, $globalDebug;
2046
-		if ($globalDebug) echo "Download TLE : Download...";
2548
+		if ($globalDebug) {
2549
+			echo "Download TLE : Download...";
2550
+		}
2047 2551
 		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2048 2552
 		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2049 2553
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
2050 2554
 		foreach ($alltle as $filename) {
2051
-			if ($globalDebug) echo "downloading ".$filename.'...';
2555
+			if ($globalDebug) {
2556
+				echo "downloading ".$filename.'...';
2557
+			}
2052 2558
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2053 2559
 			if (file_exists($tmp_dir.$filename)) {
2054
-				if ($globalDebug) echo "Add to DB ".$filename."...";
2560
+				if ($globalDebug) {
2561
+					echo "Add to DB ".$filename."...";
2562
+				}
2055 2563
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2056
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2564
+			} else {
2565
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2566
+			}
2057 2567
 			if ($error != '') {
2058 2568
 				echo $error."\n";
2059
-			} elseif ($globalDebug) echo "Done\n";
2569
+			} elseif ($globalDebug) {
2570
+				echo "Done\n";
2571
+			}
2060 2572
 		}
2061 2573
 		return '';
2062 2574
 	}
@@ -2064,10 +2576,14 @@  discard block
 block discarded – undo
2064 2576
 	public static function update_models() {
2065 2577
 		global $tmp_dir, $globalDebug;
2066 2578
 		$error = '';
2067
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2579
+		if ($globalDebug) {
2580
+			echo "Models from FlightAirMap website : Download...";
2581
+		}
2068 2582
 		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2069 2583
 		if (file_exists($tmp_dir.'models.md5sum')) {
2070
-			if ($globalDebug) echo "Check files...\n";
2584
+			if ($globalDebug) {
2585
+				echo "Check files...\n";
2586
+			}
2071 2587
 			$newmodelsdb = array();
2072 2588
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2073 2589
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2086,25 +2602,35 @@  discard block
 block discarded – undo
2086 2602
 			}
2087 2603
 			$diff = array_diff($newmodelsdb,$modelsdb);
2088 2604
 			foreach ($diff as $key => $value) {
2089
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2605
+				if ($globalDebug) {
2606
+					echo 'Downloading model '.$key.' ...'."\n";
2607
+				}
2090 2608
 				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2091 2609
 				
2092 2610
 			}
2093 2611
 			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2094
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2612
+		} else {
2613
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2614
+		}
2095 2615
 		if ($error != '') {
2096 2616
 			return $error;
2097
-		} elseif ($globalDebug) echo "Done\n";
2617
+		} elseif ($globalDebug) {
2618
+			echo "Done\n";
2619
+		}
2098 2620
 		return '';
2099 2621
 	}
2100 2622
 
2101 2623
 	public static function update_space_models() {
2102 2624
 		global $tmp_dir, $globalDebug;
2103 2625
 		$error = '';
2104
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2626
+		if ($globalDebug) {
2627
+			echo "Space models from FlightAirMap website : Download...";
2628
+		}
2105 2629
 		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2106 2630
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2107
-			if ($globalDebug) echo "Check files...\n";
2631
+			if ($globalDebug) {
2632
+				echo "Check files...\n";
2633
+			}
2108 2634
 			$newmodelsdb = array();
2109 2635
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2110 2636
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2123,15 +2649,21 @@  discard block
 block discarded – undo
2123 2649
 			}
2124 2650
 			$diff = array_diff($newmodelsdb,$modelsdb);
2125 2651
 			foreach ($diff as $key => $value) {
2126
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2652
+				if ($globalDebug) {
2653
+					echo 'Downloading space model '.$key.' ...'."\n";
2654
+				}
2127 2655
 				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2128 2656
 				
2129 2657
 			}
2130 2658
 			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2131
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2659
+		} else {
2660
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2661
+		}
2132 2662
 		if ($error != '') {
2133 2663
 			return $error;
2134
-		} elseif ($globalDebug) echo "Done\n";
2664
+		} elseif ($globalDebug) {
2665
+			echo "Done\n";
2666
+		}
2135 2667
 		return '';
2136 2668
 	}
2137 2669
 
@@ -2174,7 +2706,9 @@  discard block
 block discarded – undo
2174 2706
                 }
2175 2707
 
2176 2708
 		$error = '';
2177
-		if ($globalDebug) echo "Notam : Download...";
2709
+		if ($globalDebug) {
2710
+			echo "Notam : Download...";
2711
+		}
2178 2712
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2179 2713
 		if (file_exists($tmp_dir.'notam.rss')) {
2180 2714
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -2189,14 +2723,30 @@  discard block
 block discarded – undo
2189 2723
 				$data['fir'] = $q[0];
2190 2724
 				$data['code'] = $q[1];
2191 2725
 				$ifrvfr = $q[2];
2192
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
2193
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
2194
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
2195
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
2196
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
2197
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
2198
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
2199
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
2726
+				if ($ifrvfr == 'IV') {
2727
+					$data['rules'] = 'IFR/VFR';
2728
+				}
2729
+				if ($ifrvfr == 'I') {
2730
+					$data['rules'] = 'IFR';
2731
+				}
2732
+				if ($ifrvfr == 'V') {
2733
+					$data['rules'] = 'VFR';
2734
+				}
2735
+				if ($q[4] == 'A') {
2736
+					$data['scope'] = 'Airport warning';
2737
+				}
2738
+				if ($q[4] == 'E') {
2739
+					$data['scope'] = 'Enroute warning';
2740
+				}
2741
+				if ($q[4] == 'W') {
2742
+					$data['scope'] = 'Navigation warning';
2743
+				}
2744
+				if ($q[4] == 'AE') {
2745
+					$data['scope'] = 'Airport/Enroute warning';
2746
+				}
2747
+				if ($q[4] == 'AW') {
2748
+					$data['scope'] = 'Airport/Navigation warning';
2749
+				}
2200 2750
 				//$data['scope'] = $q[4];
2201 2751
 				$data['lower_limit'] = $q[5];
2202 2752
 				$data['upper_limit'] = $q[6];
@@ -2204,8 +2754,12 @@  discard block
 block discarded – undo
2204 2754
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2205 2755
 				$latitude = $Common->convertDec($las,'latitude');
2206 2756
 				$longitude = $Common->convertDec($lns,'longitude');
2207
-				if ($lac == 'S') $latitude = '-'.$latitude;
2208
-				if ($lnc == 'W') $longitude = '-'.$longitude;
2757
+				if ($lac == 'S') {
2758
+					$latitude = '-'.$latitude;
2759
+				}
2760
+				if ($lnc == 'W') {
2761
+					$longitude = '-'.$longitude;
2762
+				}
2209 2763
 				$data['center_latitude'] = $latitude;
2210 2764
 				$data['center_longitude'] = $longitude;
2211 2765
 				$data['radius'] = intval($radius);
@@ -2235,10 +2789,14 @@  discard block
 block discarded – undo
2235 2789
 				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
2236 2790
 				unset($data);
2237 2791
 			} 
2238
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2792
+		} else {
2793
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
2794
+		}
2239 2795
 		if ($error != '') {
2240 2796
 			return $error;
2241
-		} elseif ($globalDebug) echo "Done\n";
2797
+		} elseif ($globalDebug) {
2798
+			echo "Done\n";
2799
+		}
2242 2800
 		return '';
2243 2801
 	}
2244 2802
 	
@@ -2263,7 +2821,9 @@  discard block
 block discarded – undo
2263 2821
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2264 2822
 		$airspace_json = json_decode($airspace_lst,true);
2265 2823
 		foreach ($airspace_json['records'] as $airspace) {
2266
-			if ($globalDebug) echo $airspace['name']."...\n";
2824
+			if ($globalDebug) {
2825
+				echo $airspace['name']."...\n";
2826
+			}
2267 2827
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2268 2828
 			if (file_exists($tmp_dir.$airspace['name'])) {
2269 2829
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -2307,8 +2867,11 @@  discard block
 block discarded – undo
2307 2867
                         return "error : ".$e->getMessage();
2308 2868
                 }
2309 2869
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2310
-                if ($row['nb'] > 0) return false;
2311
-                else return true;
2870
+                if ($row['nb'] > 0) {
2871
+                	return false;
2872
+                } else {
2873
+                	return true;
2874
+                }
2312 2875
 	}
2313 2876
 
2314 2877
 	public static function insert_last_update() {
@@ -2333,8 +2896,11 @@  discard block
 block discarded – undo
2333 2896
                         return "error : ".$e->getMessage();
2334 2897
                 }
2335 2898
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2336
-                if ($row['nb'] > 0) return true;
2337
-                else return false;
2899
+                if ($row['nb'] > 0) {
2900
+                	return true;
2901
+                } else {
2902
+                	return false;
2903
+                }
2338 2904
 	}
2339 2905
 
2340 2906
 
@@ -2365,8 +2931,11 @@  discard block
 block discarded – undo
2365 2931
                         return "error : ".$e->getMessage();
2366 2932
                 }
2367 2933
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2368
-                if ($row['nb'] > 0) return false;
2369
-                else return true;
2934
+                if ($row['nb'] > 0) {
2935
+                	return false;
2936
+                } else {
2937
+                	return true;
2938
+                }
2370 2939
 	}
2371 2940
 
2372 2941
 	public static function insert_last_notam_update() {
@@ -2395,8 +2964,11 @@  discard block
 block discarded – undo
2395 2964
                         return "error : ".$e->getMessage();
2396 2965
                 }
2397 2966
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2398
-                if ($row['nb'] > 0) return false;
2399
-                else return true;
2967
+                if ($row['nb'] > 0) {
2968
+                	return false;
2969
+                } else {
2970
+                	return true;
2971
+                }
2400 2972
 	}
2401 2973
 
2402 2974
 	public static function insert_last_airspace_update() {
@@ -2426,8 +2998,11 @@  discard block
 block discarded – undo
2426 2998
                         return "error : ".$e->getMessage();
2427 2999
                 }
2428 3000
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2429
-                if ($row['nb'] > 0) return false;
2430
-                else return true;
3001
+                if ($row['nb'] > 0) {
3002
+                	return false;
3003
+                } else {
3004
+                	return true;
3005
+                }
2431 3006
 	}
2432 3007
 
2433 3008
 	public static function insert_last_owner_update() {
@@ -2456,8 +3031,11 @@  discard block
 block discarded – undo
2456 3031
                         return "error : ".$e->getMessage();
2457 3032
                 }
2458 3033
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2459
-                if ($row['nb'] > 0) return false;
2460
-                else return true;
3034
+                if ($row['nb'] > 0) {
3035
+                	return false;
3036
+                } else {
3037
+                	return true;
3038
+                }
2461 3039
 	}
2462 3040
 
2463 3041
 	public static function insert_last_schedules_update() {
@@ -2486,8 +3064,11 @@  discard block
 block discarded – undo
2486 3064
                         return "error : ".$e->getMessage();
2487 3065
                 }
2488 3066
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
2489
-                if ($row['nb'] > 0) return false;
2490
-                else return true;
3067
+                if ($row['nb'] > 0) {
3068
+                	return false;
3069
+                } else {
3070
+                	return true;
3071
+                }
2491 3072
 	}
2492 3073
 
2493 3074
 	public static function insert_last_tle_update() {
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
 	    die;
41 41
 	}
42 42
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
43
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
43
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
44 44
     }
45 45
 }
46 46
 
47
-$options = getopt('s::',array('source::','server','idsource::'));
47
+$options = getopt('s::', array('source::', 'server', 'idsource::'));
48 48
 //if (isset($options['s'])) $hosts = array($options['s']);
49 49
 //elseif (isset($options['source'])) $hosts = array($options['source']);
50 50
 if (isset($options['s'])) {
@@ -59,17 +59,17 @@  discard block
 block discarded – undo
59 59
 else $id_source = 1;
60 60
 if (isset($globalServer) && $globalServer) {
61 61
     if ($globalDebug) echo "Using Server Mode\n";
62
-    $SI=new SpotterServer();
63
-} else $SI=new SpotterImport($Connection->db);
62
+    $SI = new SpotterServer();
63
+} else $SI = new SpotterImport($Connection->db);
64 64
 //$APRS=new APRS($Connection->db);
65
-$SBS=new SBS();
66
-$ACARS=new ACARS($Connection->db);
67
-$Common=new Common();
65
+$SBS = new SBS();
66
+$ACARS = new ACARS($Connection->db);
67
+$Common = new Common();
68 68
 date_default_timezone_set('UTC');
69 69
 //$servertz = system('date +%Z');
70 70
 // signal handler - playing nice with sockets and dump1090
71 71
 if (function_exists('pcntl_fork')) {
72
-    pcntl_signal(SIGINT,  function() {
72
+    pcntl_signal(SIGINT, function() {
73 73
         global $sockets;
74 74
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75 75
         die("Bye!\n");
@@ -113,35 +113,35 @@  discard block
 block discarded – undo
113 113
 
114 114
 function connect_all($hosts) {
115 115
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
116
+    global $sockets, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset;
117 117
     $reset++;
118 118
     if ($globalDebug) echo 'Connect to all...'."\n";
119 119
     foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
123
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
+            if (preg_match('/deltadb.txt$/i', $host)) {
125 125
         	//$formats[$id] = 'deltadbtxt';
126 126
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 127
         	//$last_exec['deltadbtxt'] = 0;
128 128
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
129
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
130 130
         	//$formats[$id] = 'vatsimtxt';
131 131
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 132
         	//$last_exec['vatsimtxt'] = 0;
133 133
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
134
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
135 135
         	//$formats[$id] = 'aircraftlistjson';
136 136
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 137
         	//$last_exec['aircraftlistjson'] = 0;
138 138
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
139
+    	    } else if (preg_match('/opensky/i', $host)) {
140 140
         	//$formats[$id] = 'aircraftlistjson';
141 141
         	$globalSources[$id]['format'] = 'opensky';
142 142
         	//$last_exec['aircraftlistjson'] = 0;
143 143
         	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
144
+    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) {
145 145
         	//$formats[$id] = 'radarvirtueljson';
146 146
         	$globalSources[$id]['format'] = 'radarvirtueljson';
147 147
         	//$last_exec['radarvirtueljson'] = 0;
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151 151
         	    exit(0);
152 152
         	}
153
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
153
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
154 154
         	//$formats[$id] = 'planeupdatefaa';
155 155
         	$globalSources[$id]['format'] = 'planeupdatefaa';
156 156
         	//$last_exec['planeupdatefaa'] = 0;
@@ -159,26 +159,26 @@  discard block
 block discarded – undo
159 159
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160 160
         	    exit(0);
161 161
         	}
162
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
162
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
163 163
         	//$formats[$id] = 'phpvmacars';
164 164
         	$globalSources[$id]['format'] = 'phpvmacars';
165 165
         	//$last_exec['phpvmacars'] = 0;
166 166
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
167
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
167
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
168 168
         	//$formats[$id] = 'phpvmacars';
169 169
         	$globalSources[$id]['format'] = 'vam';
170 170
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
171
-            } else if (preg_match('/whazzup/i',$host)) {
171
+            } else if (preg_match('/whazzup/i', $host)) {
172 172
         	//$formats[$id] = 'whazzup';
173 173
         	$globalSources[$id]['format'] = 'whazzup';
174 174
         	//$last_exec['whazzup'] = 0;
175 175
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
176
-            } else if (preg_match('/recentpireps/i',$host)) {
176
+            } else if (preg_match('/recentpireps/i', $host)) {
177 177
         	//$formats[$id] = 'pirepsjson';
178 178
         	$globalSources[$id]['format'] = 'pirepsjson';
179 179
         	//$last_exec['pirepsjson'] = 0;
180 180
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
181
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
181
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
182 182
         	//$formats[$id] = 'fr24json';
183 183
         	$globalSources[$id]['format'] = 'fr24json';
184 184
         	//$last_exec['fr24json'] = 0;
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
         	    exit(0);
189 189
         	}
190 190
             //} else if (preg_match('/10001/',$host)) {
191
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
191
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192 192
         	//$formats[$id] = 'tsv';
193 193
         	$globalSources[$id]['format'] = 'tsv';
194 194
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
195 195
             }
196
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
196
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
197 197
         	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
198
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199
-	    $hostport = explode(':',$host);
198
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
199
+	    $hostport = explode(':', $host);
200 200
 	    if (isset($hostport[1])) {
201 201
 		$port = $hostport[1];
202 202
 		$hostn = $hostport[0];
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
 		$hostn = $globalSources[$id]['host'];
206 206
 	    }
207 207
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
208
-        	$s = create_socket($hostn,$port, $errno, $errstr);
208
+        	$s = create_socket($hostn, $port, $errno, $errstr);
209 209
     	    } else {
210
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
210
+        	$s = create_socket_udp($hostn, $port, $errno, $errstr);
211 211
 	    }
212 212
 	    if ($s) {
213 213
     	        $sockets[$id] = $s;
214 214
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
215
-		    if (preg_match('/aprs/',$hostn)) {
215
+		    if (preg_match('/aprs/', $hostn)) {
216 216
 			//$formats[$id] = 'aprs';
217 217
 			$globalSources[$id]['format'] = 'aprs';
218 218
 			//$aprs_connect = 0;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
254 254
 else $timeout = 20;
255 255
 $errno = '';
256
-$errstr='';
256
+$errstr = '';
257 257
 
258 258
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
259 259
 /* Initiate connections to all the hosts simultaneously */
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 
283 283
 if ($use_aprs) {
284 284
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
285
-	$APRS=new APRS();
285
+	$APRS = new APRS();
286 286
 	$aprs_connect = 0;
287 287
 	$aprs_keep = 120;
288 288
 	$aprs_last_tx = time();
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	else $aprs_ssid = 'FAM';
294 294
 	//else $aprs_ssid = 'PerlEx';
295 295
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
296
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
296
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
297 297
 	if ($aprs_full) $aprs_filter = '';
298 298
 	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n";
299 299
 	else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n";
@@ -304,12 +304,12 @@  discard block
 block discarded – undo
304 304
 sleep(1);
305 305
 if ($globalDebug) echo "SCAN MODE \n\n";
306 306
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
307
-$endtime = time()+$globalCronEnd;
307
+$endtime = time() + $globalCronEnd;
308 308
 $i = 1;
309 309
 $tt = array();
310 310
 // Delete all ATC
311 311
 if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
312
-	$ATC=new ATC($Connection->db);
312
+	$ATC = new ATC($Connection->db);
313 313
 }
314 314
 if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
315 315
 	$ATC->deleteAll();
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
319 319
 while ($i > 0) {
320
-    if (!$globalDaemon) $i = $endtime-time();
320
+    if (!$globalDaemon) $i = $endtime - time();
321 321
     // Delete old ATC
322 322
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
323 323
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 	}
332 332
 	if ($max != $globalMinFetch) {
333 333
 	    if ($globalDebug) echo 'Sleeping...'."\n";
334
-	    sleep($globalMinFetch-$max+2);
334
+	    sleep($globalMinFetch - $max + 2);
335 335
 	}
336 336
     }
337 337
 
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 	    //$buffer = $Common->getData($hosts[$id]);
344 344
 	    $buffer = $Common->getData($value['host']);
345 345
 	    if ($buffer != '') $reset = 0;
346
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347
-	    $buffer = explode('\n',$buffer);
346
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
347
+	    $buffer = explode('\n', $buffer);
348 348
 	    foreach ($buffer as $line) {
349 349
     		if ($line != '' && count($line) > 7) {
350 350
     		    $line = explode(',', $line);
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
374 374
 	    //$buffer = $Common->getData($hosts[$id]);
375 375
 	    $buffer = $Common->getData($value['host']);
376
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
-	    $buffer = explode('\n',$buffer);
376
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
377
+	    $buffer = explode('\n', $buffer);
378 378
 	    $reset = 0;
379 379
 	    foreach ($buffer as $line) {
380 380
     		if ($line != '') {
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 			$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
385 385
 			$data['pilot_id'] = $line[1];
386 386
 			$data['pilot_name'] = $line[2];
387
-			$data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT);
387
+			$data['hex'] = str_pad(dechex($line[1]), 6, '000000', STR_PAD_LEFT);
388 388
 			$data['ident'] = $line[0]; // ident
389 389
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
390 390
 			$data['speed'] = $line[8]; // speed
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
401 401
 			if (isset($line[37])) $data['last_update'] = $line[37];
402 402
 		        $data['departure_airport_icao'] = $line[11];
403
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
403
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
404 404
 		        $data['arrival_airport_icao'] = $line[13];
405 405
 			$data['frequency'] = $line[4];
406 406
 			$data['type'] = $line[18];
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
     			$data['id_source'] = $id_source;
410 410
 	    		//$data['arrival_airport_time'] = ;
411 411
 	    		if ($line[9] != '') {
412
-	    		    $aircraft_data = explode('/',$line[9]);
412
+	    		    $aircraft_data = explode('/', $line[9]);
413 413
 	    		    if (isset($aircraft_data[1])) {
414 414
 	    			$data['aircraft_icao'] = $aircraft_data[1];
415 415
 	    		    }
@@ -423,9 +423,9 @@  discard block
 block discarded – undo
423 423
     			if ($line[3] == 'PILOT') $SI->add($data);
424 424
 			elseif ($line[3] == 'ATC') {
425 425
 				//print_r($data);
426
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
427
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
428
-				$typec = substr($data['ident'],-3);
426
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
427
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
428
+				$typec = substr($data['ident'], -3);
429 429
 				if ($typec == 'APP') $data['type'] = 'Approach';
430 430
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
431 431
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
437 437
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
438 438
 				if (!isset($data['source_name'])) $data['source_name'] = '';
439
-				echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
439
+				echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
440 440
 			}
441 441
     			unset($data);
442 442
     		    }
@@ -447,9 +447,9 @@  discard block
 block discarded – undo
447 447
     	    $last_exec[$id]['last'] = time();
448 448
     	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
449 449
     	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
450
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
450
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
451 451
 	    if ($buffer != '') {
452
-	    $all_data = json_decode($buffer,true);
452
+	    $all_data = json_decode($buffer, true);
453 453
 	    if (isset($all_data['acList'])) {
454 454
 		$reset = 0;
455 455
 		foreach ($all_data['acList'] as $line) {
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
506 506
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
507 507
 	    $buffer = $Common->getData($value['host']);
508
-	    $all_data = json_decode($buffer,true);
508
+	    $all_data = json_decode($buffer, true);
509 509
 	    if (isset($all_data['planes'])) {
510 510
 		$reset = 0;
511 511
 		foreach ($all_data['planes'] as $key => $line) {
@@ -522,12 +522,12 @@  discard block
 block discarded – undo
522 522
 		    $data['emergency'] = ''; // emergency
523 523
 		    $data['registration'] = $line[2];
524 524
 		    $data['aircraft_icao'] = $line[0];
525
-		    $deparr = explode('-',$line[1]);
525
+		    $deparr = explode('-', $line[1]);
526 526
 		    if (count($deparr) == 2) {
527 527
 			$data['departure_airport_icao'] = $deparr[0];
528 528
 			$data['arrival_airport_icao'] = $deparr[1];
529 529
 		    }
530
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
530
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
531 531
 	    	    $data['format_source'] = 'planeupdatefaa';
532 532
     		    $data['id_source'] = $id_source;
533 533
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
     	    $last_exec[$id]['last'] = time();
540 540
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
541 541
 	    $buffer = $Common->getData($value['host']);
542
-	    $all_data = json_decode($buffer,true);
542
+	    $all_data = json_decode($buffer, true);
543 543
 	    if (isset($all_data['states'])) {
544 544
 		$reset = 0;
545 545
 		foreach ($all_data['states'] as $key => $line) {
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 		    //$data['emergency'] = ''; // emergency
557 557
 		    //$data['registration'] = $line[2];
558 558
 		    //$data['aircraft_icao'] = $line[0];
559
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
559
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
560 560
 	    	    $data['format_source'] = 'opensky';
561 561
     		    $data['id_source'] = $id_source;
562 562
 		    $SI->add($data);
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
570 570
 	    //$buffer = $Common->getData($hosts[$id]);
571 571
 	    $buffer = $Common->getData($value['host']);
572
-	    $all_data = json_decode($buffer,true);
572
+	    $all_data = json_decode($buffer, true);
573 573
 	    if (!empty($all_data)) $reset = 0;
574 574
 	    foreach ($all_data as $key => $line) {
575 575
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -601,11 +601,11 @@  discard block
 block discarded – undo
601 601
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
602 602
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
603 603
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
604
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
604
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
605 605
 	    //echo $buffer;
606
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
607
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
608
-	    $all_data = json_decode($buffer,true);
606
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
607
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
608
+	    $all_data = json_decode($buffer, true);
609 609
 	    if (json_last_error() != JSON_ERROR_NONE) {
610 610
 		die(json_last_error_msg());
611 611
 	    }
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 			//$data['departure_airport_iata'] = $line[11];
629 629
 			//$data['arrival_airport_iata'] = $line[12];
630 630
 	    		//$data['emergency'] = ''; // emergency
631
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
631
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
632 632
 	    		$data['format_source'] = 'radarvirtueljson';
633 633
     			$data['id_source'] = $id_source;
634 634
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -643,14 +643,14 @@  discard block
 block discarded – undo
643 643
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
644 644
 	    //$buffer = $Common->getData($hosts[$id]);
645 645
 	    $buffer = $Common->getData($value['host'].'?'.time());
646
-	    $all_data = json_decode(utf8_encode($buffer),true);
646
+	    $all_data = json_decode(utf8_encode($buffer), true);
647 647
 	    
648 648
 	    if (isset($all_data['pireps'])) {
649 649
 		$reset = 0;
650 650
 	        foreach ($all_data['pireps'] as $line) {
651 651
 		    $data = array();
652 652
 		    $data['id'] = $line['id'];
653
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
653
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
654 654
 		    $data['ident'] = $line['callsign']; // ident
655 655
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
656 656
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -679,9 +679,9 @@  discard block
 block discarded – undo
679 679
 			$SI->add($data);
680 680
 		    //    print_r($data);
681 681
     		    } elseif ($line['icon'] == 'ct') {
682
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
683
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
684
-			$typec = substr($data['ident'],-3);
682
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
683
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
684
+			$typec = substr($data['ident'], -3);
685 685
 			$data['type'] = '';
686 686
 			if ($typec == 'APP') $data['type'] = 'Approach';
687 687
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
693 693
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
694 694
 			else $data['type'] = 'Observer';
695
-			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
695
+			echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']);
696 696
 		    }
697 697
 		    unset($data);
698 698
 		}
@@ -704,14 +704,14 @@  discard block
 block discarded – undo
704 704
 	    //$buffer = $Common->getData($hosts[$id]);
705 705
 	    if ($globalDebug) echo 'Get Data...'."\n";
706 706
 	    $buffer = $Common->getData($value['host']);
707
-	    $all_data = json_decode($buffer,true);
707
+	    $all_data = json_decode($buffer, true);
708 708
 	    if ($buffer != '' && is_array($all_data)) {
709 709
 		$reset = 0;
710 710
 		foreach ($all_data as $line) {
711 711
 	    	    $data = array();
712 712
 	    	    //$data['id'] = $line['id']; // id not usable
713 713
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
714
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
714
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
715 715
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
716 716
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
717 717
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -734,12 +734,12 @@  discard block
 block discarded – undo
734 734
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
735 735
 		    if (isset($line['aircraftname'])) {
736 736
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
737
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
738
-	    		$aircraft_data = explode('-',$line['aircraftname']);
737
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
738
+	    		$aircraft_data = explode('-', $line['aircraftname']);
739 739
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
740 740
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
741 741
 	    		else {
742
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
742
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
743 743
 	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
744 744
 	    		    else $data['aircraft_icao'] = $line['aircraftname'];
745 745
 	    		}
@@ -761,14 +761,14 @@  discard block
 block discarded – undo
761 761
 	    //$buffer = $Common->getData($hosts[$id]);
762 762
 	    if ($globalDebug) echo 'Get Data...'."\n";
763 763
 	    $buffer = $Common->getData($value['host']);
764
-	    $all_data = json_decode($buffer,true);
764
+	    $all_data = json_decode($buffer, true);
765 765
 	    if ($buffer != '' && is_array($all_data)) {
766 766
 		$reset = 0;
767 767
 		foreach ($all_data as $line) {
768 768
 	    	    $data = array();
769 769
 	    	    //$data['id'] = $line['id']; // id not usable
770 770
 	    	    $data['id'] = trim($line['flight_id']);
771
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
771
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
772 772
 	    	    $data['pilot_name'] = $line['pilot_name'];
773 773
 	    	    $data['pilot_id'] = $line['pilot_id'];
774 774
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -819,9 +819,9 @@  discard block
 block discarded – undo
819 819
 		    //$value = $formats[$nb];
820 820
 		    $format = $globalSources[$nb]['format'];
821 821
         	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
822
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
822
+        		$buffer = socket_read($r, 6000, PHP_NORMAL_READ);
823 823
         	    } else {
824
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
824
+	    	        $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
825 825
 	    	    }
826 826
         	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
827 827
         	    //echo $buffer."\n";
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
 		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
830 830
 		    $error = false;
831 831
 		    //$SI::del();
832
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
832
+		    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
833 833
 		    // SBS format is CSV format
834 834
 		    if ($buffer != '') {
835 835
 			$tt[$format] = 0;
@@ -850,10 +850,10 @@  discard block
 block discarded – undo
850 850
                         } elseif ($format == 'flightgearsp') {
851 851
                     	    //echo $buffer."\n";
852 852
                     	    if (strlen($buffer) > 5) {
853
-				$line = explode(',',$buffer);
853
+				$line = explode(',', $buffer);
854 854
 				$data = array();
855 855
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
856
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
856
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
857 857
 				$data['ident'] = $line[6];
858 858
 				$data['aircraft_name'] = $line[7];
859 859
 				$data['longitude'] = $line[1];
@@ -864,21 +864,21 @@  discard block
 block discarded – undo
864 864
 				$data['datetime'] = date('Y-m-d H:i:s');
865 865
 				$data['format_source'] = 'flightgearsp';
866 866
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
867
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
867
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
868 868
 			    }
869 869
                         } elseif ($format == 'acars') {
870 870
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
871 871
 			    $ACARS->add(trim($buffer));
872
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
872
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
873 873
 			    $ACARS->deleteLiveAcarsData();
874 874
 			} elseif ($format == 'flightgearmp') {
875
-			    if (substr($buffer,0,1) != '#') {
875
+			    if (substr($buffer, 0, 1) != '#') {
876 876
 				$data = array();
877 877
 				//echo $buffer."\n";
878
-				$line = explode(' ',$buffer);
878
+				$line = explode(' ', $buffer);
879 879
 				if (count($line) == 11) {
880
-				    $userserver = explode('@',$line[0]);
881
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
880
+				    $userserver = explode('@', $line[0]);
881
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
882 882
 				    $data['ident'] = $userserver[0];
883 883
 				    $data['registration'] = $userserver[0];
884 884
 				    $data['latitude'] = $line[4];
@@ -886,24 +886,24 @@  discard block
 block discarded – undo
886 886
 				    $data['altitude'] = $line[6];
887 887
 				    $data['datetime'] = date('Y-m-d H:i:s');
888 888
 				    $aircraft_type = $line[10];
889
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
890
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
889
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
890
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
891 891
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
892 892
 				}
893 893
 			    }
894 894
 			} elseif ($format == 'beast') {
895 895
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
896 896
 			    die;
897
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
897
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
898 898
 			    $line = explode("\t", $buffer);
899
-			    for($k = 0; $k < count($line); $k=$k+2) {
899
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
900 900
 				$key = $line[$k];
901
-			        $lined[$key] = $line[$k+1];
901
+			        $lined[$key] = $line[$k + 1];
902 902
 			    }
903 903
     			    if (count($lined) > 3) {
904 904
     				$data['hex'] = $lined['hexid'];
905 905
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
906
-    				$data['datetime'] = date('Y-m-d H:i:s');;
906
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
907 907
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
908 908
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
909 909
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -921,24 +921,24 @@  discard block
 block discarded – undo
921 921
     			    } else $error = true;
922 922
 			} elseif ($format == 'aprs' && $use_aprs) {
923 923
 			    if ($aprs_connect == 0) {
924
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
924
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
925 925
 				$aprs_connect = 1;
926 926
 			    }
927
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
927
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
928 928
 				$aprs_last_tx = time();
929 929
 				$data_aprs = "# Keep alive";
930
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
930
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
931 931
 			    }
932 932
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
933
-			    $buffer = str_replace('APRS <- ','',$buffer);
934
-			    $buffer = str_replace('APRS -> ','',$buffer);
935
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
933
+			    $buffer = str_replace('APRS <- ', '', $buffer);
934
+			    $buffer = str_replace('APRS -> ', '', $buffer);
935
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
936 936
 				$line = $APRS->parse($buffer);
937 937
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
938 938
 				    $data = array();
939 939
 				    //print_r($line);
940 940
 				    $data['hex'] = $line['address'];
941
-				    $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
941
+				    $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
942 942
 				    //$data['datetime'] = date('Y-m-d H:i:s');
943 943
 				    $data['ident'] = $line['ident'];
944 944
 				    $data['latitude'] = $line['latitude'];
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
 				    $currentdate = date('Y-m-d H:i:s');
959 959
 				    $aprsdate = strtotime($data['datetime']);
960 960
 				    // Accept data if time <= system time + 20s
961
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
961
+				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
962 962
 				    else {
963 963
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
964 964
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 				connect_all($sourceee);
1045 1045
 				$sourceee = array();
1046 1046
 				//connect_all($globalSources);
1047
-				$tt[$format]=0;
1047
+				$tt[$format] = 0;
1048 1048
 				break;
1049 1049
 			    }
1050 1050
 			}
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
 		}
1053 1053
 	    } else {
1054 1054
 		$error = socket_strerror(socket_last_error());
1055
-		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1055
+		if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1056 1056
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1057 1057
 			if (isset($globalDebug)) echo "Restarting...\n";
1058 1058
 			// Restart the script if possible
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
 			    if ($globalDebug) echo "Shutdown all sockets...";
1061 1061
 			    
1062 1062
 			    foreach ($sockets as $sock) {
1063
-				@socket_shutdown($sock,2);
1063
+				@socket_shutdown($sock, 2);
1064 1064
 				@socket_close($sock);
1065 1065
 			    }
1066 1066
 			    
Please login to merge, or discard this patch.
Braces   +544 added lines, -186 removed lines patch added patch discarded remove patch
@@ -14,7 +14,9 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16 16
 
17
-if (!isset($globalDebug)) $globalDebug = FALSE;
17
+if (!isset($globalDebug)) {
18
+	$globalDebug = FALSE;
19
+}
18 20
 
19 21
 // Check if schema is at latest version
20 22
 $Connection = new Connection();
@@ -54,13 +56,22 @@  discard block
 block discarded – undo
54 56
     $globalSources = array();
55 57
     $globalSources[] = array('host' => $options['source']);
56 58
 }
57
-if (isset($options['server'])) $globalServer = TRUE;
58
-if (isset($options['idsource'])) $id_source = $options['idsource'];
59
-else $id_source = 1;
59
+if (isset($options['server'])) {
60
+	$globalServer = TRUE;
61
+}
62
+if (isset($options['idsource'])) {
63
+	$id_source = $options['idsource'];
64
+} else {
65
+	$id_source = 1;
66
+}
60 67
 if (isset($globalServer) && $globalServer) {
61
-    if ($globalDebug) echo "Using Server Mode\n";
68
+    if ($globalDebug) {
69
+    	echo "Using Server Mode\n";
70
+    }
62 71
     $SI=new SpotterServer();
63
-} else $SI=new SpotterImport($Connection->db);
72
+} else {
73
+	$SI=new SpotterImport($Connection->db);
74
+}
64 75
 //$APRS=new APRS($Connection->db);
65 76
 $SBS=new SBS();
66 77
 $ACARS=new ACARS($Connection->db);
@@ -78,7 +89,9 @@  discard block
 block discarded – undo
78 89
 }
79 90
 
80 91
 // let's try and connect
81
-if ($globalDebug) echo "Connecting...\n";
92
+if ($globalDebug) {
93
+	echo "Connecting...\n";
94
+}
82 95
 $use_aprs = false;
83 96
 $aprs_full = false;
84 97
 $reset = 0;
@@ -87,7 +100,9 @@  discard block
 block discarded – undo
87 100
     $ip = gethostbyname($host);
88 101
     $s = socket_create(AF_INET, SOCK_STREAM, 0);
89 102
     $r = @socket_connect($s, $ip, $port);
90
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
103
+    if (!socket_set_nonblock($s)) {
104
+    	echo "Unable to set nonblock on socket\n";
105
+    }
91 106
     if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
92 107
         return $s;
93 108
     }
@@ -115,7 +130,9 @@  discard block
 block discarded – undo
115 130
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116 131
     global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
117 132
     $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
133
+    if ($globalDebug) {
134
+    	echo 'Connect to all...'."\n";
135
+    }
119 136
     foreach ($hosts as $id => $value) {
120 137
 	$host = $value['host'];
121 138
 	$globalSources[$id]['last_exec'] = 0;
@@ -125,27 +142,37 @@  discard block
 block discarded – undo
125 142
         	//$formats[$id] = 'deltadbtxt';
126 143
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 144
         	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
145
+        	if ($globalDebug) {
146
+        		echo "Connect to deltadb source (".$host.")...\n";
147
+        	}
129 148
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130 149
         	//$formats[$id] = 'vatsimtxt';
131 150
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 151
         	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
152
+        	if ($globalDebug) {
153
+        		echo "Connect to vatsim source (".$host.")...\n";
154
+        	}
134 155
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135 156
         	//$formats[$id] = 'aircraftlistjson';
136 157
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 158
         	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
159
+        	if ($globalDebug) {
160
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
161
+        	}
139 162
     	    } else if (preg_match('/opensky/i',$host)) {
140 163
         	//$formats[$id] = 'aircraftlistjson';
141 164
         	$globalSources[$id]['format'] = 'opensky';
142 165
         	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
166
+        	if ($globalDebug) {
167
+        		echo "Connect to opensky source (".$host.")...\n";
168
+        	}
144 169
     	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
145 170
         	//$formats[$id] = 'radarvirtueljson';
146 171
         	$globalSources[$id]['format'] = 'radarvirtueljson';
147 172
         	//$last_exec['radarvirtueljson'] = 0;
148
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
173
+        	if ($globalDebug) {
174
+        		echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
175
+        	}
149 176
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
150 177
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151 178
         	    exit(0);
@@ -154,7 +181,9 @@  discard block
 block discarded – undo
154 181
         	//$formats[$id] = 'planeupdatefaa';
155 182
         	$globalSources[$id]['format'] = 'planeupdatefaa';
156 183
         	//$last_exec['planeupdatefaa'] = 0;
157
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
184
+        	if ($globalDebug) {
185
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
186
+        	}
158 187
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
159 188
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160 189
         	    exit(0);
@@ -163,26 +192,36 @@  discard block
 block discarded – undo
163 192
         	//$formats[$id] = 'phpvmacars';
164 193
         	$globalSources[$id]['format'] = 'phpvmacars';
165 194
         	//$last_exec['phpvmacars'] = 0;
166
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
195
+        	if ($globalDebug) {
196
+        		echo "Connect to phpvmacars source (".$host.")...\n";
197
+        	}
167 198
             } else if (preg_match('/VAM-json.php$/i',$host)) {
168 199
         	//$formats[$id] = 'phpvmacars';
169 200
         	$globalSources[$id]['format'] = 'vam';
170
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
201
+        	if ($globalDebug) {
202
+        		echo "Connect to Vam source (".$host.")...\n";
203
+        	}
171 204
             } else if (preg_match('/whazzup/i',$host)) {
172 205
         	//$formats[$id] = 'whazzup';
173 206
         	$globalSources[$id]['format'] = 'whazzup';
174 207
         	//$last_exec['whazzup'] = 0;
175
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
208
+        	if ($globalDebug) {
209
+        		echo "Connect to whazzup source (".$host.")...\n";
210
+        	}
176 211
             } else if (preg_match('/recentpireps/i',$host)) {
177 212
         	//$formats[$id] = 'pirepsjson';
178 213
         	$globalSources[$id]['format'] = 'pirepsjson';
179 214
         	//$last_exec['pirepsjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
215
+        	if ($globalDebug) {
216
+        		echo "Connect to pirepsjson source (".$host.")...\n";
217
+        	}
181 218
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182 219
         	//$formats[$id] = 'fr24json';
183 220
         	$globalSources[$id]['format'] = 'fr24json';
184 221
         	//$last_exec['fr24json'] = 0;
185
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
222
+        	if ($globalDebug) {
223
+        		echo "Connect to fr24 source (".$host.")...\n";
224
+        	}
186 225
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
187 226
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
188 227
         	    exit(0);
@@ -191,10 +230,14 @@  discard block
 block discarded – undo
191 230
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192 231
         	//$formats[$id] = 'tsv';
193 232
         	$globalSources[$id]['format'] = 'tsv';
194
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
233
+        	if ($globalDebug) {
234
+        		echo "Connect to tsv source (".$host.")...\n";
235
+        	}
195 236
             }
196 237
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
197
-        	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
238
+        	if ($globalDebug) {
239
+        		echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
240
+        	}
198 241
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199 242
 	    $hostport = explode(':',$host);
200 243
 	    if (isset($hostport[1])) {
@@ -231,17 +274,25 @@  discard block
 block discarded – undo
231 274
         		//$formats[$id] = 'beast';
232 275
         		$globalSources[$id]['format'] = 'beast';
233 276
 		    //} else $formats[$id] = 'sbs';
234
-		    } else $globalSources[$id]['format'] = 'sbs';
277
+		    } else {
278
+		    	$globalSources[$id]['format'] = 'sbs';
279
+		    }
235 280
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
236 281
 		}
237
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
282
+		if ($globalDebug) {
283
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
284
+		}
238 285
             } else {
239
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
286
+		if ($globalDebug) {
287
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
288
+		}
240 289
     	    }
241 290
         }
242 291
     }
243 292
 }
244
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
293
+if (!isset($globalMinFetch)) {
294
+	$globalMinFetch = 15;
295
+}
245 296
 
246 297
 // Initialize all
247 298
 $status = array();
@@ -249,13 +300,19 @@  discard block
 block discarded – undo
249 300
 $formats = array();
250 301
 $last_exec = array();
251 302
 $time = time();
252
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
253
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
254
-else $timeout = 20;
303
+if (isset($globalSourcesTimeout)) {
304
+	$timeout = $globalSourcesTimeOut;
305
+} else if (isset($globalSBS1TimeOut)) {
306
+	$timeout = $globalSBS1TimeOut;
307
+} else {
308
+	$timeout = 20;
309
+}
255 310
 $errno = '';
256 311
 $errstr='';
257 312
 
258
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
313
+if (!isset($globalDaemon)) {
314
+	$globalDaemon = TRUE;
315
+}
259 316
 /* Initiate connections to all the hosts simultaneously */
260 317
 //connect_all($hosts);
261 318
 //connect_all($globalSources);
@@ -275,7 +332,9 @@  discard block
 block discarded – undo
275 332
     if (isset($source['format']) && $source['format'] == 'aprs') {
276 333
 	$aprs_connect = 0;
277 334
 	$use_aprs = true;
278
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
335
+	if (isset($source['port']) && $source['port'] == '10152') {
336
+		$aprs_full = true;
337
+	}
279 338
 	break;
280 339
     }
281 340
 }
@@ -286,24 +345,44 @@  discard block
 block discarded – undo
286 345
 	$aprs_connect = 0;
287 346
 	$aprs_keep = 120;
288 347
 	$aprs_last_tx = time();
289
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
290
-	else $aprs_version = $globalName.' using FlightAirMap';
348
+	if (isset($globalAPRSversion)) {
349
+		$aprs_version = $globalAPRSversion;
350
+	} else {
351
+		$aprs_version = $globalName.' using FlightAirMap';
352
+	}
291 353
 	//else $aprs_version = 'Perl Example App';
292
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
293
-	else $aprs_ssid = 'FAM';
354
+	if (isset($globalAPRSssid)) {
355
+		$aprs_ssid = $globalAPRSssid;
356
+	} else {
357
+		$aprs_ssid = 'FAM';
358
+	}
294 359
 	//else $aprs_ssid = 'PerlEx';
295
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
296
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
297
-	if ($aprs_full) $aprs_filter = '';
298
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n";
299
-	else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n";
300
-}
360
+	if (isset($globalAPRSfilter)) {
361
+		$aprs_filter = $globalAPRSfilter;
362
+	} else {
363
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
364
+	}
365
+	if ($aprs_full) {
366
+		$aprs_filter = '';
367
+	}
368
+	if ($aprs_filter != '') {
369
+		$aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n";
370
+	} else {
371
+		$aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n";
372
+	}
373
+	}
301 374
 
302 375
 // connected - lets do some work
303
-if ($globalDebug) echo "Connected!\n";
376
+if ($globalDebug) {
377
+	echo "Connected!\n";
378
+}
304 379
 sleep(1);
305
-if ($globalDebug) echo "SCAN MODE \n\n";
306
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
380
+if ($globalDebug) {
381
+	echo "SCAN MODE \n\n";
382
+}
383
+if (!isset($globalCronEnd)) {
384
+	$globalCronEnd = 60;
385
+}
307 386
 $endtime = time()+$globalCronEnd;
308 387
 $i = 1;
309 388
 $tt = array();
@@ -317,20 +396,28 @@  discard block
 block discarded – undo
317 396
 
318 397
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
319 398
 while ($i > 0) {
320
-    if (!$globalDaemon) $i = $endtime-time();
399
+    if (!$globalDaemon) {
400
+    	$i = $endtime-time();
401
+    }
321 402
     // Delete old ATC
322 403
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
323
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
404
+	if ($globalDebug) {
405
+		echo 'Delete old ATC...'."\n";
406
+	}
324 407
         $ATC->deleteOldATC();
325 408
     }
326 409
     
327 410
     if (count($last_exec) > 0) {
328 411
 	$max = $globalMinFetch;
329 412
 	foreach ($last_exec as $last) {
330
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
413
+	    if ((time() - $last['last']) < $max) {
414
+	    	$max = time() - $last['last'];
415
+	    }
331 416
 	}
332 417
 	if ($max != $globalMinFetch) {
333
-	    if ($globalDebug) echo 'Sleeping...'."\n";
418
+	    if ($globalDebug) {
419
+	    	echo 'Sleeping...'."\n";
420
+	    }
334 421
 	    sleep($globalMinFetch-$max+2);
335 422
 	}
336 423
     }
@@ -338,11 +425,15 @@  discard block
 block discarded – undo
338 425
     
339 426
     //foreach ($formats as $id => $value) {
340 427
     foreach ($globalSources as $id => $value) {
341
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
428
+	if (!isset($last_exec[$id]['last'])) {
429
+		$last_exec[$id]['last'] = 0;
430
+	}
342 431
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
343 432
 	    //$buffer = $Common->getData($hosts[$id]);
344 433
 	    $buffer = $Common->getData($value['host']);
345
-	    if ($buffer != '') $reset = 0;
434
+	    if ($buffer != '') {
435
+	    	$reset = 0;
436
+	    }
346 437
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347 438
 	    $buffer = explode('\n',$buffer);
348 439
 	    foreach ($buffer as $line) {
@@ -351,19 +442,38 @@  discard block
 block discarded – undo
351 442
 	            $data = array();
352 443
 	            $data['hex'] = $line[1]; // hex
353 444
 	            $data['ident'] = $line[2]; // ident
354
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
355
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
356
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
357
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
358
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
445
+	            if (isset($line[3])) {
446
+	            	$data['altitude'] = $line[3];
447
+	            }
448
+	            // altitude
449
+	            if (isset($line[4])) {
450
+	            	$data['speed'] = $line[4];
451
+	            }
452
+	            // speed
453
+	            if (isset($line[5])) {
454
+	            	$data['heading'] = $line[5];
455
+	            }
456
+	            // heading
457
+	            if (isset($line[6])) {
458
+	            	$data['latitude'] = $line[6];
459
+	            }
460
+	            // lat
461
+	            if (isset($line[7])) {
462
+	            	$data['longitude'] = $line[7];
463
+	            }
464
+	            // long
359 465
 	            $data['verticalrate'] = ''; // vertical rate
360 466
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
361 467
 	            $data['emergency'] = ''; // emergency
362 468
 		    $data['datetime'] = date('Y-m-d H:i:s');
363 469
 		    $data['format_source'] = 'deltadbtxt';
364 470
     		    $data['id_source'] = $id_source;
365
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
366
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
471
+		    if (isset($value['name']) && $value['name'] != '') {
472
+		    	$data['source_name'] = $value['name'];
473
+		    }
474
+		    if (isset($value['sourcestats'])) {
475
+		    	$data['sourcestats'] = $value['sourcestats'];
476
+		    }
367 477
     		    $SI->add($data);
368 478
 		    unset($data);
369 479
     		}
@@ -386,10 +496,19 @@  discard block
 block discarded – undo
386 496
 			$data['pilot_name'] = $line[2];
387 497
 			$data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT);
388 498
 			$data['ident'] = $line[0]; // ident
389
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
499
+			if ($line[7] != '' && $line[7] != 0) {
500
+				$data['altitude'] = $line[7];
501
+			}
502
+			// altitude
390 503
 			$data['speed'] = $line[8]; // speed
391
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
392
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
504
+			if (isset($line[45])) {
505
+				$data['heading'] = $line[45];
506
+			}
507
+			// heading
508
+			elseif (isset($line[38])) {
509
+				$data['heading'] = $line[38];
510
+			}
511
+			// heading
393 512
 			$data['latitude'] = $line[5]; // lat
394 513
 	        	$data['longitude'] = $line[6]; // long
395 514
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -398,14 +517,18 @@  discard block
 block discarded – undo
398 517
 	        	$data['waypoints'] = $line[30];
399 518
 			$data['datetime'] = date('Y-m-d H:i:s');
400 519
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
401
-			if (isset($line[37])) $data['last_update'] = $line[37];
520
+			if (isset($line[37])) {
521
+				$data['last_update'] = $line[37];
522
+			}
402 523
 		        $data['departure_airport_icao'] = $line[11];
403 524
 		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
404 525
 		        $data['arrival_airport_icao'] = $line[13];
405 526
 			$data['frequency'] = $line[4];
406 527
 			$data['type'] = $line[18];
407 528
 			$data['range'] = $line[19];
408
-			if (isset($line[35])) $data['info'] = $line[35];
529
+			if (isset($line[35])) {
530
+				$data['info'] = $line[35];
531
+			}
409 532
     			$data['id_source'] = $id_source;
410 533
 	    		//$data['arrival_airport_time'] = ;
411 534
 	    		if ($line[9] != '') {
@@ -419,23 +542,38 @@  discard block
 block discarded – undo
419 542
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
420 543
 	    		*/
421 544
 	    		$data['format_source'] = $value['format'];
422
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
423
-    			if ($line[3] == 'PILOT') $SI->add($data);
424
-			elseif ($line[3] == 'ATC') {
545
+			if (isset($value['name']) && $value['name'] != '') {
546
+				$data['source_name'] = $value['name'];
547
+			}
548
+    			if ($line[3] == 'PILOT') {
549
+    				$SI->add($data);
550
+    			} elseif ($line[3] == 'ATC') {
425 551
 				//print_r($data);
426 552
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
427 553
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
428 554
 				$typec = substr($data['ident'],-3);
429
-				if ($typec == 'APP') $data['type'] = 'Approach';
430
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
431
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
432
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
433
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
434
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
435
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
436
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
437
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
438
-				if (!isset($data['source_name'])) $data['source_name'] = '';
555
+				if ($typec == 'APP') {
556
+					$data['type'] = 'Approach';
557
+				} elseif ($typec == 'TWR') {
558
+					$data['type'] = 'Tower';
559
+				} elseif ($typec == 'OBS') {
560
+					$data['type'] = 'Observer';
561
+				} elseif ($typec == 'GND') {
562
+					$data['type'] = 'Ground';
563
+				} elseif ($typec == 'DEL') {
564
+					$data['type'] = 'Delivery';
565
+				} elseif ($typec == 'DEP') {
566
+					$data['type'] = 'Departure';
567
+				} elseif ($typec == 'FSS') {
568
+					$data['type'] = 'Flight Service Station';
569
+				} elseif ($typec == 'CTR') {
570
+					$data['type'] = 'Control Radar or Centre';
571
+				} elseif ($data['type'] == '') {
572
+					$data['type'] = 'Observer';
573
+				}
574
+				if (!isset($data['source_name'])) {
575
+					$data['source_name'] = '';
576
+				}
439 577
 				echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
440 578
 			}
441 579
     			unset($data);
@@ -455,26 +593,55 @@  discard block
 block discarded – undo
455 593
 		foreach ($all_data['acList'] as $line) {
456 594
 		    $data = array();
457 595
 		    $data['hex'] = $line['Icao']; // hex
458
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
459
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
460
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
461
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
462
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
463
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
596
+		    if (isset($line['Call'])) {
597
+		    	$data['ident'] = $line['Call'];
598
+		    }
599
+		    // ident
600
+		    if (isset($line['Alt'])) {
601
+		    	$data['altitude'] = $line['Alt'];
602
+		    }
603
+		    // altitude
604
+		    if (isset($line['Spd'])) {
605
+		    	$data['speed'] = $line['Spd'];
606
+		    }
607
+		    // speed
608
+		    if (isset($line['Trak'])) {
609
+		    	$data['heading'] = $line['Trak'];
610
+		    }
611
+		    // heading
612
+		    if (isset($line['Lat'])) {
613
+		    	$data['latitude'] = $line['Lat'];
614
+		    }
615
+		    // lat
616
+		    if (isset($line['Long'])) {
617
+		    	$data['longitude'] = $line['Long'];
618
+		    }
619
+		    // long
464 620
 		    //$data['verticalrate'] = $line['']; // verticale rate
465
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
621
+		    if (isset($line['Sqk'])) {
622
+		    	$data['squawk'] = $line['Sqk'];
623
+		    }
624
+		    // squawk
466 625
 		    $data['emergency'] = ''; // emergency
467
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
626
+		    if (isset($line['Reg'])) {
627
+		    	$data['registration'] = $line['Reg'];
628
+		    }
468 629
 		    /*
469 630
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
470 631
 		    else $data['datetime'] = date('Y-m-d H:i:s');
471 632
 		    */
472 633
 		    $data['datetime'] = date('Y-m-d H:i:s');
473
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
634
+		    if (isset($line['Type'])) {
635
+		    	$data['aircraft_icao'] = $line['Type'];
636
+		    }
474 637
 	    	    $data['format_source'] = 'aircraftlistjson';
475 638
 		    $data['id_source'] = $id_source;
476
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
477
-		    if (isset($data['datetime'])) $SI->add($data);
639
+		    if (isset($value['name']) && $value['name'] != '') {
640
+		    	$data['source_name'] = $value['name'];
641
+		    }
642
+		    if (isset($data['datetime'])) {
643
+		    	$SI->add($data);
644
+		    }
478 645
 		    unset($data);
479 646
 		}
480 647
 	    } else {
@@ -494,7 +661,9 @@  discard block
 block discarded – undo
494 661
 		    $data['datetime'] = date('Y-m-d H:i:s');
495 662
 	    	    $data['format_source'] = 'aircraftlistjson';
496 663
     		    $data['id_source'] = $id_source;
497
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
664
+		    if (isset($value['name']) && $value['name'] != '') {
665
+		    	$data['source_name'] = $value['name'];
666
+		    }
498 667
 		    $SI->add($data);
499 668
 		    unset($data);
500 669
 		}
@@ -530,7 +699,9 @@  discard block
 block discarded – undo
530 699
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
531 700
 	    	    $data['format_source'] = 'planeupdatefaa';
532 701
     		    $data['id_source'] = $id_source;
533
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
702
+		    if (isset($value['name']) && $value['name'] != '') {
703
+		    	$data['source_name'] = $value['name'];
704
+		    }
534 705
 		    $SI->add($data);
535 706
 		    unset($data);
536 707
 		}
@@ -570,7 +741,9 @@  discard block
 block discarded – undo
570 741
 	    //$buffer = $Common->getData($hosts[$id]);
571 742
 	    $buffer = $Common->getData($value['host']);
572 743
 	    $all_data = json_decode($buffer,true);
573
-	    if (!empty($all_data)) $reset = 0;
744
+	    if (!empty($all_data)) {
745
+	    	$reset = 0;
746
+	    }
574 747
 	    foreach ($all_data as $key => $line) {
575 748
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
576 749
 		    $data = array();
@@ -591,7 +764,9 @@  discard block
 block discarded – undo
591 764
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
592 765
 	    	    $data['format_source'] = 'fr24json';
593 766
     		    $data['id_source'] = $id_source;
594
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
767
+		    if (isset($value['name']) && $value['name'] != '') {
768
+		    	$data['source_name'] = $value['name'];
769
+		    }
595 770
 		    $SI->add($data);
596 771
 		    unset($data);
597 772
 		}
@@ -615,23 +790,39 @@  discard block
 block discarded – undo
615 790
 		    if (isset($line['inf'])) {
616 791
 			$data = array();
617 792
 			$data['hex'] = $line['inf']['ia'];
618
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
793
+			if (isset($line['inf']['cs'])) {
794
+				$data['ident'] = $line['inf']['cs'];
795
+			}
796
+			//$line[13]
619 797
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
620
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
621
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
798
+	    		if (isset($line['inf']['gs'])) {
799
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
800
+	    		}
801
+	    		// speed
802
+	    		if (isset($line['inf']['tr'])) {
803
+	    			$data['heading'] = $line['inf']['tr'];
804
+	    		}
805
+	    		// heading
622 806
 	    		$data['latitude'] = $line['pt'][0]; // lat
623 807
 	    		$data['longitude'] = $line['pt'][1]; // long
624 808
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
625
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
809
+	    		if (isset($line['inf']['sq'])) {
810
+	    			$data['squawk'] = $line['inf']['sq'];
811
+	    		}
812
+	    		// squawk
626 813
 	    		//$data['aircraft_icao'] = $line[8];
627
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
814
+	    		if (isset($line['inf']['rc'])) {
815
+	    			$data['registration'] = $line['inf']['rc'];
816
+	    		}
628 817
 			//$data['departure_airport_iata'] = $line[11];
629 818
 			//$data['arrival_airport_iata'] = $line[12];
630 819
 	    		//$data['emergency'] = ''; // emergency
631 820
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
632 821
 	    		$data['format_source'] = 'radarvirtueljson';
633 822
     			$data['id_source'] = $id_source;
634
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
823
+			if (isset($value['name']) && $value['name'] != '') {
824
+				$data['source_name'] = $value['name'];
825
+			}
635 826
 			$SI->add($data);
636 827
 			unset($data);
637 828
 		    }
@@ -652,29 +843,62 @@  discard block
 block discarded – undo
652 843
 		    $data['id'] = $line['id'];
653 844
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
654 845
 		    $data['ident'] = $line['callsign']; // ident
655
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
656
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
657
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
658
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
659
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
660
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
846
+		    if (isset($line['pilotid'])) {
847
+		    	$data['pilot_id'] = $line['pilotid'];
848
+		    }
849
+		    // pilot id
850
+		    if (isset($line['name'])) {
851
+		    	$data['pilot_name'] = $line['name'];
852
+		    }
853
+		    // pilot name
854
+		    if (isset($line['alt'])) {
855
+		    	$data['altitude'] = $line['alt'];
856
+		    }
857
+		    // altitude
858
+		    if (isset($line['gs'])) {
859
+		    	$data['speed'] = $line['gs'];
860
+		    }
861
+		    // speed
862
+		    if (isset($line['heading'])) {
863
+		    	$data['heading'] = $line['heading'];
864
+		    }
865
+		    // heading
866
+		    if (isset($line['route'])) {
867
+		    	$data['waypoints'] = $line['route'];
868
+		    }
869
+		    // route
661 870
 		    $data['latitude'] = $line['lat']; // lat
662 871
 		    $data['longitude'] = $line['lon']; // long
663 872
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
664 873
 		    //$data['squawk'] = $line['squawk']; // squawk
665 874
 		    //$data['emergency'] = ''; // emergency
666
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
667
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
668
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
875
+		    if (isset($line['depicao'])) {
876
+		    	$data['departure_airport_icao'] = $line['depicao'];
877
+		    }
878
+		    if (isset($line['deptime'])) {
879
+		    	$data['departure_airport_time'] = $line['deptime'];
880
+		    }
881
+		    if (isset($line['arricao'])) {
882
+		    	$data['arrival_airport_icao'] = $line['arricao'];
883
+		    }
669 884
 		    //$data['arrival_airport_time'] = $line['arrtime'];
670
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
671
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
672
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
673
-		    else $data['info'] = '';
885
+		    if (isset($line['aircraft'])) {
886
+		    	$data['aircraft_icao'] = $line['aircraft'];
887
+		    }
888
+		    if (isset($line['transponder'])) {
889
+		    	$data['squawk'] = $line['transponder'];
890
+		    }
891
+		    if (isset($line['atis'])) {
892
+		    	$data['info'] = $line['atis'];
893
+		    } else {
894
+		    	$data['info'] = '';
895
+		    }
674 896
 		    $data['format_source'] = 'pireps';
675 897
     		    $data['id_source'] = $id_source;
676 898
 		    $data['datetime'] = date('Y-m-d H:i:s');
677
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
899
+		    if (isset($value['name']) && $value['name'] != '') {
900
+		    	$data['source_name'] = $value['name'];
901
+		    }
678 902
 		    if ($line['icon'] == 'plane') {
679 903
 			$SI->add($data);
680 904
 		    //    print_r($data);
@@ -683,15 +907,25 @@  discard block
 block discarded – undo
683 907
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
684 908
 			$typec = substr($data['ident'],-3);
685 909
 			$data['type'] = '';
686
-			if ($typec == 'APP') $data['type'] = 'Approach';
687
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
688
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
689
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
690
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
691
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
692
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
693
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
694
-			else $data['type'] = 'Observer';
910
+			if ($typec == 'APP') {
911
+				$data['type'] = 'Approach';
912
+			} elseif ($typec == 'TWR') {
913
+				$data['type'] = 'Tower';
914
+			} elseif ($typec == 'OBS') {
915
+				$data['type'] = 'Observer';
916
+			} elseif ($typec == 'GND') {
917
+				$data['type'] = 'Ground';
918
+			} elseif ($typec == 'DEL') {
919
+				$data['type'] = 'Delivery';
920
+			} elseif ($typec == 'DEP') {
921
+				$data['type'] = 'Departure';
922
+			} elseif ($typec == 'FSS') {
923
+				$data['type'] = 'Flight Service Station';
924
+			} elseif ($typec == 'CTR') {
925
+				$data['type'] = 'Control Radar or Centre';
926
+			} else {
927
+				$data['type'] = 'Observer';
928
+			}
695 929
 			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
696 930
 		    }
697 931
 		    unset($data);
@@ -702,7 +936,9 @@  discard block
 block discarded – undo
702 936
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
703 937
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
704 938
 	    //$buffer = $Common->getData($hosts[$id]);
705
-	    if ($globalDebug) echo 'Get Data...'."\n";
939
+	    if ($globalDebug) {
940
+	    	echo 'Get Data...'."\n";
941
+	    }
706 942
 	    $buffer = $Common->getData($value['host']);
707 943
 	    $all_data = json_decode($buffer,true);
708 944
 	    if ($buffer != '' && is_array($all_data)) {
@@ -710,10 +946,16 @@  discard block
 block discarded – undo
710 946
 		foreach ($all_data as $line) {
711 947
 	    	    $data = array();
712 948
 	    	    //$data['id'] = $line['id']; // id not usable
713
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
949
+	    	    if (isset($line['pilotid'])) {
950
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
951
+	    	    }
714 952
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
715
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
716
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
953
+	    	    if (isset($line['pilotname'])) {
954
+	    	    	$data['pilot_name'] = $line['pilotname'];
955
+	    	    }
956
+	    	    if (isset($line['pilotid'])) {
957
+	    	    	$data['pilot_id'] = $line['pilotid'];
958
+	    	    }
717 959
 	    	    $data['ident'] = $line['flightnum']; // ident
718 960
 	    	    $data['altitude'] = $line['alt']; // altitude
719 961
 	    	    $data['speed'] = $line['gs']; // speed
@@ -731,27 +973,41 @@  discard block
 block discarded – undo
731 973
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
732 974
     		    $data['arrival_airport_time'] = $line['arrtime'];
733 975
     		    $data['registration'] = $line['aircraft'];
734
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
976
+		    if (isset($line['route'])) {
977
+		    	$data['waypoints'] = $line['route'];
978
+		    }
979
+		    // route
735 980
 		    if (isset($line['aircraftname'])) {
736 981
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
737 982
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
738 983
 	    		$aircraft_data = explode('-',$line['aircraftname']);
739
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
740
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
741
-	    		else {
984
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) {
985
+	    			$data['aircraft_icao'] = $aircraft_data[0];
986
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) {
987
+	    			$data['aircraft_icao'] = $aircraft_data[1];
988
+	    		} else {
742 989
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
743
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
744
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
990
+	    		    if (isset($aircraft_data[1])) {
991
+	    		    	$data['aircraft_icao'] = $aircraft_data[1];
992
+	    		    } else {
993
+	    		    	$data['aircraft_icao'] = $line['aircraftname'];
994
+	    		    }
745 995
 	    		}
746 996
 	    	    }
747
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
997
+    		    if (isset($line['route'])) {
998
+    		    	$data['waypoints'] = $line['route'];
999
+    		    }
748 1000
     		    $data['id_source'] = $id_source;
749 1001
 	    	    $data['format_source'] = 'phpvmacars';
750
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1002
+		    if (isset($value['name']) && $value['name'] != '') {
1003
+		    	$data['source_name'] = $value['name'];
1004
+		    }
751 1005
 		    $SI->add($data);
752 1006
 		    unset($data);
753 1007
 		}
754
-		if ($globalDebug) echo 'No more data...'."\n";
1008
+		if ($globalDebug) {
1009
+			echo 'No more data...'."\n";
1010
+		}
755 1011
 		unset($buffer);
756 1012
 		unset($all_data);
757 1013
 	    }
@@ -759,7 +1015,9 @@  discard block
 block discarded – undo
759 1015
     	    $last_exec[$id]['last'] = time();
760 1016
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
761 1017
 	    //$buffer = $Common->getData($hosts[$id]);
762
-	    if ($globalDebug) echo 'Get Data...'."\n";
1018
+	    if ($globalDebug) {
1019
+	    	echo 'Get Data...'."\n";
1020
+	    }
763 1021
 	    $buffer = $Common->getData($value['host']);
764 1022
 	    $all_data = json_decode($buffer,true);
765 1023
 	    if ($buffer != '' && is_array($all_data)) {
@@ -788,15 +1046,22 @@  discard block
 block discarded – undo
788 1046
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
789 1047
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
790 1048
     		    //$data['registration'] = $line['aircraft'];
791
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1049
+		    if (isset($line['route'])) {
1050
+		    	$data['waypoints'] = $line['route'];
1051
+		    }
1052
+		    // route
792 1053
 	    	    $data['aircraft_icao'] = $line['plane_type'];
793 1054
     		    $data['id_source'] = $id_source;
794 1055
 	    	    $data['format_source'] = 'vam';
795
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1056
+		    if (isset($value['name']) && $value['name'] != '') {
1057
+		    	$data['source_name'] = $value['name'];
1058
+		    }
796 1059
 		    $SI->add($data);
797 1060
 		    unset($data);
798 1061
 		}
799
-		if ($globalDebug) echo 'No more data...'."\n";
1062
+		if ($globalDebug) {
1063
+			echo 'No more data...'."\n";
1064
+		}
800 1065
 		unset($buffer);
801 1066
 		unset($all_data);
802 1067
 	    }
@@ -804,7 +1069,9 @@  discard block
 block discarded – undo
804 1069
     	    $last_exec[$id]['last'] = time();
805 1070
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
806 1071
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3') {
807
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1072
+	    if (function_exists('pcntl_fork')) {
1073
+	    	pcntl_signal_dispatch();
1074
+	    }
808 1075
     	    //$last_exec[$id]['last'] = time();
809 1076
 
810 1077
 	    //$read = array( $sockets[$id] );
@@ -812,7 +1079,9 @@  discard block
 block discarded – undo
812 1079
 	    $write = NULL;
813 1080
 	    $e = NULL;
814 1081
 	    $n = socket_select($read, $write, $e, $timeout);
815
-	    if ($e != NULL) var_dump($e);
1082
+	    if ($e != NULL) {
1083
+	    	var_dump($e);
1084
+	    }
816 1085
 	    if ($n > 0) {
817 1086
 		$reset = 0;
818 1087
 		foreach ($read as $nb => $r) {
@@ -834,7 +1103,9 @@  discard block
 block discarded – undo
834 1103
 		    if ($buffer != '') {
835 1104
 			$tt[$format] = 0;
836 1105
 			if ($format == 'acarssbs3') {
837
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1106
+                    	    if ($globalDebug) {
1107
+                    	    	echo 'ACARS : '.$buffer."\n";
1108
+                    	    }
838 1109
 			    $ACARS->add(trim($buffer));
839 1110
 			    $ACARS->deleteLiveAcarsData();
840 1111
 			} elseif ($format == 'raw') {
@@ -843,9 +1114,15 @@  discard block
 block discarded – undo
843 1114
 			    if (is_array($data)) {
844 1115
 				$data['datetime'] = date('Y-m-d H:i:s');
845 1116
 				$data['format_source'] = 'raw';
846
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
847
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
848
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1117
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1118
+					$data['source_name'] = $globalSources[$nb]['name'];
1119
+				}
1120
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1121
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1122
+    				}
1123
+                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1124
+                                	$SI->add($data);
1125
+                                }
849 1126
                             }
850 1127
                         } elseif ($format == 'flightgearsp') {
851 1128
                     	    //echo $buffer."\n";
@@ -863,11 +1140,15 @@  discard block
 block discarded – undo
863 1140
 				$data['speed'] = round($line[5]*1.94384);
864 1141
 				$data['datetime'] = date('Y-m-d H:i:s');
865 1142
 				$data['format_source'] = 'flightgearsp';
866
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1143
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1144
+					$SI->add($data);
1145
+				}
867 1146
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
868 1147
 			    }
869 1148
                         } elseif ($format == 'acars') {
870
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1149
+                    	    if ($globalDebug) {
1150
+                    	    	echo 'ACARS : '.$buffer."\n";
1151
+                    	    }
871 1152
 			    $ACARS->add(trim($buffer));
872 1153
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
873 1154
 			    $ACARS->deleteLiveAcarsData();
@@ -888,7 +1169,9 @@  discard block
 block discarded – undo
888 1169
 				    $aircraft_type = $line[10];
889 1170
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
890 1171
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
891
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1172
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1173
+				    	$SI->add($data);
1174
+				    }
892 1175
 				}
893 1176
 			    }
894 1177
 			} elseif ($format == 'beast') {
@@ -904,21 +1187,43 @@  discard block
 block discarded – undo
904 1187
     				$data['hex'] = $lined['hexid'];
905 1188
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
906 1189
     				$data['datetime'] = date('Y-m-d H:i:s');;
907
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
908
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
909
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
910
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
911
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
912
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
913
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1190
+    				if (isset($lined['ident'])) {
1191
+    					$data['ident'] = $lined['ident'];
1192
+    				}
1193
+    				if (isset($lined['lat'])) {
1194
+    					$data['latitude'] = $lined['lat'];
1195
+    				}
1196
+    				if (isset($lined['lon'])) {
1197
+    					$data['longitude'] = $lined['lon'];
1198
+    				}
1199
+    				if (isset($lined['speed'])) {
1200
+    					$data['speed'] = $lined['speed'];
1201
+    				}
1202
+    				if (isset($lined['squawk'])) {
1203
+    					$data['squawk'] = $lined['squawk'];
1204
+    				}
1205
+    				if (isset($lined['alt'])) {
1206
+    					$data['altitude'] = $lined['alt'];
1207
+    				}
1208
+    				if (isset($lined['heading'])) {
1209
+    					$data['heading'] = $lined['heading'];
1210
+    				}
914 1211
     				$data['id_source'] = $id_source;
915 1212
     				$data['format_source'] = 'tsv';
916
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
917
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
918
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1213
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1214
+    					$data['source_name'] = $globalSources[$nb]['name'];
1215
+    				}
1216
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1217
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1218
+    				}
1219
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1220
+    					$SI->add($data);
1221
+    				}
919 1222
     				unset($lined);
920 1223
     				unset($data);
921
-    			    } else $error = true;
1224
+    			    } else {
1225
+    			    	$error = true;
1226
+    			    }
922 1227
 			} elseif ($format == 'aprs' && $use_aprs) {
923 1228
 			    if ($aprs_connect == 0) {
924 1229
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -944,29 +1249,44 @@  discard block
 block discarded – undo
944 1249
 				    $data['latitude'] = $line['latitude'];
945 1250
 				    $data['longitude'] = $line['longitude'];
946 1251
 				    //$data['verticalrate'] = $line[16];
947
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
948
-				    else $data['speed'] = 0;
1252
+				    if (isset($line['speed'])) {
1253
+				    	$data['speed'] = $line['speed'];
1254
+				    } else {
1255
+				    	$data['speed'] = 0;
1256
+				    }
949 1257
 				    $data['altitude'] = $line['altitude'];
950
-				    if (isset($line['course'])) $data['heading'] = $line['course'];
1258
+				    if (isset($line['course'])) {
1259
+				    	$data['heading'] = $line['course'];
1260
+				    }
951 1261
 				    //else $data['heading'] = 0;
952 1262
 				    $data['aircraft_type'] = $line['stealth'];
953
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1263
+				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) {
1264
+				    	$data['noarchive'] = true;
1265
+				    }
954 1266
     				    $data['id_source'] = $id_source;
955 1267
 				    $data['format_source'] = 'aprs';
956 1268
 				    $data['source_name'] = $line['source'];
957
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1269
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1270
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1271
+    				    }
958 1272
 				    $currentdate = date('Y-m-d H:i:s');
959 1273
 				    $aprsdate = strtotime($data['datetime']);
960 1274
 				    // Accept data if time <= system time + 20s
961
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
962
-				    else {
963
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
964
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1275
+				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1276
+				    	$send = $SI->add($data);
1277
+				    } else {
1278
+					if ($line['stealth'] != 0) {
1279
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1280
+					} else {
1281
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1282
+					}
965 1283
 				    }
966 1284
 				    unset($data);
967 1285
 				} 
968 1286
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
969
-				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1287
+				elseif ($line == true && $globalDebug) {
1288
+					echo '!! Failed : '.$buffer."!!\n";
1289
+				}
970 1290
 			    }
971 1291
 			} else {
972 1292
 			    $line = explode(',', $buffer);
@@ -995,25 +1315,42 @@  discard block
 block discarded – undo
995 1315
     				$data['ground'] = $line[21];
996 1316
     				$data['emergency'] = $line[19];
997 1317
     				$data['format_source'] = 'sbs';
998
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
999
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1318
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1319
+					$data['source_name'] = $globalSources[$nb]['name'];
1320
+				}
1321
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1322
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1323
+    				}
1000 1324
     				$data['id_source'] = $id_source;
1001
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1002
-    				else $error = true;
1325
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1326
+    					$send = $SI->add($data);
1327
+    				} else {
1328
+    					$error = true;
1329
+    				}
1003 1330
     				unset($data);
1004
-    			    } else $error = true;
1331
+    			    } else {
1332
+    			    	$error = true;
1333
+    			    }
1005 1334
 			    if ($error) {
1006 1335
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1007
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
1336
+					if ($globalDebug) {
1337
+						echo "Not a message. Ignoring... \n";
1338
+					}
1008 1339
 				} else {
1009
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
1340
+					if ($globalDebug) {
1341
+						echo "Wrong line format. Ignoring... \n";
1342
+					}
1010 1343
 					if ($globalDebug) {
1011 1344
 						echo $buffer;
1012 1345
 						print_r($line);
1013 1346
 					}
1014 1347
 					//socket_close($r);
1015
-					if ($globalDebug) echo "Reconnect after an error...\n";
1016
-					if ($format == 'aprs') $aprs_connect = 0;
1348
+					if ($globalDebug) {
1349
+						echo "Reconnect after an error...\n";
1350
+					}
1351
+					if ($format == 'aprs') {
1352
+						$aprs_connect = 0;
1353
+					}
1017 1354
 					$sourceer[$nb] = $globalSources[$nb];
1018 1355
 					connect_all($sourceer);
1019 1356
 					$sourceer = array();
@@ -1021,10 +1358,14 @@  discard block
 block discarded – undo
1021 1358
 			    }
1022 1359
 			}
1023 1360
 			// Sleep for xxx microseconds
1024
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1361
+			if (isset($globalSBSSleep)) {
1362
+				usleep($globalSBSSleep);
1363
+			}
1025 1364
 		    } else {
1026 1365
 			if ($format == 'flightgearmp') {
1027
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1366
+			    	if ($globalDebug) {
1367
+			    		echo "Reconnect FlightGear MP...";
1368
+			    	}
1028 1369
 				//@socket_close($r);
1029 1370
 				sleep($globalMinFetch);
1030 1371
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1033,10 +1374,15 @@  discard block
 block discarded – undo
1033 1374
 				break;
1034 1375
 				
1035 1376
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1036
-			    if (isset($tt[$format])) $tt[$format]++;
1037
-			    else $tt[$format] = 0;
1377
+			    if (isset($tt[$format])) {
1378
+			    	$tt[$format]++;
1379
+			    } else {
1380
+			    	$tt[$format] = 0;
1381
+			    }
1038 1382
 			    if ($tt[$format] > 30) {
1039
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1383
+				if ($globalDebug) {
1384
+					echo "ERROR : Reconnect ".$format."...";
1385
+				}
1040 1386
 				//@socket_close($r);
1041 1387
 				sleep(2);
1042 1388
 				$aprs_connect = 0;
@@ -1052,12 +1398,18 @@  discard block
 block discarded – undo
1052 1398
 		}
1053 1399
 	    } else {
1054 1400
 		$error = socket_strerror(socket_last_error());
1055
-		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1401
+		if ($globalDebug) {
1402
+			echo "ERROR : socket_select give this error ".$error . "\n";
1403
+		}
1056 1404
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1057
-			if (isset($globalDebug)) echo "Restarting...\n";
1405
+			if (isset($globalDebug)) {
1406
+				echo "Restarting...\n";
1407
+			}
1058 1408
 			// Restart the script if possible
1059 1409
 			if (is_array($sockets)) {
1060
-			    if ($globalDebug) echo "Shutdown all sockets...";
1410
+			    if ($globalDebug) {
1411
+			    	echo "Shutdown all sockets...";
1412
+			    }
1061 1413
 			    
1062 1414
 			    foreach ($sockets as $sock) {
1063 1415
 				@socket_shutdown($sock,2);
@@ -1065,18 +1417,24 @@  discard block
 block discarded – undo
1065 1417
 			    }
1066 1418
 			    
1067 1419
 			}
1068
-			if ($globalDebug) echo "Restart all connections...";
1420
+			if ($globalDebug) {
1421
+				echo "Restart all connections...";
1422
+			}
1069 1423
 			sleep(2);
1070 1424
 			$time = time();
1071 1425
 			//connect_all($hosts);
1072 1426
 			$aprs_connect = 0;
1073
-			if ($reset > 40) exit('Too many attempts...');
1427
+			if ($reset > 40) {
1428
+				exit('Too many attempts...');
1429
+			}
1074 1430
 			connect_all($globalSources);
1075 1431
 		}
1076 1432
 	    }
1077 1433
 	}
1078 1434
 	if ($globalDaemon === false) {
1079
-	    if ($globalDebug) echo 'Check all...'."\n";
1435
+	    if ($globalDebug) {
1436
+	    	echo 'Check all...'."\n";
1437
+	    }
1080 1438
 	    $SI->checkAll();
1081 1439
 	}
1082 1440
     }
Please login to merge, or discard this patch.
Indentation   +693 added lines, -693 removed lines patch added patch discarded remove patch
@@ -19,47 +19,47 @@  discard block
 block discarded – undo
19 19
 // Check if schema is at latest version
20 20
 $Connection = new Connection();
21 21
 if ($Connection->latest() === false) {
22
-    echo "You MUST update to latest schema. Run install/index.php";
23
-    exit();
22
+	echo "You MUST update to latest schema. Run install/index.php";
23
+	exit();
24 24
 }
25 25
 if (PHP_SAPI != 'cli') {
26
-    echo "This script MUST be called from console, not a web browser.";
26
+	echo "This script MUST be called from console, not a web browser.";
27 27
 //    exit();
28 28
 }
29 29
 
30 30
 // This is to be compatible with old version of settings.php
31 31
 if (!isset($globalSources)) {
32
-    if (isset($globalSBS1Hosts)) {
33
-        //$hosts = $globalSBS1Hosts;
34
-        foreach ($globalSBS1Hosts as $host) {
35
-	    $globalSources[] = array('host' => $host);
36
-    	}
37
-    } else {
38
-        if (!isset($globalSBS1Host)) {
39
-	    echo '$globalSources MUST be defined !';
40
-	    die;
32
+	if (isset($globalSBS1Hosts)) {
33
+		//$hosts = $globalSBS1Hosts;
34
+		foreach ($globalSBS1Hosts as $host) {
35
+		$globalSources[] = array('host' => $host);
36
+		}
37
+	} else {
38
+		if (!isset($globalSBS1Host)) {
39
+		echo '$globalSources MUST be defined !';
40
+		die;
41 41
 	}
42 42
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
43 43
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
44
-    }
44
+	}
45 45
 }
46 46
 
47 47
 $options = getopt('s::',array('source::','server','idsource::'));
48 48
 //if (isset($options['s'])) $hosts = array($options['s']);
49 49
 //elseif (isset($options['source'])) $hosts = array($options['source']);
50 50
 if (isset($options['s'])) {
51
-    $globalSources = array();
52
-    $globalSources[] = array('host' => $options['s']);
51
+	$globalSources = array();
52
+	$globalSources[] = array('host' => $options['s']);
53 53
 } elseif (isset($options['source'])) {
54
-    $globalSources = array();
55
-    $globalSources[] = array('host' => $options['source']);
54
+	$globalSources = array();
55
+	$globalSources[] = array('host' => $options['source']);
56 56
 }
57 57
 if (isset($options['server'])) $globalServer = TRUE;
58 58
 if (isset($options['idsource'])) $id_source = $options['idsource'];
59 59
 else $id_source = 1;
60 60
 if (isset($globalServer) && $globalServer) {
61
-    if ($globalDebug) echo "Using Server Mode\n";
62
-    $SI=new SpotterServer();
61
+	if ($globalDebug) echo "Using Server Mode\n";
62
+	$SI=new SpotterServer();
63 63
 } else $SI=new SpotterImport($Connection->db);
64 64
 //$APRS=new APRS($Connection->db);
65 65
 $SBS=new SBS();
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
 //$servertz = system('date +%Z');
70 70
 // signal handler - playing nice with sockets and dump1090
71 71
 if (function_exists('pcntl_fork')) {
72
-    pcntl_signal(SIGINT,  function() {
73
-        global $sockets;
74
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75
-        die("Bye!\n");
76
-    });
77
-    pcntl_signal_dispatch();
72
+	pcntl_signal(SIGINT,  function() {
73
+		global $sockets;
74
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75
+		die("Bye!\n");
76
+	});
77
+	pcntl_signal_dispatch();
78 78
 }
79 79
 
80 80
 // let's try and connect
@@ -84,162 +84,162 @@  discard block
 block discarded – undo
84 84
 $reset = 0;
85 85
 
86 86
 function create_socket($host, $port, &$errno, &$errstr) {
87
-    $ip = gethostbyname($host);
88
-    $s = socket_create(AF_INET, SOCK_STREAM, 0);
89
-    $r = @socket_connect($s, $ip, $port);
90
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
91
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
92
-        return $s;
93
-    }
94
-    $errno = socket_last_error($s);
95
-    $errstr = socket_strerror($errno);
96
-    socket_close($s);
97
-    return false;
87
+	$ip = gethostbyname($host);
88
+	$s = socket_create(AF_INET, SOCK_STREAM, 0);
89
+	$r = @socket_connect($s, $ip, $port);
90
+	if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
91
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
92
+		return $s;
93
+	}
94
+	$errno = socket_last_error($s);
95
+	$errstr = socket_strerror($errno);
96
+	socket_close($s);
97
+	return false;
98 98
 }
99 99
 
100 100
 function create_socket_udp($host, $port, &$errno, &$errstr) {
101
-    echo "Create an UDP socket...\n";
102
-    $ip = gethostbyname($host);
103
-    $s = socket_create(AF_INET, SOCK_DGRAM, 0);
104
-    $r = @socket_bind($s, $ip, $port);
105
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
106
-        return $s;
107
-    }
108
-    $errno = socket_last_error($s);
109
-    $errstr = socket_strerror($errno);
110
-    socket_close($s);
111
-    return false;
101
+	echo "Create an UDP socket...\n";
102
+	$ip = gethostbyname($host);
103
+	$s = socket_create(AF_INET, SOCK_DGRAM, 0);
104
+	$r = @socket_bind($s, $ip, $port);
105
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
106
+		return $s;
107
+	}
108
+	$errno = socket_last_error($s);
109
+	$errstr = socket_strerror($errno);
110
+	socket_close($s);
111
+	return false;
112 112
 }
113 113
 
114 114
 function connect_all($hosts) {
115
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
117
-    $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
119
-    foreach ($hosts as $id => $value) {
115
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
+	global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset;
117
+	$reset++;
118
+	if ($globalDebug) echo 'Connect to all...'."\n";
119
+	foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123 123
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
125
-        	//$formats[$id] = 'deltadbtxt';
126
-        	$globalSources[$id]['format'] = 'deltadbtxt';
127
-        	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
-        	//$formats[$id] = 'vatsimtxt';
131
-        	$globalSources[$id]['format'] = 'vatsimtxt';
132
-        	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135
-        	//$formats[$id] = 'aircraftlistjson';
136
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
137
-        	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
140
-        	//$formats[$id] = 'aircraftlistjson';
141
-        	$globalSources[$id]['format'] = 'opensky';
142
-        	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
145
-        	//$formats[$id] = 'radarvirtueljson';
146
-        	$globalSources[$id]['format'] = 'radarvirtueljson';
147
-        	//$last_exec['radarvirtueljson'] = 0;
148
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
149
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
150
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151
-        	    exit(0);
152
-        	}
153
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
154
-        	//$formats[$id] = 'planeupdatefaa';
155
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
156
-        	//$last_exec['planeupdatefaa'] = 0;
157
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
158
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
159
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160
-        	    exit(0);
161
-        	}
162
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
163
-        	//$formats[$id] = 'phpvmacars';
164
-        	$globalSources[$id]['format'] = 'phpvmacars';
165
-        	//$last_exec['phpvmacars'] = 0;
166
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
167
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
168
-        	//$formats[$id] = 'phpvmacars';
169
-        	$globalSources[$id]['format'] = 'vam';
170
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
171
-            } else if (preg_match('/whazzup/i',$host)) {
172
-        	//$formats[$id] = 'whazzup';
173
-        	$globalSources[$id]['format'] = 'whazzup';
174
-        	//$last_exec['whazzup'] = 0;
175
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
176
-            } else if (preg_match('/recentpireps/i',$host)) {
177
-        	//$formats[$id] = 'pirepsjson';
178
-        	$globalSources[$id]['format'] = 'pirepsjson';
179
-        	//$last_exec['pirepsjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
181
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182
-        	//$formats[$id] = 'fr24json';
183
-        	$globalSources[$id]['format'] = 'fr24json';
184
-        	//$last_exec['fr24json'] = 0;
185
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
186
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
187
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
188
-        	    exit(0);
189
-        	}
190
-            //} else if (preg_match('/10001/',$host)) {
191
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192
-        	//$formats[$id] = 'tsv';
193
-        	$globalSources[$id]['format'] = 'tsv';
194
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
195
-            }
196
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
197
-        	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
198
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199
-	    $hostport = explode(':',$host);
200
-	    if (isset($hostport[1])) {
124
+			if (preg_match('/deltadb.txt$/i',$host)) {
125
+			//$formats[$id] = 'deltadbtxt';
126
+			$globalSources[$id]['format'] = 'deltadbtxt';
127
+			//$last_exec['deltadbtxt'] = 0;
128
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
+			//$formats[$id] = 'vatsimtxt';
131
+			$globalSources[$id]['format'] = 'vatsimtxt';
132
+			//$last_exec['vatsimtxt'] = 0;
133
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
135
+			//$formats[$id] = 'aircraftlistjson';
136
+			$globalSources[$id]['format'] = 'aircraftlistjson';
137
+			//$last_exec['aircraftlistjson'] = 0;
138
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
+			} else if (preg_match('/opensky/i',$host)) {
140
+			//$formats[$id] = 'aircraftlistjson';
141
+			$globalSources[$id]['format'] = 'opensky';
142
+			//$last_exec['aircraftlistjson'] = 0;
143
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
+			} else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
145
+			//$formats[$id] = 'radarvirtueljson';
146
+			$globalSources[$id]['format'] = 'radarvirtueljson';
147
+			//$last_exec['radarvirtueljson'] = 0;
148
+			if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
149
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
150
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
151
+				exit(0);
152
+			}
153
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
154
+			//$formats[$id] = 'planeupdatefaa';
155
+			$globalSources[$id]['format'] = 'planeupdatefaa';
156
+			//$last_exec['planeupdatefaa'] = 0;
157
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
158
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
159
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
160
+				exit(0);
161
+			}
162
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
163
+			//$formats[$id] = 'phpvmacars';
164
+			$globalSources[$id]['format'] = 'phpvmacars';
165
+			//$last_exec['phpvmacars'] = 0;
166
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
167
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
168
+			//$formats[$id] = 'phpvmacars';
169
+			$globalSources[$id]['format'] = 'vam';
170
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
171
+			} else if (preg_match('/whazzup/i',$host)) {
172
+			//$formats[$id] = 'whazzup';
173
+			$globalSources[$id]['format'] = 'whazzup';
174
+			//$last_exec['whazzup'] = 0;
175
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
176
+			} else if (preg_match('/recentpireps/i',$host)) {
177
+			//$formats[$id] = 'pirepsjson';
178
+			$globalSources[$id]['format'] = 'pirepsjson';
179
+			//$last_exec['pirepsjson'] = 0;
180
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
181
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182
+			//$formats[$id] = 'fr24json';
183
+			$globalSources[$id]['format'] = 'fr24json';
184
+			//$last_exec['fr24json'] = 0;
185
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
186
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
187
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
188
+				exit(0);
189
+			}
190
+			//} else if (preg_match('/10001/',$host)) {
191
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
192
+			//$formats[$id] = 'tsv';
193
+			$globalSources[$id]['format'] = 'tsv';
194
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
195
+			}
196
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
197
+			if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
198
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
199
+		$hostport = explode(':',$host);
200
+		if (isset($hostport[1])) {
201 201
 		$port = $hostport[1];
202 202
 		$hostn = $hostport[0];
203
-	    } else {
203
+		} else {
204 204
 		$port = $globalSources[$id]['port'];
205 205
 		$hostn = $globalSources[$id]['host'];
206
-	    }
207
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
208
-        	$s = create_socket($hostn,$port, $errno, $errstr);
209
-    	    } else {
210
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
211
-	    }
212
-	    if ($s) {
213
-    	        $sockets[$id] = $s;
214
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
215
-		    if (preg_match('/aprs/',$hostn)) {
206
+		}
207
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
208
+			$s = create_socket($hostn,$port, $errno, $errstr);
209
+			} else {
210
+			$s = create_socket_udp($hostn,$port, $errno, $errstr);
211
+		}
212
+		if ($s) {
213
+				$sockets[$id] = $s;
214
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
215
+			if (preg_match('/aprs/',$hostn)) {
216 216
 			//$formats[$id] = 'aprs';
217 217
 			$globalSources[$id]['format'] = 'aprs';
218 218
 			//$aprs_connect = 0;
219 219
 			//$use_aprs = true;
220
-    		    } elseif ($port == '10001') {
221
-        		//$formats[$id] = 'tsv';
222
-        		$globalSources[$id]['format'] = 'tsv';
223
-		    } elseif ($port == '30002') {
224
-        		//$formats[$id] = 'raw';
225
-        		$globalSources[$id]['format'] = 'raw';
226
-		    } elseif ($port == '5001') {
227
-        		//$formats[$id] = 'raw';
228
-        		$globalSources[$id]['format'] = 'flightgearmp';
229
-		    } elseif ($port == '30005') {
220
+				} elseif ($port == '10001') {
221
+				//$formats[$id] = 'tsv';
222
+				$globalSources[$id]['format'] = 'tsv';
223
+			} elseif ($port == '30002') {
224
+				//$formats[$id] = 'raw';
225
+				$globalSources[$id]['format'] = 'raw';
226
+			} elseif ($port == '5001') {
227
+				//$formats[$id] = 'raw';
228
+				$globalSources[$id]['format'] = 'flightgearmp';
229
+			} elseif ($port == '30005') {
230 230
 			// Not yet supported
231
-        		//$formats[$id] = 'beast';
232
-        		$globalSources[$id]['format'] = 'beast';
233
-		    //} else $formats[$id] = 'sbs';
234
-		    } else $globalSources[$id]['format'] = 'sbs';
235
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
231
+				//$formats[$id] = 'beast';
232
+				$globalSources[$id]['format'] = 'beast';
233
+			//} else $formats[$id] = 'sbs';
234
+			} else $globalSources[$id]['format'] = 'sbs';
235
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
236 236
 		}
237 237
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
238
-            } else {
238
+			} else {
239 239
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
240
-    	    }
241
-        }
242
-    }
240
+			}
241
+		}
242
+	}
243 243
 }
244 244
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
245 245
 
@@ -266,18 +266,18 @@  discard block
 block discarded – undo
266 266
 	die;
267 267
 }
268 268
 foreach ($globalSources as $key => $source) {
269
-    if (!isset($source['format'])) {
270
-        $globalSources[$key]['format'] = 'auto';
271
-    }
269
+	if (!isset($source['format'])) {
270
+		$globalSources[$key]['format'] = 'auto';
271
+	}
272 272
 }
273 273
 connect_all($globalSources);
274 274
 foreach ($globalSources as $key => $source) {
275
-    if (isset($source['format']) && $source['format'] == 'aprs') {
275
+	if (isset($source['format']) && $source['format'] == 'aprs') {
276 276
 	$aprs_connect = 0;
277 277
 	$use_aprs = true;
278 278
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
279 279
 	break;
280
-    }
280
+	}
281 281
 }
282 282
 
283 283
 if ($use_aprs) {
@@ -317,69 +317,69 @@  discard block
 block discarded – undo
317 317
 
318 318
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
319 319
 while ($i > 0) {
320
-    if (!$globalDaemon) $i = $endtime-time();
321
-    // Delete old ATC
322
-    if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
320
+	if (!$globalDaemon) $i = $endtime-time();
321
+	// Delete old ATC
322
+	if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
323 323
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
324
-        $ATC->deleteOldATC();
325
-    }
324
+		$ATC->deleteOldATC();
325
+	}
326 326
     
327
-    if (count($last_exec) > 0) {
327
+	if (count($last_exec) > 0) {
328 328
 	$max = $globalMinFetch;
329 329
 	foreach ($last_exec as $last) {
330
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
330
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
331 331
 	}
332 332
 	if ($max != $globalMinFetch) {
333
-	    if ($globalDebug) echo 'Sleeping...'."\n";
334
-	    sleep($globalMinFetch-$max+2);
333
+		if ($globalDebug) echo 'Sleeping...'."\n";
334
+		sleep($globalMinFetch-$max+2);
335
+	}
335 336
 	}
336
-    }
337 337
 
338 338
     
339
-    //foreach ($formats as $id => $value) {
340
-    foreach ($globalSources as $id => $value) {
339
+	//foreach ($formats as $id => $value) {
340
+	foreach ($globalSources as $id => $value) {
341 341
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
342 342
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
343
-	    //$buffer = $Common->getData($hosts[$id]);
344
-	    $buffer = $Common->getData($value['host']);
345
-	    if ($buffer != '') $reset = 0;
346
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347
-	    $buffer = explode('\n',$buffer);
348
-	    foreach ($buffer as $line) {
349
-    		if ($line != '' && count($line) > 7) {
350
-    		    $line = explode(',', $line);
351
-	            $data = array();
352
-	            $data['hex'] = $line[1]; // hex
353
-	            $data['ident'] = $line[2]; // ident
354
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
355
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
356
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
357
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
358
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
359
-	            $data['verticalrate'] = ''; // vertical rate
360
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
361
-	            $data['emergency'] = ''; // emergency
362
-		    $data['datetime'] = date('Y-m-d H:i:s');
363
-		    $data['format_source'] = 'deltadbtxt';
364
-    		    $data['id_source'] = $id_source;
365
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
366
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
367
-    		    $SI->add($data);
368
-		    unset($data);
369
-    		}
370
-    	    }
371
-    	    $last_exec[$id]['last'] = time();
343
+		//$buffer = $Common->getData($hosts[$id]);
344
+		$buffer = $Common->getData($value['host']);
345
+		if ($buffer != '') $reset = 0;
346
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
347
+		$buffer = explode('\n',$buffer);
348
+		foreach ($buffer as $line) {
349
+			if ($line != '' && count($line) > 7) {
350
+				$line = explode(',', $line);
351
+				$data = array();
352
+				$data['hex'] = $line[1]; // hex
353
+				$data['ident'] = $line[2]; // ident
354
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
355
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
356
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
357
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
358
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
359
+				$data['verticalrate'] = ''; // vertical rate
360
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
361
+				$data['emergency'] = ''; // emergency
362
+			$data['datetime'] = date('Y-m-d H:i:s');
363
+			$data['format_source'] = 'deltadbtxt';
364
+				$data['id_source'] = $id_source;
365
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
366
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
367
+				$SI->add($data);
368
+			unset($data);
369
+			}
370
+			}
371
+			$last_exec[$id]['last'] = time();
372 372
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
373 373
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
374
-	    //$buffer = $Common->getData($hosts[$id]);
375
-	    $buffer = $Common->getData($value['host']);
376
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
-	    $buffer = explode('\n',$buffer);
378
-	    $reset = 0;
379
-	    foreach ($buffer as $line) {
380
-    		if ($line != '') {
381
-    		    $line = explode(':', $line);
382
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
374
+		//$buffer = $Common->getData($hosts[$id]);
375
+		$buffer = $Common->getData($value['host']);
376
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
+		$buffer = explode('\n',$buffer);
378
+		$reset = 0;
379
+		foreach ($buffer as $line) {
380
+			if ($line != '') {
381
+				$line = explode(':', $line);
382
+				if (count($line) > 30 && $line[0] != 'callsign') {
383 383
 			$data = array();
384 384
 			$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
385 385
 			$data['pilot_id'] = $line[1];
@@ -391,36 +391,36 @@  discard block
 block discarded – undo
391 391
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
392 392
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
393 393
 			$data['latitude'] = $line[5]; // lat
394
-	        	$data['longitude'] = $line[6]; // long
395
-	        	$data['verticalrate'] = ''; // vertical rate
396
-	        	$data['squawk'] = ''; // squawk
397
-	        	$data['emergency'] = ''; // emergency
398
-	        	$data['waypoints'] = $line[30];
394
+				$data['longitude'] = $line[6]; // long
395
+				$data['verticalrate'] = ''; // vertical rate
396
+				$data['squawk'] = ''; // squawk
397
+				$data['emergency'] = ''; // emergency
398
+				$data['waypoints'] = $line[30];
399 399
 			$data['datetime'] = date('Y-m-d H:i:s');
400 400
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
401 401
 			if (isset($line[37])) $data['last_update'] = $line[37];
402
-		        $data['departure_airport_icao'] = $line[11];
403
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
404
-		        $data['arrival_airport_icao'] = $line[13];
402
+				$data['departure_airport_icao'] = $line[11];
403
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
404
+				$data['arrival_airport_icao'] = $line[13];
405 405
 			$data['frequency'] = $line[4];
406 406
 			$data['type'] = $line[18];
407 407
 			$data['range'] = $line[19];
408 408
 			if (isset($line[35])) $data['info'] = $line[35];
409
-    			$data['id_source'] = $id_source;
410
-	    		//$data['arrival_airport_time'] = ;
411
-	    		if ($line[9] != '') {
412
-	    		    $aircraft_data = explode('/',$line[9]);
413
-	    		    if (isset($aircraft_data[1])) {
414
-	    			$data['aircraft_icao'] = $aircraft_data[1];
415
-	    		    }
416
-        		}
417
-	    		/*
409
+				$data['id_source'] = $id_source;
410
+				//$data['arrival_airport_time'] = ;
411
+				if ($line[9] != '') {
412
+					$aircraft_data = explode('/',$line[9]);
413
+					if (isset($aircraft_data[1])) {
414
+					$data['aircraft_icao'] = $aircraft_data[1];
415
+					}
416
+				}
417
+				/*
418 418
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
419 419
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
420 420
 	    		*/
421
-	    		$data['format_source'] = $value['format'];
421
+				$data['format_source'] = $value['format'];
422 422
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
423
-    			if ($line[3] == 'PILOT') $SI->add($data);
423
+				if ($line[3] == 'PILOT') $SI->add($data);
424 424
 			elseif ($line[3] == 'ATC') {
425 425
 				//print_r($data);
426 426
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -438,247 +438,247 @@  discard block
 block discarded – undo
438 438
 				if (!isset($data['source_name'])) $data['source_name'] = '';
439 439
 				echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
440 440
 			}
441
-    			unset($data);
442
-    		    }
443
-    		}
444
-    	    }
445
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
446
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
447
-    	    $last_exec[$id]['last'] = time();
448
-    	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
449
-    	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
450
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
451
-	    if ($buffer != '') {
452
-	    $all_data = json_decode($buffer,true);
453
-	    if (isset($all_data['acList'])) {
441
+				unset($data);
442
+				}
443
+			}
444
+			}
445
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
446
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
447
+			$last_exec[$id]['last'] = time();
448
+		//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
449
+		} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
450
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
451
+		if ($buffer != '') {
452
+		$all_data = json_decode($buffer,true);
453
+		if (isset($all_data['acList'])) {
454 454
 		$reset = 0;
455 455
 		foreach ($all_data['acList'] as $line) {
456
-		    $data = array();
457
-		    $data['hex'] = $line['Icao']; // hex
458
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
459
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
460
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
461
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
462
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
463
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
464
-		    //$data['verticalrate'] = $line['']; // verticale rate
465
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
466
-		    $data['emergency'] = ''; // emergency
467
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
468
-		    /*
456
+			$data = array();
457
+			$data['hex'] = $line['Icao']; // hex
458
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
459
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
460
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
461
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
462
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
463
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
464
+			//$data['verticalrate'] = $line['']; // verticale rate
465
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
466
+			$data['emergency'] = ''; // emergency
467
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
468
+			/*
469 469
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
470 470
 		    else $data['datetime'] = date('Y-m-d H:i:s');
471 471
 		    */
472
-		    $data['datetime'] = date('Y-m-d H:i:s');
473
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
474
-	    	    $data['format_source'] = 'aircraftlistjson';
475
-		    $data['id_source'] = $id_source;
476
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
477
-		    if (isset($data['datetime'])) $SI->add($data);
478
-		    unset($data);
472
+			$data['datetime'] = date('Y-m-d H:i:s');
473
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
474
+				$data['format_source'] = 'aircraftlistjson';
475
+			$data['id_source'] = $id_source;
476
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
477
+			if (isset($data['datetime'])) $SI->add($data);
478
+			unset($data);
479 479
 		}
480
-	    } else {
480
+		} else {
481 481
 		$reset = 0;
482 482
 		foreach ($all_data as $line) {
483
-		    $data = array();
484
-		    $data['hex'] = $line['hex']; // hex
485
-		    $data['ident'] = $line['flight']; // ident
486
-		    $data['altitude'] = $line['altitude']; // altitude
487
-		    $data['speed'] = $line['speed']; // speed
488
-		    $data['heading'] = $line['track']; // heading
489
-		    $data['latitude'] = $line['lat']; // lat
490
-		    $data['longitude'] = $line['lon']; // long
491
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
492
-		    $data['squawk'] = $line['squawk']; // squawk
493
-		    $data['emergency'] = ''; // emergency
494
-		    $data['datetime'] = date('Y-m-d H:i:s');
495
-	    	    $data['format_source'] = 'aircraftlistjson';
496
-    		    $data['id_source'] = $id_source;
497
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
498
-		    $SI->add($data);
499
-		    unset($data);
483
+			$data = array();
484
+			$data['hex'] = $line['hex']; // hex
485
+			$data['ident'] = $line['flight']; // ident
486
+			$data['altitude'] = $line['altitude']; // altitude
487
+			$data['speed'] = $line['speed']; // speed
488
+			$data['heading'] = $line['track']; // heading
489
+			$data['latitude'] = $line['lat']; // lat
490
+			$data['longitude'] = $line['lon']; // long
491
+			$data['verticalrate'] = $line['vrt']; // verticale rate
492
+			$data['squawk'] = $line['squawk']; // squawk
493
+			$data['emergency'] = ''; // emergency
494
+			$data['datetime'] = date('Y-m-d H:i:s');
495
+				$data['format_source'] = 'aircraftlistjson';
496
+				$data['id_source'] = $id_source;
497
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
498
+			$SI->add($data);
499
+			unset($data);
500
+		}
500 501
 		}
501
-	    }
502
-	    }
503
-    	    //$last_exec['aircraftlistjson'] = time();
504
-    	    $last_exec[$id]['last'] = time();
505
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
506
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
507
-	    $buffer = $Common->getData($value['host']);
508
-	    $all_data = json_decode($buffer,true);
509
-	    if (isset($all_data['planes'])) {
502
+		}
503
+			//$last_exec['aircraftlistjson'] = time();
504
+			$last_exec[$id]['last'] = time();
505
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
506
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
507
+		$buffer = $Common->getData($value['host']);
508
+		$all_data = json_decode($buffer,true);
509
+		if (isset($all_data['planes'])) {
510 510
 		$reset = 0;
511 511
 		foreach ($all_data['planes'] as $key => $line) {
512
-		    $data = array();
513
-		    $data['hex'] = $key; // hex
514
-		    $data['ident'] = $line[3]; // ident
515
-		    $data['altitude'] = $line[6]; // altitude
516
-		    $data['speed'] = $line[8]; // speed
517
-		    $data['heading'] = $line[7]; // heading
518
-		    $data['latitude'] = $line[4]; // lat
519
-		    $data['longitude'] = $line[5]; // long
520
-		    //$data['verticalrate'] = $line[]; // verticale rate
521
-		    $data['squawk'] = $line[10]; // squawk
522
-		    $data['emergency'] = ''; // emergency
523
-		    $data['registration'] = $line[2];
524
-		    $data['aircraft_icao'] = $line[0];
525
-		    $deparr = explode('-',$line[1]);
526
-		    if (count($deparr) == 2) {
512
+			$data = array();
513
+			$data['hex'] = $key; // hex
514
+			$data['ident'] = $line[3]; // ident
515
+			$data['altitude'] = $line[6]; // altitude
516
+			$data['speed'] = $line[8]; // speed
517
+			$data['heading'] = $line[7]; // heading
518
+			$data['latitude'] = $line[4]; // lat
519
+			$data['longitude'] = $line[5]; // long
520
+			//$data['verticalrate'] = $line[]; // verticale rate
521
+			$data['squawk'] = $line[10]; // squawk
522
+			$data['emergency'] = ''; // emergency
523
+			$data['registration'] = $line[2];
524
+			$data['aircraft_icao'] = $line[0];
525
+			$deparr = explode('-',$line[1]);
526
+			if (count($deparr) == 2) {
527 527
 			$data['departure_airport_icao'] = $deparr[0];
528 528
 			$data['arrival_airport_icao'] = $deparr[1];
529
-		    }
530
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
531
-	    	    $data['format_source'] = 'planeupdatefaa';
532
-    		    $data['id_source'] = $id_source;
533
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
534
-		    $SI->add($data);
535
-		    unset($data);
529
+			}
530
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
531
+				$data['format_source'] = 'planeupdatefaa';
532
+				$data['id_source'] = $id_source;
533
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
534
+			$SI->add($data);
535
+			unset($data);
536
+		}
536 537
 		}
537
-	    }
538
-    	    //$last_exec['planeupdatefaa'] = time();
539
-    	    $last_exec[$id]['last'] = time();
540
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
541
-	    $buffer = $Common->getData($value['host']);
542
-	    $all_data = json_decode($buffer,true);
543
-	    if (isset($all_data['states'])) {
538
+			//$last_exec['planeupdatefaa'] = time();
539
+			$last_exec[$id]['last'] = time();
540
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
541
+		$buffer = $Common->getData($value['host']);
542
+		$all_data = json_decode($buffer,true);
543
+		if (isset($all_data['states'])) {
544 544
 		$reset = 0;
545 545
 		foreach ($all_data['states'] as $key => $line) {
546
-		    $data = array();
547
-		    $data['hex'] = $line[0]; // hex
548
-		    $data['ident'] = trim($line[1]); // ident
549
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
550
-		    $data['speed'] = round($line[9]*1.94384); // speed
551
-		    $data['heading'] = round($line[10]); // heading
552
-		    $data['latitude'] = $line[5]; // lat
553
-		    $data['longitude'] = $line[6]; // long
554
-		    $data['verticalrate'] = $line[11]; // verticale rate
555
-		    //$data['squawk'] = $line[10]; // squawk
556
-		    //$data['emergency'] = ''; // emergency
557
-		    //$data['registration'] = $line[2];
558
-		    //$data['aircraft_icao'] = $line[0];
559
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
560
-	    	    $data['format_source'] = 'opensky';
561
-    		    $data['id_source'] = $id_source;
562
-		    $SI->add($data);
563
-		    unset($data);
546
+			$data = array();
547
+			$data['hex'] = $line[0]; // hex
548
+			$data['ident'] = trim($line[1]); // ident
549
+			$data['altitude'] = round($line[7]*3.28084); // altitude
550
+			$data['speed'] = round($line[9]*1.94384); // speed
551
+			$data['heading'] = round($line[10]); // heading
552
+			$data['latitude'] = $line[5]; // lat
553
+			$data['longitude'] = $line[6]; // long
554
+			$data['verticalrate'] = $line[11]; // verticale rate
555
+			//$data['squawk'] = $line[10]; // squawk
556
+			//$data['emergency'] = ''; // emergency
557
+			//$data['registration'] = $line[2];
558
+			//$data['aircraft_icao'] = $line[0];
559
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
560
+				$data['format_source'] = 'opensky';
561
+				$data['id_source'] = $id_source;
562
+			$SI->add($data);
563
+			unset($data);
564
+		}
564 565
 		}
565
-	    }
566
-    	    //$last_exec['planeupdatefaa'] = time();
567
-    	    $last_exec[$id]['last'] = time();
568
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
569
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
570
-	    //$buffer = $Common->getData($hosts[$id]);
571
-	    $buffer = $Common->getData($value['host']);
572
-	    $all_data = json_decode($buffer,true);
573
-	    if (!empty($all_data)) $reset = 0;
574
-	    foreach ($all_data as $key => $line) {
566
+			//$last_exec['planeupdatefaa'] = time();
567
+			$last_exec[$id]['last'] = time();
568
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
569
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
570
+		//$buffer = $Common->getData($hosts[$id]);
571
+		$buffer = $Common->getData($value['host']);
572
+		$all_data = json_decode($buffer,true);
573
+		if (!empty($all_data)) $reset = 0;
574
+		foreach ($all_data as $key => $line) {
575 575
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
576
-		    $data = array();
577
-		    $data['hex'] = $line[0];
578
-		    $data['ident'] = $line[16]; //$line[13]
579
-	    	    $data['altitude'] = $line[4]; // altitude
580
-	    	    $data['speed'] = $line[5]; // speed
581
-	    	    $data['heading'] = $line[3]; // heading
582
-	    	    $data['latitude'] = $line[1]; // lat
583
-	    	    $data['longitude'] = $line[2]; // long
584
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
585
-	    	    $data['squawk'] = $line[6]; // squawk
586
-	    	    $data['aircraft_icao'] = $line[8];
587
-	    	    $data['registration'] = $line[9];
588
-		    $data['departure_airport_iata'] = $line[11];
589
-		    $data['arrival_airport_iata'] = $line[12];
590
-	    	    $data['emergency'] = ''; // emergency
591
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
592
-	    	    $data['format_source'] = 'fr24json';
593
-    		    $data['id_source'] = $id_source;
594
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
595
-		    $SI->add($data);
596
-		    unset($data);
576
+			$data = array();
577
+			$data['hex'] = $line[0];
578
+			$data['ident'] = $line[16]; //$line[13]
579
+				$data['altitude'] = $line[4]; // altitude
580
+				$data['speed'] = $line[5]; // speed
581
+				$data['heading'] = $line[3]; // heading
582
+				$data['latitude'] = $line[1]; // lat
583
+				$data['longitude'] = $line[2]; // long
584
+				$data['verticalrate'] = $line[15]; // verticale rate
585
+				$data['squawk'] = $line[6]; // squawk
586
+				$data['aircraft_icao'] = $line[8];
587
+				$data['registration'] = $line[9];
588
+			$data['departure_airport_iata'] = $line[11];
589
+			$data['arrival_airport_iata'] = $line[12];
590
+				$data['emergency'] = ''; // emergency
591
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
592
+				$data['format_source'] = 'fr24json';
593
+				$data['id_source'] = $id_source;
594
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
595
+			$SI->add($data);
596
+			unset($data);
597
+		}
597 598
 		}
598
-	    }
599
-    	    //$last_exec['fr24json'] = time();
600
-    	    $last_exec[$id]['last'] = time();
601
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
602
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
603
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
604
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
605
-	    //echo $buffer;
606
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
607
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
608
-	    $all_data = json_decode($buffer,true);
609
-	    if (json_last_error() != JSON_ERROR_NONE) {
599
+			//$last_exec['fr24json'] = time();
600
+			$last_exec[$id]['last'] = time();
601
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
602
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
603
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
604
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
605
+		//echo $buffer;
606
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
607
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
608
+		$all_data = json_decode($buffer,true);
609
+		if (json_last_error() != JSON_ERROR_NONE) {
610 610
 		die(json_last_error_msg());
611
-	    }
612
-	    if (isset($all_data['mrkrs'])) {
611
+		}
612
+		if (isset($all_data['mrkrs'])) {
613 613
 		$reset = 0;
614 614
 		foreach ($all_data['mrkrs'] as $key => $line) {
615
-		    if (isset($line['inf'])) {
615
+			if (isset($line['inf'])) {
616 616
 			$data = array();
617 617
 			$data['hex'] = $line['inf']['ia'];
618 618
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
619
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
620
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
621
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
622
-	    		$data['latitude'] = $line['pt'][0]; // lat
623
-	    		$data['longitude'] = $line['pt'][1]; // long
624
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
625
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
626
-	    		//$data['aircraft_icao'] = $line[8];
627
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
619
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
620
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
621
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
622
+				$data['latitude'] = $line['pt'][0]; // lat
623
+				$data['longitude'] = $line['pt'][1]; // long
624
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
625
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
626
+				//$data['aircraft_icao'] = $line[8];
627
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
628 628
 			//$data['departure_airport_iata'] = $line[11];
629 629
 			//$data['arrival_airport_iata'] = $line[12];
630
-	    		//$data['emergency'] = ''; // emergency
630
+				//$data['emergency'] = ''; // emergency
631 631
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
632
-	    		$data['format_source'] = 'radarvirtueljson';
633
-    			$data['id_source'] = $id_source;
632
+				$data['format_source'] = 'radarvirtueljson';
633
+				$data['id_source'] = $id_source;
634 634
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
635 635
 			$SI->add($data);
636 636
 			unset($data);
637
-		    }
637
+			}
638
+		}
638 639
 		}
639
-	    }
640
-    	    //$last_exec['radarvirtueljson'] = time();
641
-    	    $last_exec[$id]['last'] = time();
642
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
643
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
644
-	    //$buffer = $Common->getData($hosts[$id]);
645
-	    $buffer = $Common->getData($value['host'].'?'.time());
646
-	    $all_data = json_decode(utf8_encode($buffer),true);
640
+			//$last_exec['radarvirtueljson'] = time();
641
+			$last_exec[$id]['last'] = time();
642
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
643
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
644
+		//$buffer = $Common->getData($hosts[$id]);
645
+		$buffer = $Common->getData($value['host'].'?'.time());
646
+		$all_data = json_decode(utf8_encode($buffer),true);
647 647
 	    
648
-	    if (isset($all_data['pireps'])) {
648
+		if (isset($all_data['pireps'])) {
649 649
 		$reset = 0;
650
-	        foreach ($all_data['pireps'] as $line) {
651
-		    $data = array();
652
-		    $data['id'] = $line['id'];
653
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
654
-		    $data['ident'] = $line['callsign']; // ident
655
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
656
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
657
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
658
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
659
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
660
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
661
-		    $data['latitude'] = $line['lat']; // lat
662
-		    $data['longitude'] = $line['lon']; // long
663
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
664
-		    //$data['squawk'] = $line['squawk']; // squawk
665
-		    //$data['emergency'] = ''; // emergency
666
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
667
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
668
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
669
-		    //$data['arrival_airport_time'] = $line['arrtime'];
670
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
671
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
672
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
673
-		    else $data['info'] = '';
674
-		    $data['format_source'] = 'pireps';
675
-    		    $data['id_source'] = $id_source;
676
-		    $data['datetime'] = date('Y-m-d H:i:s');
677
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
678
-		    if ($line['icon'] == 'plane') {
650
+			foreach ($all_data['pireps'] as $line) {
651
+			$data = array();
652
+			$data['id'] = $line['id'];
653
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
654
+			$data['ident'] = $line['callsign']; // ident
655
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
656
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
657
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
658
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
659
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
660
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
661
+			$data['latitude'] = $line['lat']; // lat
662
+			$data['longitude'] = $line['lon']; // long
663
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
664
+			//$data['squawk'] = $line['squawk']; // squawk
665
+			//$data['emergency'] = ''; // emergency
666
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
667
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
668
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
669
+			//$data['arrival_airport_time'] = $line['arrtime'];
670
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
671
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
672
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
673
+			else $data['info'] = '';
674
+			$data['format_source'] = 'pireps';
675
+				$data['id_source'] = $id_source;
676
+			$data['datetime'] = date('Y-m-d H:i:s');
677
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
678
+			if ($line['icon'] == 'plane') {
679 679
 			$SI->add($data);
680
-		    //    print_r($data);
681
-    		    } elseif ($line['icon'] == 'ct') {
680
+			//    print_r($data);
681
+				} elseif ($line['icon'] == 'ct') {
682 682
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
683 683
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
684 684
 			$typec = substr($data['ident'],-3);
@@ -693,163 +693,163 @@  discard block
 block discarded – undo
693 693
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
694 694
 			else $data['type'] = 'Observer';
695 695
 			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
696
-		    }
697
-		    unset($data);
696
+			}
697
+			unset($data);
698
+		}
698 699
 		}
699
-	    }
700
-    	    //$last_exec['pirepsjson'] = time();
701
-    	    $last_exec[$id]['last'] = time();
702
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
703
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
704
-	    //$buffer = $Common->getData($hosts[$id]);
705
-	    if ($globalDebug) echo 'Get Data...'."\n";
706
-	    $buffer = $Common->getData($value['host']);
707
-	    $all_data = json_decode($buffer,true);
708
-	    if ($buffer != '' && is_array($all_data)) {
700
+			//$last_exec['pirepsjson'] = time();
701
+			$last_exec[$id]['last'] = time();
702
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
703
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
704
+		//$buffer = $Common->getData($hosts[$id]);
705
+		if ($globalDebug) echo 'Get Data...'."\n";
706
+		$buffer = $Common->getData($value['host']);
707
+		$all_data = json_decode($buffer,true);
708
+		if ($buffer != '' && is_array($all_data)) {
709 709
 		$reset = 0;
710 710
 		foreach ($all_data as $line) {
711
-	    	    $data = array();
712
-	    	    //$data['id'] = $line['id']; // id not usable
713
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
714
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
715
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
716
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
717
-	    	    $data['ident'] = $line['flightnum']; // ident
718
-	    	    $data['altitude'] = $line['alt']; // altitude
719
-	    	    $data['speed'] = $line['gs']; // speed
720
-	    	    $data['heading'] = $line['heading']; // heading
721
-	    	    $data['latitude'] = $line['lat']; // lat
722
-	    	    $data['longitude'] = $line['lng']; // long
723
-	    	    $data['verticalrate'] = ''; // verticale rate
724
-	    	    $data['squawk'] = ''; // squawk
725
-	    	    $data['emergency'] = ''; // emergency
726
-	    	    //$data['datetime'] = $line['lastupdate'];
727
-	    	    $data['last_update'] = $line['lastupdate'];
728
-		    $data['datetime'] = date('Y-m-d H:i:s');
729
-	    	    $data['departure_airport_icao'] = $line['depicao'];
730
-	    	    $data['departure_airport_time'] = $line['deptime'];
731
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
732
-    		    $data['arrival_airport_time'] = $line['arrtime'];
733
-    		    $data['registration'] = $line['aircraft'];
734
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
735
-		    if (isset($line['aircraftname'])) {
711
+				$data = array();
712
+				//$data['id'] = $line['id']; // id not usable
713
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
714
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
715
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
716
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
717
+				$data['ident'] = $line['flightnum']; // ident
718
+				$data['altitude'] = $line['alt']; // altitude
719
+				$data['speed'] = $line['gs']; // speed
720
+				$data['heading'] = $line['heading']; // heading
721
+				$data['latitude'] = $line['lat']; // lat
722
+				$data['longitude'] = $line['lng']; // long
723
+				$data['verticalrate'] = ''; // verticale rate
724
+				$data['squawk'] = ''; // squawk
725
+				$data['emergency'] = ''; // emergency
726
+				//$data['datetime'] = $line['lastupdate'];
727
+				$data['last_update'] = $line['lastupdate'];
728
+			$data['datetime'] = date('Y-m-d H:i:s');
729
+				$data['departure_airport_icao'] = $line['depicao'];
730
+				$data['departure_airport_time'] = $line['deptime'];
731
+				$data['arrival_airport_icao'] = $line['arricao'];
732
+				$data['arrival_airport_time'] = $line['arrtime'];
733
+				$data['registration'] = $line['aircraft'];
734
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
735
+			if (isset($line['aircraftname'])) {
736 736
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
737 737
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
738
-	    		$aircraft_data = explode('-',$line['aircraftname']);
739
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
740
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
741
-	    		else {
742
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
743
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
744
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
745
-	    		}
746
-	    	    }
747
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
748
-    		    $data['id_source'] = $id_source;
749
-	    	    $data['format_source'] = 'phpvmacars';
750
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
751
-		    $SI->add($data);
752
-		    unset($data);
738
+				$aircraft_data = explode('-',$line['aircraftname']);
739
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
740
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
741
+				else {
742
+					$aircraft_data = explode(' ',$line['aircraftname']);
743
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
744
+					else $data['aircraft_icao'] = $line['aircraftname'];
745
+				}
746
+				}
747
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
748
+				$data['id_source'] = $id_source;
749
+				$data['format_source'] = 'phpvmacars';
750
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
751
+			$SI->add($data);
752
+			unset($data);
753 753
 		}
754 754
 		if ($globalDebug) echo 'No more data...'."\n";
755 755
 		unset($buffer);
756 756
 		unset($all_data);
757
-	    }
758
-    	    //$last_exec['phpvmacars'] = time();
759
-    	    $last_exec[$id]['last'] = time();
760
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
761
-	    //$buffer = $Common->getData($hosts[$id]);
762
-	    if ($globalDebug) echo 'Get Data...'."\n";
763
-	    $buffer = $Common->getData($value['host']);
764
-	    $all_data = json_decode($buffer,true);
765
-	    if ($buffer != '' && is_array($all_data)) {
757
+		}
758
+			//$last_exec['phpvmacars'] = time();
759
+			$last_exec[$id]['last'] = time();
760
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
761
+		//$buffer = $Common->getData($hosts[$id]);
762
+		if ($globalDebug) echo 'Get Data...'."\n";
763
+		$buffer = $Common->getData($value['host']);
764
+		$all_data = json_decode($buffer,true);
765
+		if ($buffer != '' && is_array($all_data)) {
766 766
 		$reset = 0;
767 767
 		foreach ($all_data as $line) {
768
-	    	    $data = array();
769
-	    	    //$data['id'] = $line['id']; // id not usable
770
-	    	    $data['id'] = trim($line['flight_id']);
771
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
772
-	    	    $data['pilot_name'] = $line['pilot_name'];
773
-	    	    $data['pilot_id'] = $line['pilot_id'];
774
-	    	    $data['ident'] = trim($line['callsign']); // ident
775
-	    	    $data['altitude'] = $line['altitude']; // altitude
776
-	    	    $data['speed'] = $line['gs']; // speed
777
-	    	    $data['heading'] = $line['heading']; // heading
778
-	    	    $data['latitude'] = $line['latitude']; // lat
779
-	    	    $data['longitude'] = $line['longitude']; // long
780
-	    	    $data['verticalrate'] = ''; // verticale rate
781
-	    	    $data['squawk'] = ''; // squawk
782
-	    	    $data['emergency'] = ''; // emergency
783
-	    	    //$data['datetime'] = $line['lastupdate'];
784
-	    	    $data['last_update'] = $line['last_update'];
785
-		    $data['datetime'] = date('Y-m-d H:i:s');
786
-	    	    $data['departure_airport_icao'] = $line['departure'];
787
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
788
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
789
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
790
-    		    //$data['registration'] = $line['aircraft'];
791
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
792
-	    	    $data['aircraft_icao'] = $line['plane_type'];
793
-    		    $data['id_source'] = $id_source;
794
-	    	    $data['format_source'] = 'vam';
795
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
796
-		    $SI->add($data);
797
-		    unset($data);
768
+				$data = array();
769
+				//$data['id'] = $line['id']; // id not usable
770
+				$data['id'] = trim($line['flight_id']);
771
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
772
+				$data['pilot_name'] = $line['pilot_name'];
773
+				$data['pilot_id'] = $line['pilot_id'];
774
+				$data['ident'] = trim($line['callsign']); // ident
775
+				$data['altitude'] = $line['altitude']; // altitude
776
+				$data['speed'] = $line['gs']; // speed
777
+				$data['heading'] = $line['heading']; // heading
778
+				$data['latitude'] = $line['latitude']; // lat
779
+				$data['longitude'] = $line['longitude']; // long
780
+				$data['verticalrate'] = ''; // verticale rate
781
+				$data['squawk'] = ''; // squawk
782
+				$data['emergency'] = ''; // emergency
783
+				//$data['datetime'] = $line['lastupdate'];
784
+				$data['last_update'] = $line['last_update'];
785
+			$data['datetime'] = date('Y-m-d H:i:s');
786
+				$data['departure_airport_icao'] = $line['departure'];
787
+				//$data['departure_airport_time'] = $line['departure_time'];
788
+				$data['arrival_airport_icao'] = $line['arrival'];
789
+				//$data['arrival_airport_time'] = $line['arrival_time'];
790
+				//$data['registration'] = $line['aircraft'];
791
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
792
+				$data['aircraft_icao'] = $line['plane_type'];
793
+				$data['id_source'] = $id_source;
794
+				$data['format_source'] = 'vam';
795
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
796
+			$SI->add($data);
797
+			unset($data);
798 798
 		}
799 799
 		if ($globalDebug) echo 'No more data...'."\n";
800 800
 		unset($buffer);
801 801
 		unset($all_data);
802
-	    }
803
-    	    //$last_exec['phpvmacars'] = time();
804
-    	    $last_exec[$id]['last'] = time();
802
+		}
803
+			//$last_exec['phpvmacars'] = time();
804
+			$last_exec[$id]['last'] = time();
805 805
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
806 806
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3') {
807
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
808
-    	    //$last_exec[$id]['last'] = time();
807
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
808
+			//$last_exec[$id]['last'] = time();
809 809
 
810
-	    //$read = array( $sockets[$id] );
811
-	    $read = $sockets;
812
-	    $write = NULL;
813
-	    $e = NULL;
814
-	    $n = socket_select($read, $write, $e, $timeout);
815
-	    if ($e != NULL) var_dump($e);
816
-	    if ($n > 0) {
810
+		//$read = array( $sockets[$id] );
811
+		$read = $sockets;
812
+		$write = NULL;
813
+		$e = NULL;
814
+		$n = socket_select($read, $write, $e, $timeout);
815
+		if ($e != NULL) var_dump($e);
816
+		if ($n > 0) {
817 817
 		$reset = 0;
818 818
 		foreach ($read as $nb => $r) {
819
-		    //$value = $formats[$nb];
820
-		    $format = $globalSources[$nb]['format'];
821
-        	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
822
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
823
-        	    } else {
824
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
825
-	    	    }
826
-        	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
827
-        	    //echo $buffer."\n";
828
-		    // lets play nice and handle signals such as ctrl-c/kill properly
829
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
830
-		    $error = false;
831
-		    //$SI::del();
832
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
833
-		    // SBS format is CSV format
834
-		    if ($buffer != '') {
819
+			//$value = $formats[$nb];
820
+			$format = $globalSources[$nb]['format'];
821
+				if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
822
+				$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
823
+				} else {
824
+					$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
825
+				}
826
+				//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
827
+				//echo $buffer."\n";
828
+			// lets play nice and handle signals such as ctrl-c/kill properly
829
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
830
+			$error = false;
831
+			//$SI::del();
832
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
833
+			// SBS format is CSV format
834
+			if ($buffer != '') {
835 835
 			$tt[$format] = 0;
836 836
 			if ($format == 'acarssbs3') {
837
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
838
-			    $ACARS->add(trim($buffer));
839
-			    $ACARS->deleteLiveAcarsData();
837
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
838
+				$ACARS->add(trim($buffer));
839
+				$ACARS->deleteLiveAcarsData();
840 840
 			} elseif ($format == 'raw') {
841
-			    // AVR format
842
-			    $data = $SBS->parse($buffer);
843
-			    if (is_array($data)) {
841
+				// AVR format
842
+				$data = $SBS->parse($buffer);
843
+				if (is_array($data)) {
844 844
 				$data['datetime'] = date('Y-m-d H:i:s');
845 845
 				$data['format_source'] = 'raw';
846 846
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
847
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
848
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
849
-                            }
850
-                        } elseif ($format == 'flightgearsp') {
851
-                    	    //echo $buffer."\n";
852
-                    	    if (strlen($buffer) > 5) {
847
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
848
+								if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
849
+							}
850
+						} elseif ($format == 'flightgearsp') {
851
+							//echo $buffer."\n";
852
+							if (strlen($buffer) > 5) {
853 853
 				$line = explode(',',$buffer);
854 854
 				$data = array();
855 855
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -865,114 +865,114 @@  discard block
 block discarded – undo
865 865
 				$data['format_source'] = 'flightgearsp';
866 866
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
867 867
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
868
-			    }
869
-                        } elseif ($format == 'acars') {
870
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
871
-			    $ACARS->add(trim($buffer));
872
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
873
-			    $ACARS->deleteLiveAcarsData();
868
+				}
869
+						} elseif ($format == 'acars') {
870
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
871
+				$ACARS->add(trim($buffer));
872
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
873
+				$ACARS->deleteLiveAcarsData();
874 874
 			} elseif ($format == 'flightgearmp') {
875
-			    if (substr($buffer,0,1) != '#') {
875
+				if (substr($buffer,0,1) != '#') {
876 876
 				$data = array();
877 877
 				//echo $buffer."\n";
878 878
 				$line = explode(' ',$buffer);
879 879
 				if (count($line) == 11) {
880
-				    $userserver = explode('@',$line[0]);
881
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
882
-				    $data['ident'] = $userserver[0];
883
-				    $data['registration'] = $userserver[0];
884
-				    $data['latitude'] = $line[4];
885
-				    $data['longitude'] = $line[5];
886
-				    $data['altitude'] = $line[6];
887
-				    $data['datetime'] = date('Y-m-d H:i:s');
888
-				    $aircraft_type = $line[10];
889
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
890
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
891
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
880
+					$userserver = explode('@',$line[0]);
881
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
882
+					$data['ident'] = $userserver[0];
883
+					$data['registration'] = $userserver[0];
884
+					$data['latitude'] = $line[4];
885
+					$data['longitude'] = $line[5];
886
+					$data['altitude'] = $line[6];
887
+					$data['datetime'] = date('Y-m-d H:i:s');
888
+					$aircraft_type = $line[10];
889
+					$aircraft_type = preg_split(':/:',$aircraft_type);
890
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
891
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
892
+				}
892 893
 				}
893
-			    }
894 894
 			} elseif ($format == 'beast') {
895
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
896
-			    die;
895
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
896
+				die;
897 897
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
898
-			    $line = explode("\t", $buffer);
899
-			    for($k = 0; $k < count($line); $k=$k+2) {
898
+				$line = explode("\t", $buffer);
899
+				for($k = 0; $k < count($line); $k=$k+2) {
900 900
 				$key = $line[$k];
901
-			        $lined[$key] = $line[$k+1];
902
-			    }
903
-    			    if (count($lined) > 3) {
904
-    				$data['hex'] = $lined['hexid'];
905
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
906
-    				$data['datetime'] = date('Y-m-d H:i:s');;
907
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
908
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
909
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
910
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
911
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
912
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
913
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
914
-    				$data['id_source'] = $id_source;
915
-    				$data['format_source'] = 'tsv';
916
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
917
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
918
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
919
-    				unset($lined);
920
-    				unset($data);
921
-    			    } else $error = true;
901
+					$lined[$key] = $line[$k+1];
902
+				}
903
+					if (count($lined) > 3) {
904
+					$data['hex'] = $lined['hexid'];
905
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
906
+					$data['datetime'] = date('Y-m-d H:i:s');;
907
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
908
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
909
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
910
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
911
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
912
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
913
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
914
+					$data['id_source'] = $id_source;
915
+					$data['format_source'] = 'tsv';
916
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
917
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
918
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
919
+					unset($lined);
920
+					unset($data);
921
+					} else $error = true;
922 922
 			} elseif ($format == 'aprs' && $use_aprs) {
923
-			    if ($aprs_connect == 0) {
923
+				if ($aprs_connect == 0) {
924 924
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
925 925
 				$aprs_connect = 1;
926
-			    }
927
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
926
+				}
927
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
928 928
 				$aprs_last_tx = time();
929 929
 				$data_aprs = "# Keep alive";
930 930
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
931
-			    }
932
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
933
-			    $buffer = str_replace('APRS <- ','',$buffer);
934
-			    $buffer = str_replace('APRS -> ','',$buffer);
935
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
931
+				}
932
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
933
+				$buffer = str_replace('APRS <- ','',$buffer);
934
+				$buffer = str_replace('APRS -> ','',$buffer);
935
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
936 936
 				$line = $APRS->parse($buffer);
937 937
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
938
-				    $data = array();
939
-				    //print_r($line);
940
-				    $data['hex'] = $line['address'];
941
-				    $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
942
-				    //$data['datetime'] = date('Y-m-d H:i:s');
943
-				    $data['ident'] = $line['ident'];
944
-				    $data['latitude'] = $line['latitude'];
945
-				    $data['longitude'] = $line['longitude'];
946
-				    //$data['verticalrate'] = $line[16];
947
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
948
-				    else $data['speed'] = 0;
949
-				    $data['altitude'] = $line['altitude'];
950
-				    if (isset($line['course'])) $data['heading'] = $line['course'];
951
-				    //else $data['heading'] = 0;
952
-				    $data['aircraft_type'] = $line['stealth'];
953
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
954
-    				    $data['id_source'] = $id_source;
955
-				    $data['format_source'] = 'aprs';
956
-				    $data['source_name'] = $line['source'];
957
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
958
-				    $currentdate = date('Y-m-d H:i:s');
959
-				    $aprsdate = strtotime($data['datetime']);
960
-				    // Accept data if time <= system time + 20s
961
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
962
-				    else {
938
+					$data = array();
939
+					//print_r($line);
940
+					$data['hex'] = $line['address'];
941
+					$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
942
+					//$data['datetime'] = date('Y-m-d H:i:s');
943
+					$data['ident'] = $line['ident'];
944
+					$data['latitude'] = $line['latitude'];
945
+					$data['longitude'] = $line['longitude'];
946
+					//$data['verticalrate'] = $line[16];
947
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
948
+					else $data['speed'] = 0;
949
+					$data['altitude'] = $line['altitude'];
950
+					if (isset($line['course'])) $data['heading'] = $line['course'];
951
+					//else $data['heading'] = 0;
952
+					$data['aircraft_type'] = $line['stealth'];
953
+					if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
954
+						$data['id_source'] = $id_source;
955
+					$data['format_source'] = 'aprs';
956
+					$data['source_name'] = $line['source'];
957
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
958
+					$currentdate = date('Y-m-d H:i:s');
959
+					$aprsdate = strtotime($data['datetime']);
960
+					// Accept data if time <= system time + 20s
961
+					if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
962
+					else {
963 963
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
964 964
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
965
-				    }
966
-				    unset($data);
965
+					}
966
+					unset($data);
967 967
 				} 
968 968
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
969 969
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
970
-			    }
970
+				}
971 971
 			} else {
972
-			    $line = explode(',', $buffer);
973
-    			    if (count($line) > 20) {
974
-    			    	$data['hex'] = $line[4];
975
-    				/*
972
+				$line = explode(',', $buffer);
973
+					if (count($line) > 20) {
974
+						$data['hex'] = $line[4];
975
+					/*
976 976
     				$data['datetime'] = $line[6].' '.$line[7];
977 977
     					date_default_timezone_set($globalTimezone);
978 978
     					$datetime = new DateTime($data['datetime']);
@@ -980,29 +980,29 @@  discard block
 block discarded – undo
980 980
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
981 981
     					date_default_timezone_set('UTC');
982 982
     				*/
983
-    				// Force datetime to current UTC datetime
984
-    				date_default_timezone_set('UTC');
985
-    				$data['datetime'] = date('Y-m-d H:i:s');
986
-    				$data['ident'] = trim($line[10]);
987
-    				$data['latitude'] = $line[14];
988
-    				$data['longitude'] = $line[15];
989
-    				$data['verticalrate'] = $line[16];
990
-    				$data['emergency'] = $line[20];
991
-    				$data['speed'] = $line[12];
992
-    				$data['squawk'] = $line[17];
993
-    				$data['altitude'] = $line[11];
994
-    				$data['heading'] = $line[13];
995
-    				$data['ground'] = $line[21];
996
-    				$data['emergency'] = $line[19];
997
-    				$data['format_source'] = 'sbs';
983
+					// Force datetime to current UTC datetime
984
+					date_default_timezone_set('UTC');
985
+					$data['datetime'] = date('Y-m-d H:i:s');
986
+					$data['ident'] = trim($line[10]);
987
+					$data['latitude'] = $line[14];
988
+					$data['longitude'] = $line[15];
989
+					$data['verticalrate'] = $line[16];
990
+					$data['emergency'] = $line[20];
991
+					$data['speed'] = $line[12];
992
+					$data['squawk'] = $line[17];
993
+					$data['altitude'] = $line[11];
994
+					$data['heading'] = $line[13];
995
+					$data['ground'] = $line[21];
996
+					$data['emergency'] = $line[19];
997
+					$data['format_source'] = 'sbs';
998 998
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
999
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1000
-    				$data['id_source'] = $id_source;
1001
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1002
-    				else $error = true;
1003
-    				unset($data);
1004
-    			    } else $error = true;
1005
-			    if ($error) {
999
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1000
+					$data['id_source'] = $id_source;
1001
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1002
+					else $error = true;
1003
+					unset($data);
1004
+					} else $error = true;
1005
+				if ($error) {
1006 1006
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1007 1007
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1008 1008
 				} else {
@@ -1018,13 +1018,13 @@  discard block
 block discarded – undo
1018 1018
 					connect_all($sourceer);
1019 1019
 					$sourceer = array();
1020 1020
 				}
1021
-			    }
1021
+				}
1022 1022
 			}
1023 1023
 			// Sleep for xxx microseconds
1024 1024
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1025
-		    } else {
1025
+			} else {
1026 1026
 			if ($format == 'flightgearmp') {
1027
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1027
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1028 1028
 				//@socket_close($r);
1029 1029
 				sleep($globalMinFetch);
1030 1030
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1033,9 +1033,9 @@  discard block
 block discarded – undo
1033 1033
 				break;
1034 1034
 				
1035 1035
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1036
-			    if (isset($tt[$format])) $tt[$format]++;
1037
-			    else $tt[$format] = 0;
1038
-			    if ($tt[$format] > 30) {
1036
+				if (isset($tt[$format])) $tt[$format]++;
1037
+				else $tt[$format] = 0;
1038
+				if ($tt[$format] > 30) {
1039 1039
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1040 1040
 				//@socket_close($r);
1041 1041
 				sleep(2);
@@ -1046,23 +1046,23 @@  discard block
 block discarded – undo
1046 1046
 				//connect_all($globalSources);
1047 1047
 				$tt[$format]=0;
1048 1048
 				break;
1049
-			    }
1049
+				}
1050
+			}
1050 1051
 			}
1051
-		    }
1052 1052
 		}
1053
-	    } else {
1053
+		} else {
1054 1054
 		$error = socket_strerror(socket_last_error());
1055 1055
 		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1056 1056
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1057 1057
 			if (isset($globalDebug)) echo "Restarting...\n";
1058 1058
 			// Restart the script if possible
1059 1059
 			if (is_array($sockets)) {
1060
-			    if ($globalDebug) echo "Shutdown all sockets...";
1060
+				if ($globalDebug) echo "Shutdown all sockets...";
1061 1061
 			    
1062
-			    foreach ($sockets as $sock) {
1062
+				foreach ($sockets as $sock) {
1063 1063
 				@socket_shutdown($sock,2);
1064 1064
 				@socket_close($sock);
1065
-			    }
1065
+				}
1066 1066
 			    
1067 1067
 			}
1068 1068
 			if ($globalDebug) echo "Restart all connections...";
@@ -1073,13 +1073,13 @@  discard block
 block discarded – undo
1073 1073
 			if ($reset > 40) exit('Too many attempts...');
1074 1074
 			connect_all($globalSources);
1075 1075
 		}
1076
-	    }
1076
+		}
1077 1077
 	}
1078 1078
 	if ($globalDaemon === false) {
1079
-	    if ($globalDebug) echo 'Check all...'."\n";
1080
-	    $SI->checkAll();
1079
+		if ($globalDebug) echo 'Check all...'."\n";
1080
+		$SI->checkAll();
1081
+	}
1081 1082
 	}
1082
-    }
1083 1083
 }
1084 1084
 
1085 1085
 ?>
Please login to merge, or discard this patch.
require/class.Stats.php 4 patches
Doc Comments   +31 added lines patch added patch discarded remove patch
@@ -17,6 +17,10 @@  discard block
 block discarded – undo
17 17
 		$this->db = $Connection->db();
18 18
         }
19 19
               
20
+	/**
21
+	 * @param string $type
22
+	 * @param string $stats_date
23
+	 */
20 24
 	public function addLastStatsUpdate($type,$stats_date) {
21 25
                 $query = "DELETE FROM config WHERE name = :type;
22 26
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
@@ -827,6 +831,11 @@  discard block
 block discarded – undo
827 831
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
828 832
                 return $all;
829 833
         }
834
+
835
+	/**
836
+	 * @param string $type
837
+	 * @param string $year
838
+	 */
830 839
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
831 840
 		if ($filter_name == '') $filter_name = $this->filter_name;
832 841
     		global $globalArchiveMonths, $globalDBdriver;
@@ -943,6 +952,10 @@  discard block
 block discarded – undo
943 952
                 return $all[0]['total'];
944 953
         }
945 954
 
955
+	/**
956
+	 * @param string $type
957
+	 * @param string $stats_date
958
+	 */
946 959
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
947 960
 		global $globalDBdriver;
948 961
 		if ($filter_name == '') $filter_name = $this->filter_name;
@@ -996,6 +1009,9 @@  discard block
 block discarded – undo
996 1009
         }
997 1010
         */
998 1011
 
1012
+	/**
1013
+	 * @param string $stats_type
1014
+	 */
999 1015
 	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1000 1016
 		global $globalDBdriver;
1001 1017
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
@@ -1039,6 +1055,9 @@  discard block
 block discarded – undo
1039 1055
 		return $all;
1040 1056
 	}
1041 1057
 
1058
+	/**
1059
+	 * @param string $stats_type
1060
+	 */
1042 1061
 	public function addStatSource($data,$source_name,$stats_type,$date) {
1043 1062
 		global $globalDBdriver;
1044 1063
 		if ($globalDBdriver == 'mysql') {
@@ -1054,6 +1073,10 @@  discard block
 block discarded – undo
1054 1073
                         return "error : ".$e->getMessage();
1055 1074
                 }
1056 1075
         }
1076
+
1077
+	/**
1078
+	 * @param string $type
1079
+	 */
1057 1080
 	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1058 1081
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1059 1082
                 $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
@@ -1320,6 +1343,10 @@  discard block
 block discarded – undo
1320 1343
                         return "error : ".$e->getMessage();
1321 1344
                 }
1322 1345
         }
1346
+
1347
+	/**
1348
+	 * @param string $type
1349
+	 */
1323 1350
 	public function deleteStatFlight($type) {
1324 1351
                 $query = "DELETE FROM stats_flight WHERE stats_type = :type";
1325 1352
                 $query_values = array(':type' => $type);
@@ -1330,6 +1357,10 @@  discard block
 block discarded – undo
1330 1357
                         return "error : ".$e->getMessage();
1331 1358
                 }
1332 1359
         }
1360
+
1361
+	/**
1362
+	 * @param string $type
1363
+	 */
1333 1364
 	public function deleteStatAirport($type) {
1334 1365
                 $query = "DELETE FROM stats_airport WHERE stats_type = :type";
1335 1366
                 $query_values = array(':type' => $type);
Please login to merge, or discard this patch.
Indentation   +757 added lines, -757 removed lines patch added patch discarded remove patch
@@ -15,33 +15,33 @@  discard block
 block discarded – undo
15 15
 		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
16 16
 		$Connection = new Connection($dbc);
17 17
 		$this->db = $Connection->db();
18
-        }
18
+		}
19 19
               
20 20
 	public function addLastStatsUpdate($type,$stats_date) {
21
-                $query = "DELETE FROM config WHERE name = :type;
21
+				$query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
24
-                 try {
25
-                        $sth = $this->db->prepare($query);
26
-                        $sth->execute($query_values);
27
-                } catch(PDOException $e) {
28
-                        return "error : ".$e->getMessage();
29
-                }
30
-        }
23
+				$query_values = array('type' => $type,':stats_date' => $stats_date);
24
+				 try {
25
+						$sth = $this->db->prepare($query);
26
+						$sth->execute($query_values);
27
+				} catch(PDOException $e) {
28
+						return "error : ".$e->getMessage();
29
+				}
30
+		}
31 31
 
32 32
 	public function getLastStatsUpdate($type = 'last_update_stats') {
33
-                $query = "SELECT value FROM config WHERE name = :type";
34
-                 try {
35
-                        $sth = $this->db->prepare($query);
36
-                        $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
38
-                        echo "error : ".$e->getMessage();
39
-                }
40
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
41
-                return $all;
42
-        }
43
-        public function deleteStats($filter_name = '') {
44
-        	/*
33
+				$query = "SELECT value FROM config WHERE name = :type";
34
+				 try {
35
+						$sth = $this->db->prepare($query);
36
+						$sth->execute(array(':type' => $type));
37
+				} catch(PDOException $e) {
38
+						echo "error : ".$e->getMessage();
39
+				}
40
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
41
+				return $all;
42
+		}
43
+		public function deleteStats($filter_name = '') {
44
+			/*
45 45
         	$query = "DELETE FROM config WHERE name = 'last_update_stats'";
46 46
                  try {
47 47
                         $sth = $this->db->prepare($query);
@@ -50,106 +50,106 @@  discard block
 block discarded – undo
50 50
                         return "error : ".$e->getMessage();
51 51
                 }
52 52
                 */
53
-        	$query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
54
-                 try {
55
-                        $sth = $this->db->prepare($query);
56
-                        $sth->execute(array(':filter_name' => $filter_name));
57
-                } catch(PDOException $e) {
58
-                        return "error : ".$e->getMessage();
59
-                }
60
-        }
61
-        public function deleteOldStats($filter_name = '') {
53
+			$query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
54
+				 try {
55
+						$sth = $this->db->prepare($query);
56
+						$sth->execute(array(':filter_name' => $filter_name));
57
+				} catch(PDOException $e) {
58
+						return "error : ".$e->getMessage();
59
+				}
60
+		}
61
+		public function deleteOldStats($filter_name = '') {
62 62
         	
63
-        	$query = "DELETE FROM config WHERE name = 'last_update_stats'";
64
-                 try {
65
-                        $sth = $this->db->prepare($query);
66
-                        $sth->execute();
67
-                } catch(PDOException $e) {
68
-                        return "error : ".$e->getMessage();
69
-                }
63
+			$query = "DELETE FROM config WHERE name = 'last_update_stats'";
64
+				 try {
65
+						$sth = $this->db->prepare($query);
66
+						$sth->execute();
67
+				} catch(PDOException $e) {
68
+						return "error : ".$e->getMessage();
69
+				}
70 70
                 
71
-        	$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
72
-                 try {
73
-                        $sth = $this->db->prepare($query);
74
-                        $sth->execute(array(':filter_name' => $filter_name));
75
-                } catch(PDOException $e) {
76
-                        return "error : ".$e->getMessage();
77
-                }
78
-        }
71
+			$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
72
+				 try {
73
+						$sth = $this->db->prepare($query);
74
+						$sth->execute(array(':filter_name' => $filter_name));
75
+				} catch(PDOException $e) {
76
+						return "error : ".$e->getMessage();
77
+				}
78
+		}
79 79
 	public function getAllAirlineNames($filter_name = '') {
80 80
 		if ($filter_name == '') $filter_name = $this->filter_name;
81
-                $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82
-                 try {
83
-                        $sth = $this->db->prepare($query);
84
-                        $sth->execute(array(':filter_name' => $filter_name));
85
-                } catch(PDOException $e) {
86
-                        echo "error : ".$e->getMessage();
87
-                }
88
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
89
-                return $all;
90
-        }
81
+				$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82
+				 try {
83
+						$sth = $this->db->prepare($query);
84
+						$sth->execute(array(':filter_name' => $filter_name));
85
+				} catch(PDOException $e) {
86
+						echo "error : ".$e->getMessage();
87
+				}
88
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
89
+				return $all;
90
+		}
91 91
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
92 92
 		if ($filter_name == '') $filter_name = $this->filter_name;
93
-                $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94
-                 try {
95
-                        $sth = $this->db->prepare($query);
96
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
-                } catch(PDOException $e) {
98
-                        echo "error : ".$e->getMessage();
99
-                }
100
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
101
-                return $all;
102
-        }
93
+				$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94
+				 try {
95
+						$sth = $this->db->prepare($query);
96
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
+				} catch(PDOException $e) {
98
+						echo "error : ".$e->getMessage();
99
+				}
100
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
101
+				return $all;
102
+		}
103 103
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
104 104
 		if ($filter_name == '') $filter_name = $this->filter_name;
105
-                $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106
-                 try {
107
-                        $sth = $this->db->prepare($query);
108
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
-                } catch(PDOException $e) {
110
-                        echo "error : ".$e->getMessage();
111
-                }
112
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
113
-                return $all;
114
-        }
105
+				$query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106
+				 try {
107
+						$sth = $this->db->prepare($query);
108
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
+				} catch(PDOException $e) {
110
+						echo "error : ".$e->getMessage();
111
+				}
112
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
113
+				return $all;
114
+		}
115 115
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
116 116
 		if ($filter_name == '') $filter_name = $this->filter_name;
117
-                $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118
-                 try {
119
-                        $sth = $this->db->prepare($query);
120
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
-                } catch(PDOException $e) {
122
-                        echo "error : ".$e->getMessage();
123
-                }
124
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
125
-                return $all;
126
-        }
117
+				$query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118
+				 try {
119
+						$sth = $this->db->prepare($query);
120
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
+				} catch(PDOException $e) {
122
+						echo "error : ".$e->getMessage();
123
+				}
124
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
125
+				return $all;
126
+		}
127 127
 
128 128
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
129 129
 		if ($filter_name == '') $filter_name = $this->filter_name;
130
-                $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131
-                 try {
132
-                        $sth = $this->db->prepare($query);
133
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
134
-                } catch(PDOException $e) {
135
-                        echo "error : ".$e->getMessage();
136
-                }
137
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
138
-                return $all;
139
-        }
130
+				$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131
+				 try {
132
+						$sth = $this->db->prepare($query);
133
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
134
+				} catch(PDOException $e) {
135
+						echo "error : ".$e->getMessage();
136
+				}
137
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
138
+				return $all;
139
+		}
140 140
 
141 141
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
142 142
 		if ($filter_name == '') $filter_name = $this->filter_name;
143
-                $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144
-                 try {
145
-                        $sth = $this->db->prepare($query);
146
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
147
-                } catch(PDOException $e) {
148
-                        echo "error : ".$e->getMessage();
149
-                }
150
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
151
-                return $all;
152
-        }
143
+				$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144
+				 try {
145
+						$sth = $this->db->prepare($query);
146
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
147
+				} catch(PDOException $e) {
148
+						echo "error : ".$e->getMessage();
149
+				}
150
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
151
+				return $all;
152
+		}
153 153
 
154 154
 
155 155
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
 			}
167 167
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
168 168
 		} else $all = array();
169
-                if (empty($all)) {
170
-            	    $filters = array('airlines' => array($stats_airline));
171
-            	    if ($filter_name != '') {
172
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
173
-            	    }
174
-            	    $Spotter = new Spotter($this->db);
175
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
176
-                }
177
-                return $all;
169
+				if (empty($all)) {
170
+					$filters = array('airlines' => array($stats_airline));
171
+					if ($filter_name != '') {
172
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
173
+					}
174
+					$Spotter = new Spotter($this->db);
175
+					$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
176
+				}
177
+				return $all;
178 178
 	}
179 179
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
180 180
 		global $globalStatsFilters;
@@ -190,15 +190,15 @@  discard block
 block discarded – undo
190 190
 			}
191 191
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
192 192
 		} else $all = array();
193
-                if (empty($all)) {
194
-            		$Spotter = new Spotter($this->db);
195
-            		$filters = array();
196
-            		if ($filter_name != '') {
197
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
193
+				if (empty($all)) {
194
+					$Spotter = new Spotter($this->db);
195
+					$filters = array();
196
+					if ($filter_name != '') {
197
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
198 198
 			}
199
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
200
-                }
201
-                return $all;
199
+					$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
200
+				}
201
+				return $all;
202 202
 	}
203 203
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
204 204
 		global $globalStatsFilters;
@@ -239,37 +239,37 @@  discard block
 block discarded – undo
239 239
 			}
240 240
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
241 241
 		} else $all = array();
242
-                if (empty($all)) {
242
+				if (empty($all)) {
243 243
 			$filters = array('airlines' => array($stats_airline));
244 244
 			if ($filter_name != '') {
245
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
245
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
246 246
 			}
247 247
 			$Spotter = new Spotter($this->db);
248 248
 			$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
249
-                }
250
-                return $all;
249
+				}
250
+				return $all;
251 251
 	}
252 252
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
253 253
 		global $globalStatsFilters;
254 254
 		if ($filter_name == '') $filter_name = $this->filter_name;
255 255
 		if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
256 256
 		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
257
-                 try {
258
-                        $sth = $this->db->prepare($query);
259
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
260
-                } catch(PDOException $e) {
261
-                        echo "error : ".$e->getMessage();
262
-                }
263
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
264
-                if (empty($all)) {
257
+				 try {
258
+						$sth = $this->db->prepare($query);
259
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
260
+				} catch(PDOException $e) {
261
+						echo "error : ".$e->getMessage();
262
+				}
263
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
264
+				if (empty($all)) {
265 265
 			$filters = array('airlines' => array($stats_airline));
266 266
 			if ($filter_name != '') {
267
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
267
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
268 268
 			}
269 269
 			$Spotter = new Spotter($this->db);
270 270
 			$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
271
-                }
272
-                return $all;
271
+				}
272
+				return $all;
273 273
 	}
274 274
 
275 275
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
@@ -286,16 +286,16 @@  discard block
 block discarded – undo
286 286
 			}
287 287
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
288 288
 		} else $all = array();
289
-                if (empty($all)) {
290
-	                $Spotter = new Spotter($this->db);
291
-            		$filters = array();
292
-            		if ($filter_name != '') {
293
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
289
+				if (empty($all)) {
290
+					$Spotter = new Spotter($this->db);
291
+					$filters = array();
292
+					if ($filter_name != '') {
293
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
294 294
 			}
295 295
 
296
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
297
-                }
298
-                return $all;
296
+					$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
297
+				}
298
+				return $all;
299 299
 	}
300 300
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
301 301
 		global $globalStatsFilters;
@@ -311,15 +311,15 @@  discard block
 block discarded – undo
311 311
 			}
312 312
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
313 313
 		} else $all = array();
314
-                if (empty($all)) {
314
+				if (empty($all)) {
315 315
 			$filters = array('airlines' => array($stats_airline));
316 316
 			if ($filter_name != '') {
317 317
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
318 318
 			}
319
-	                $Spotter = new Spotter($this->db);
320
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
321
-                }
322
-                return $all;
319
+					$Spotter = new Spotter($this->db);
320
+					$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
321
+				}
322
+				return $all;
323 323
 	}
324 324
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
325 325
 		global $globalStatsFilters;
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 					echo "error : ".$e->getMessage();
360 360
 				}
361 361
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
362
-                /*
362
+				/*
363 363
                 if (empty($all)) {
364 364
 	                $Spotter = new Spotter($this->db);
365 365
     		        $all = $Spotter->countAllFlightOverCountries($limit);
@@ -410,15 +410,15 @@  discard block
 block discarded – undo
410 410
 			}
411 411
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
412 412
 		} else $all = array();
413
-                if (empty($all)) {
413
+				if (empty($all)) {
414 414
 			$filters = array('airlines' => array($stats_airline));
415 415
 			if ($filter_name != '') {
416 416
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
417 417
 			}
418
-            		$Spotter = new Spotter($this->db);
419
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
420
-                }
421
-                return $all;
418
+					$Spotter = new Spotter($this->db);
419
+					$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
420
+				}
421
+				return $all;
422 422
 	}
423 423
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
424 424
 		global $globalStatsFilters;
@@ -434,33 +434,33 @@  discard block
 block discarded – undo
434 434
 			}
435 435
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
436 436
 		} else $all = array();
437
-                if (empty($all)) {
437
+				if (empty($all)) {
438 438
 			$filters = array('airlines' => array($stats_airline));
439
-            		if ($filter_name != '') {
440
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
441
-			}
442
-            		$Spotter = new Spotter($this->db);
443
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
444
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
445
-        		$all = array();
446
-        		foreach ($pall as $value) {
447
-        			$icao = $value['airport_departure_icao'];
448
-        			$all[$icao] = $value;
449
-        		}
439
+					if ($filter_name != '') {
440
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
441
+			}
442
+					$Spotter = new Spotter($this->db);
443
+					$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
444
+				$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
445
+				$all = array();
446
+				foreach ($pall as $value) {
447
+					$icao = $value['airport_departure_icao'];
448
+					$all[$icao] = $value;
449
+				}
450 450
         		
451
-        		foreach ($dall as $value) {
452
-        			$icao = $value['airport_departure_icao'];
453
-        			if (isset($all[$icao])) {
454
-        				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
455
-        			} else $all[$icao] = $value;
456
-        		}
457
-        		$count = array();
458
-        		foreach ($all as $key => $row) {
459
-        			$count[$key] = $row['airport_departure_icao_count'];
460
-        		}
461
-        		array_multisort($count,SORT_DESC,$all);
462
-                }
463
-                return $all;
451
+				foreach ($dall as $value) {
452
+					$icao = $value['airport_departure_icao'];
453
+					if (isset($all[$icao])) {
454
+						$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
455
+					} else $all[$icao] = $value;
456
+				}
457
+				$count = array();
458
+				foreach ($all as $key => $row) {
459
+					$count[$key] = $row['airport_departure_icao_count'];
460
+				}
461
+				array_multisort($count,SORT_DESC,$all);
462
+				}
463
+				return $all;
464 464
 	}
465 465
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
466 466
 		global $globalStatsFilters;
@@ -484,26 +484,26 @@  discard block
 block discarded – undo
484 484
 			$Spotter = new Spotter($this->db);
485 485
 			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
486 486
 			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
487
-        		$all = array();
488
-        		foreach ($pall as $value) {
489
-        			$icao = $value['airport_arrival_icao'];
490
-        			$all[$icao] = $value;
491
-        		}
487
+				$all = array();
488
+				foreach ($pall as $value) {
489
+					$icao = $value['airport_arrival_icao'];
490
+					$all[$icao] = $value;
491
+				}
492 492
         		
493
-        		foreach ($dall as $value) {
494
-        			$icao = $value['airport_arrival_icao'];
495
-        			if (isset($all[$icao])) {
496
-        				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
497
-        			} else $all[$icao] = $value;
498
-        		}
499
-        		$count = array();
500
-        		foreach ($all as $key => $row) {
501
-        			$count[$key] = $row['airport_arrival_icao_count'];
502
-        		}
503
-        		array_multisort($count,SORT_DESC,$all);
504
-                }
493
+				foreach ($dall as $value) {
494
+					$icao = $value['airport_arrival_icao'];
495
+					if (isset($all[$icao])) {
496
+						$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
497
+					} else $all[$icao] = $value;
498
+				}
499
+				$count = array();
500
+				foreach ($all as $key => $row) {
501
+					$count[$key] = $row['airport_arrival_icao_count'];
502
+				}
503
+				array_multisort($count,SORT_DESC,$all);
504
+				}
505 505
  
506
-                return $all;
506
+				return $all;
507 507
 	}
508 508
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
509 509
 		global $globalDBdriver, $globalStatsFilters;
@@ -516,23 +516,23 @@  discard block
 block discarded – undo
516 516
 			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
517 517
 		}
518 518
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
519
-                 try {
520
-                        $sth = $this->db->prepare($query);
521
-                        $sth->execute($query_data);
522
-                } catch(PDOException $e) {
523
-                        echo "error : ".$e->getMessage();
524
-                }
525
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
526
-                if (empty($all)) {
519
+				 try {
520
+						$sth = $this->db->prepare($query);
521
+						$sth->execute($query_data);
522
+				} catch(PDOException $e) {
523
+						echo "error : ".$e->getMessage();
524
+				}
525
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
526
+				if (empty($all)) {
527 527
 			$filters = array('airlines' => array($stats_airline));
528 528
 			if ($filter_name != '') {
529 529
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
530 530
 			}
531
-            		$Spotter = new Spotter($this->db);
532
-            		$all = $Spotter->countAllMonthsLastYear($filters);
533
-                }
531
+					$Spotter = new Spotter($this->db);
532
+					$all = $Spotter->countAllMonthsLastYear($filters);
533
+				}
534 534
                 
535
-                return $all;
535
+				return $all;
536 536
 	}
537 537
 	
538 538
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
@@ -540,22 +540,22 @@  discard block
 block discarded – undo
540 540
 		if ($filter_name == '') $filter_name = $this->filter_name;
541 541
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
542 542
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
543
-                 try {
544
-                        $sth = $this->db->prepare($query);
545
-                        $sth->execute($query_data);
546
-                } catch(PDOException $e) {
547
-                        echo "error : ".$e->getMessage();
548
-                }
549
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
550
-                if (empty($all)) {
543
+				 try {
544
+						$sth = $this->db->prepare($query);
545
+						$sth->execute($query_data);
546
+				} catch(PDOException $e) {
547
+						echo "error : ".$e->getMessage();
548
+				}
549
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
550
+				if (empty($all)) {
551 551
 			$filters = array('airlines' => array($stats_airline));
552 552
 			if ($filter_name != '') {
553 553
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
554 554
 			}
555
-            		$Spotter = new Spotter($this->db);
556
-            		$all = $Spotter->countAllDatesLastMonth($filters);
557
-                }
558
-                return $all;
555
+					$Spotter = new Spotter($this->db);
556
+					$all = $Spotter->countAllDatesLastMonth($filters);
557
+				}
558
+				return $all;
559 559
 	}
560 560
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
561 561
 		global $globalDBdriver, $globalStatsFilters;
@@ -566,110 +566,110 @@  discard block
 block discarded – undo
566 566
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
567 567
 		}
568 568
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
569
-                 try {
570
-                        $sth = $this->db->prepare($query);
571
-                        $sth->execute($query_data);
572
-                } catch(PDOException $e) {
573
-                        echo "error : ".$e->getMessage();
574
-                }
575
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
576
-                if (empty($all)) {
569
+				 try {
570
+						$sth = $this->db->prepare($query);
571
+						$sth->execute($query_data);
572
+				} catch(PDOException $e) {
573
+						echo "error : ".$e->getMessage();
574
+				}
575
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
576
+				if (empty($all)) {
577 577
 			$filters = array('airlines' => array($stats_airline));
578 578
 			if ($filter_name != '') {
579 579
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
580 580
 			}
581
-            		$Spotter = new Spotter($this->db);
582
-            		$all = $Spotter->countAllDatesLast7Days($filters);
583
-                }
584
-                return $all;
581
+					$Spotter = new Spotter($this->db);
582
+					$all = $Spotter->countAllDatesLast7Days($filters);
583
+				}
584
+				return $all;
585 585
 	}
586 586
 	public function countAllDates($stats_airline = '',$filter_name = '') {
587 587
 		global $globalStatsFilters;
588 588
 		if ($filter_name == '') $filter_name = $this->filter_name;
589 589
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
590 590
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
591
-                 try {
592
-                        $sth = $this->db->prepare($query);
593
-                        $sth->execute($query_data);
594
-                } catch(PDOException $e) {
595
-                        echo "error : ".$e->getMessage();
596
-                }
597
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
598
-                if (empty($all)) {
591
+				 try {
592
+						$sth = $this->db->prepare($query);
593
+						$sth->execute($query_data);
594
+				} catch(PDOException $e) {
595
+						echo "error : ".$e->getMessage();
596
+				}
597
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
598
+				if (empty($all)) {
599 599
 			$filters = array('airlines' => array($stats_airline));
600 600
 			if ($filter_name != '') {
601
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
601
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
602 602
 			}
603
-            		$Spotter = new Spotter($this->db);
604
-            		$all = $Spotter->countAllDates($filters);
605
-                }
606
-                return $all;
603
+					$Spotter = new Spotter($this->db);
604
+					$all = $Spotter->countAllDates($filters);
605
+				}
606
+				return $all;
607 607
 	}
608 608
 	public function countAllDatesByAirlines($filter_name = '') {
609 609
 		global $globalStatsFilters;
610 610
 		if ($filter_name == '') $filter_name = $this->filter_name;
611 611
 		$query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name";
612 612
 		$query_data = array('filter_name' => $filter_name);
613
-                 try {
614
-                        $sth = $this->db->prepare($query);
615
-                        $sth->execute($query_data);
616
-                } catch(PDOException $e) {
617
-                        echo "error : ".$e->getMessage();
618
-                }
619
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
620
-                if (empty($all)) {
621
-            		$filters = array();
622
-            		if ($filter_name != '') {
623
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
613
+				 try {
614
+						$sth = $this->db->prepare($query);
615
+						$sth->execute($query_data);
616
+				} catch(PDOException $e) {
617
+						echo "error : ".$e->getMessage();
618
+				}
619
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
620
+				if (empty($all)) {
621
+					$filters = array();
622
+					if ($filter_name != '') {
623
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
624 624
 			}
625
-            		$Spotter = new Spotter($this->db);
626
-            		$all = $Spotter->countAllDatesByAirlines($filters);
627
-                }
628
-                return $all;
625
+					$Spotter = new Spotter($this->db);
626
+					$all = $Spotter->countAllDatesByAirlines($filters);
627
+				}
628
+				return $all;
629 629
 	}
630 630
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
631 631
 		global $globalStatsFilters;
632 632
 		if ($filter_name == '') $filter_name = $this->filter_name;
633
-	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
634
-                 try {
635
-                        $sth = $this->db->prepare($query);
636
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
637
-                } catch(PDOException $e) {
638
-                        echo "error : ".$e->getMessage();
639
-                }
640
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
633
+			$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
634
+				 try {
635
+						$sth = $this->db->prepare($query);
636
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
637
+				} catch(PDOException $e) {
638
+						echo "error : ".$e->getMessage();
639
+				}
640
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
641 641
                 
642
-                if (empty($all)) {
642
+				if (empty($all)) {
643 643
 			$filters = array('airlines' => array($stats_airline));
644 644
 			if ($filter_name != '') {
645 645
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
646 646
 			}
647
-            		$Spotter = new Spotter($this->db);
648
-            		$all = $Spotter->countAllMonths($filters);
649
-                }
647
+					$Spotter = new Spotter($this->db);
648
+					$all = $Spotter->countAllMonths($filters);
649
+				}
650 650
                 
651
-                return $all;
651
+				return $all;
652 652
 	}
653 653
 	public function countAllMilitaryMonths($filter_name = '') {
654 654
 		global $globalStatsFilters;
655 655
 		if ($filter_name == '') $filter_name = $this->filter_name;
656
-	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
657
-                 try {
658
-                        $sth = $this->db->prepare($query);
659
-                        $sth->execute(array(':filter_name' => $filter_name));
660
-                } catch(PDOException $e) {
661
-                        echo "error : ".$e->getMessage();
662
-                }
663
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
664
-                if (empty($all)) {
665
-            		$filters = array();
666
-            		if ($filter_name != '') {
667
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
656
+			$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
657
+				 try {
658
+						$sth = $this->db->prepare($query);
659
+						$sth->execute(array(':filter_name' => $filter_name));
660
+				} catch(PDOException $e) {
661
+						echo "error : ".$e->getMessage();
662
+				}
663
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
664
+				if (empty($all)) {
665
+					$filters = array();
666
+					if ($filter_name != '') {
667
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
668 668
 			}
669
-            		$Spotter = new Spotter($this->db);
670
-            		$all = $Spotter->countAllMilitaryMonths($filters);
671
-                }
672
-                return $all;
669
+					$Spotter = new Spotter($this->db);
670
+					$all = $Spotter->countAllMilitaryMonths($filters);
671
+				}
672
+				return $all;
673 673
 	}
674 674
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
675 675
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
@@ -685,22 +685,22 @@  discard block
 block discarded – undo
685 685
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
686 686
 		}
687 687
 		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
688
-                 try {
689
-                        $sth = $this->db->prepare($query);
690
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
691
-                } catch(PDOException $e) {
692
-                        echo "error : ".$e->getMessage();
693
-                }
694
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
695
-                if (empty($all)) {
688
+				 try {
689
+						$sth = $this->db->prepare($query);
690
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
691
+				} catch(PDOException $e) {
692
+						echo "error : ".$e->getMessage();
693
+				}
694
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
695
+				if (empty($all)) {
696 696
 			$filters = array('airlines' => array($stats_airline));
697 697
 			if ($filter_name != '') {
698
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
698
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
699 699
 			}
700
-            		$Spotter = new Spotter($this->db);
701
-            		$all = $Spotter->countAllHours($orderby,$filters);
702
-                }
703
-                return $all;
700
+					$Spotter = new Spotter($this->db);
701
+					$all = $Spotter->countAllHours($orderby,$filters);
702
+				}
703
+				return $all;
704 704
 	}
705 705
 	
706 706
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
@@ -724,9 +724,9 @@  discard block
 block discarded – undo
724 724
 		if ($year == '') $year = date('Y');
725 725
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
726 726
 		if (empty($all)) {
727
-		        $filters = array();
728
-            		if ($filter_name != '') {
729
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
727
+				$filters = array();
728
+					if ($filter_name != '') {
729
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
730 730
 			}
731 731
 			$Spotter = new Spotter($this->db);
732 732
 			$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -778,9 +778,9 @@  discard block
 block discarded – undo
778 778
 			$all = $result[0]['nb_airline'];
779 779
 		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
780 780
 		if (empty($all)) {
781
-            		$filters = array();
782
-            		if ($filter_name != '') {
783
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
781
+					$filters = array();
782
+					if ($filter_name != '') {
783
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
784 784
 			}
785 785
 			$Spotter = new Spotter($this->db);
786 786
 			$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -833,33 +833,33 @@  discard block
 block discarded – undo
833 833
 		if ($filter_name == '') $filter_name = $this->filter_name;
834 834
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
835 835
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
836
-                 try {
837
-                        $sth = $this->db->prepare($query);
838
-                        $sth->execute($query_values);
839
-                } catch(PDOException $e) {
840
-                        echo "error : ".$e->getMessage();
841
-                }
842
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
843
-                return $all;
836
+				 try {
837
+						$sth = $this->db->prepare($query);
838
+						$sth->execute($query_values);
839
+				} catch(PDOException $e) {
840
+						echo "error : ".$e->getMessage();
841
+				}
842
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
843
+				return $all;
844 844
 	}
845 845
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
846 846
 		if ($filter_name == '') $filter_name = $this->filter_name;
847
-                $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
848
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
849
-                 try {
850
-                        $sth = $this->db->prepare($query);
851
-                        $sth->execute($query_values);
852
-                } catch(PDOException $e) {
853
-                        echo "error : ".$e->getMessage();
854
-                }
855
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
856
-                return $all;
857
-        }
847
+				$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
848
+				$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
849
+				 try {
850
+						$sth = $this->db->prepare($query);
851
+						$sth->execute($query_values);
852
+				} catch(PDOException $e) {
853
+						echo "error : ".$e->getMessage();
854
+				}
855
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
856
+				return $all;
857
+		}
858 858
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
859 859
 		if ($filter_name == '') $filter_name = $this->filter_name;
860
-    		global $globalArchiveMonths, $globalDBdriver;
861
-    		if ($globalDBdriver == 'mysql') {
862
-    			if ($month == '') {
860
+			global $globalArchiveMonths, $globalDBdriver;
861
+			if ($globalDBdriver == 'mysql') {
862
+				if ($month == '') {
863 863
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
864 864
 				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
865 865
 			} else {
@@ -874,137 +874,137 @@  discard block
 block discarded – undo
874 874
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
875 875
 				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
876 876
 			}
877
-                }
878
-                 try {
879
-                        $sth = $this->db->prepare($query);
880
-                        $sth->execute($query_values);
881
-                } catch(PDOException $e) {
882
-                        echo "error : ".$e->getMessage();
883
-                }
884
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
885
-                return $all[0]['total'];
886
-        }
877
+				}
878
+				 try {
879
+						$sth = $this->db->prepare($query);
880
+						$sth->execute($query_values);
881
+				} catch(PDOException $e) {
882
+						echo "error : ".$e->getMessage();
883
+				}
884
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
885
+				return $all[0]['total'];
886
+		}
887 887
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
888
-    		global $globalArchiveMonths, $globalDBdriver;
888
+			global $globalArchiveMonths, $globalDBdriver;
889 889
 		if ($filter_name == '') $filter_name = $this->filter_name;
890
-    		if ($globalDBdriver == 'mysql') {
890
+			if ($globalDBdriver == 'mysql') {
891 891
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
892 892
 		} else {
893 893
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
894
-                }
895
-                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
896
-                 try {
897
-                        $sth = $this->db->prepare($query);
898
-                        $sth->execute($query_values);
899
-                } catch(PDOException $e) {
900
-                        echo "error : ".$e->getMessage();
901
-                }
902
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
903
-                return $all[0]['total'];
904
-        }
894
+				}
895
+				$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
896
+				 try {
897
+						$sth = $this->db->prepare($query);
898
+						$sth->execute($query_values);
899
+				} catch(PDOException $e) {
900
+						echo "error : ".$e->getMessage();
901
+				}
902
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
903
+				return $all[0]['total'];
904
+		}
905 905
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
906
-    		global $globalArchiveMonths, $globalDBdriver;
906
+			global $globalArchiveMonths, $globalDBdriver;
907 907
 		if ($filter_name == '') $filter_name = $this->filter_name;
908
-    		if ($globalDBdriver == 'mysql') {
908
+			if ($globalDBdriver == 'mysql') {
909 909
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
910
-                } else {
910
+				} else {
911 911
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
912
-                }
913
-                 try {
914
-                        $sth = $this->db->prepare($query);
915
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
916
-                } catch(PDOException $e) {
917
-                        echo "error : ".$e->getMessage();
918
-                }
919
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
920
-                return $all[0]['total'];
921
-        }
912
+				}
913
+				 try {
914
+						$sth = $this->db->prepare($query);
915
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
916
+				} catch(PDOException $e) {
917
+						echo "error : ".$e->getMessage();
918
+				}
919
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
920
+				return $all[0]['total'];
921
+		}
922 922
 	public function getStatsAirlineTotal($filter_name = '') {
923
-    		global $globalArchiveMonths, $globalDBdriver;
923
+			global $globalArchiveMonths, $globalDBdriver;
924 924
 		if ($filter_name == '') $filter_name = $this->filter_name;
925
-    		if ($globalDBdriver == 'mysql') {
925
+			if ($globalDBdriver == 'mysql') {
926 926
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
927
-                } else {
927
+				} else {
928 928
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
929
-                }
930
-                 try {
931
-                        $sth = $this->db->prepare($query);
932
-                        $sth->execute(array(':filter_name' => $filter_name));
933
-                } catch(PDOException $e) {
934
-                        echo "error : ".$e->getMessage();
935
-                }
936
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
937
-                return $all[0]['total'];
938
-        }
929
+				}
930
+				 try {
931
+						$sth = $this->db->prepare($query);
932
+						$sth->execute(array(':filter_name' => $filter_name));
933
+				} catch(PDOException $e) {
934
+						echo "error : ".$e->getMessage();
935
+				}
936
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
937
+				return $all[0]['total'];
938
+		}
939 939
 	public function getStatsOwnerTotal($filter_name = '') {
940
-    		global $globalArchiveMonths, $globalDBdriver;
940
+			global $globalArchiveMonths, $globalDBdriver;
941 941
 		if ($filter_name == '') $filter_name = $this->filter_name;
942
-    		if ($globalDBdriver == 'mysql') {
942
+			if ($globalDBdriver == 'mysql') {
943 943
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
944 944
 		} else {
945 945
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
946
-                }
947
-                 try {
948
-                        $sth = $this->db->prepare($query);
949
-                        $sth->execute(array(':filter_name' => $filter_name));
950
-                } catch(PDOException $e) {
951
-                        echo "error : ".$e->getMessage();
952
-                }
953
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
954
-                return $all[0]['total'];
955
-        }
946
+				}
947
+				 try {
948
+						$sth = $this->db->prepare($query);
949
+						$sth->execute(array(':filter_name' => $filter_name));
950
+				} catch(PDOException $e) {
951
+						echo "error : ".$e->getMessage();
952
+				}
953
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
954
+				return $all[0]['total'];
955
+		}
956 956
 	public function getStatsPilotTotal($filter_name = '') {
957
-    		global $globalArchiveMonths, $globalDBdriver;
957
+			global $globalArchiveMonths, $globalDBdriver;
958 958
 		if ($filter_name == '') $filter_name = $this->filter_name;
959
-    		if ($globalDBdriver == 'mysql') {
960
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
961
-            	} else {
962
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
963
-            	}
964
-                 try {
965
-                        $sth = $this->db->prepare($query);
966
-                        $sth->execute(array(':filter_name' => $filter_name));
967
-                } catch(PDOException $e) {
968
-                        echo "error : ".$e->getMessage();
969
-                }
970
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
971
-                return $all[0]['total'];
972
-        }
959
+			if ($globalDBdriver == 'mysql') {
960
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
961
+				} else {
962
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
963
+				}
964
+				 try {
965
+						$sth = $this->db->prepare($query);
966
+						$sth->execute(array(':filter_name' => $filter_name));
967
+				} catch(PDOException $e) {
968
+						echo "error : ".$e->getMessage();
969
+				}
970
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
971
+				return $all[0]['total'];
972
+		}
973 973
 
974 974
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
975 975
 		global $globalDBdriver;
976 976
 		if ($filter_name == '') $filter_name = $this->filter_name;
977 977
 		if ($globalDBdriver == 'mysql') {
978 978
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt";
979
-                } else {
979
+				} else {
980 980
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
981 981
 		}
982
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
983
-                 try {
984
-                        $sth = $this->db->prepare($query);
985
-                        $sth->execute($query_values);
986
-                } catch(PDOException $e) {
987
-                        return "error : ".$e->getMessage();
988
-                }
989
-        }
982
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
983
+				 try {
984
+						$sth = $this->db->prepare($query);
985
+						$sth->execute($query_values);
986
+				} catch(PDOException $e) {
987
+						return "error : ".$e->getMessage();
988
+				}
989
+		}
990 990
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
991 991
 		global $globalDBdriver;
992 992
 		if ($filter_name == '') $filter_name = $this->filter_name;
993 993
 		if ($globalDBdriver == 'mysql') {
994 994
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
995 995
 		} else {
996
-            		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
996
+					//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
997 997
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
998
-                }
999
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1000
-                 try {
1001
-                        $sth = $this->db->prepare($query);
1002
-                        $sth->execute($query_values);
1003
-                } catch(PDOException $e) {
1004
-                        return "error : ".$e->getMessage();
1005
-                }
1006
-        }
1007
-        /*
998
+				}
999
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1000
+				 try {
1001
+						$sth = $this->db->prepare($query);
1002
+						$sth->execute($query_values);
1003
+				} catch(PDOException $e) {
1004
+						return "error : ".$e->getMessage();
1005
+				}
1006
+		}
1007
+		/*
1008 1008
 	public function getStatsSource($date,$stats_type = '') {
1009 1009
 		if ($stats_type == '') {
1010 1010
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
@@ -1073,25 +1073,25 @@  discard block
 block discarded – undo
1073 1073
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
1074 1074
 		} else {
1075 1075
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
1076
-                }
1077
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1078
-                 try {
1079
-                        $sth = $this->db->prepare($query);
1080
-                        $sth->execute($query_values);
1081
-                } catch(PDOException $e) {
1082
-                        return "error : ".$e->getMessage();
1083
-                }
1084
-        }
1085
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1086
-                $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1087
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1088
-                 try {
1089
-                        $sth = $this->db->prepare($query);
1090
-                        $sth->execute($query_values);
1091
-                } catch(PDOException $e) {
1092
-                        return "error : ".$e->getMessage();
1093
-                }
1094
-        }
1076
+				}
1077
+				$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1078
+				 try {
1079
+						$sth = $this->db->prepare($query);
1080
+						$sth->execute($query_values);
1081
+				} catch(PDOException $e) {
1082
+						return "error : ".$e->getMessage();
1083
+				}
1084
+		}
1085
+	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1086
+				$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1087
+				$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1088
+				 try {
1089
+						$sth = $this->db->prepare($query);
1090
+						$sth->execute($query_values);
1091
+				} catch(PDOException $e) {
1092
+						return "error : ".$e->getMessage();
1093
+				}
1094
+		}
1095 1095
 	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1096 1096
 		global $globalDBdriver;
1097 1097
 		if ($globalDBdriver == 'mysql') {
@@ -1107,14 +1107,14 @@  discard block
 block discarded – undo
1107 1107
 				$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1108 1108
 			}
1109 1109
 		}
1110
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1111
-                 try {
1112
-                        $sth = $this->db->prepare($query);
1113
-                        $sth->execute($query_values);
1114
-                } catch(PDOException $e) {
1115
-                        return "error : ".$e->getMessage();
1116
-                }
1117
-        }
1110
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1111
+				 try {
1112
+						$sth = $this->db->prepare($query);
1113
+						$sth->execute($query_values);
1114
+				} catch(PDOException $e) {
1115
+						return "error : ".$e->getMessage();
1116
+				}
1117
+		}
1118 1118
 	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1119 1119
 		global $globalDBdriver;
1120 1120
 		if ($globalDBdriver == 'mysql') {
@@ -1130,14 +1130,14 @@  discard block
 block discarded – undo
1130 1130
 				$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; 
1131 1131
 			}
1132 1132
 		}
1133
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1134
-                 try {
1135
-                        $sth = $this->db->prepare($query);
1136
-                        $sth->execute($query_values);
1137
-                } catch(PDOException $e) {
1138
-                        return "error : ".$e->getMessage();
1139
-                }
1140
-        }
1133
+				$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1134
+				 try {
1135
+						$sth = $this->db->prepare($query);
1136
+						$sth->execute($query_values);
1137
+				} catch(PDOException $e) {
1138
+						return "error : ".$e->getMessage();
1139
+				}
1140
+		}
1141 1141
 	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1142 1142
 		global $globalDBdriver;
1143 1143
 		if ($globalDBdriver == 'mysql') {
@@ -1153,14 +1153,14 @@  discard block
 block discarded – undo
1153 1153
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name 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);"; 
1154 1154
 			}
1155 1155
 		}
1156
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1157
-                 try {
1158
-                        $sth = $this->db->prepare($query);
1159
-                        $sth->execute($query_values);
1160
-                } catch(PDOException $e) {
1161
-                        return "error : ".$e->getMessage();
1162
-                }
1163
-        }
1156
+				$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1157
+				 try {
1158
+						$sth = $this->db->prepare($query);
1159
+						$sth->execute($query_values);
1160
+				} catch(PDOException $e) {
1161
+						return "error : ".$e->getMessage();
1162
+				}
1163
+		}
1164 1164
 	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1165 1165
 		global $globalDBdriver;
1166 1166
 		if ($globalDBdriver == 'mysql') {
@@ -1176,14 +1176,14 @@  discard block
 block discarded – undo
1176 1176
 				$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1177 1177
 			}
1178 1178
 		}
1179
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1180
-                 try {
1181
-                        $sth = $this->db->prepare($query);
1182
-                        $sth->execute($query_values);
1183
-                } catch(PDOException $e) {
1184
-                        return "error : ".$e->getMessage();
1185
-                }
1186
-        }
1179
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1180
+				 try {
1181
+						$sth = $this->db->prepare($query);
1182
+						$sth->execute($query_values);
1183
+				} catch(PDOException $e) {
1184
+						return "error : ".$e->getMessage();
1185
+				}
1186
+		}
1187 1187
 	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1188 1188
 		global $globalDBdriver;
1189 1189
 		if ($globalDBdriver == 'mysql') {
@@ -1199,14 +1199,14 @@  discard block
 block discarded – undo
1199 1199
 				$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; 
1200 1200
 			}
1201 1201
 		}
1202
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1203
-                 try {
1204
-                        $sth = $this->db->prepare($query);
1205
-                        $sth->execute($query_values);
1206
-                } catch(PDOException $e) {
1207
-                        return "error : ".$e->getMessage();
1208
-                }
1209
-        }
1202
+				$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1203
+				 try {
1204
+						$sth = $this->db->prepare($query);
1205
+						$sth->execute($query_values);
1206
+				} catch(PDOException $e) {
1207
+						return "error : ".$e->getMessage();
1208
+				}
1209
+		}
1210 1210
 	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1211 1211
 		global $globalDBdriver;
1212 1212
 		if ($globalDBdriver == 'mysql') {
@@ -1222,14 +1222,14 @@  discard block
 block discarded – undo
1222 1222
 				$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1223 1223
 			}
1224 1224
 		}
1225
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1226
-                 try {
1227
-                        $sth = $this->db->prepare($query);
1228
-                        $sth->execute($query_values);
1229
-                } catch(PDOException $e) {
1230
-                        return "error : ".$e->getMessage();
1231
-                }
1232
-        }
1225
+				$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1226
+				 try {
1227
+						$sth = $this->db->prepare($query);
1228
+						$sth->execute($query_values);
1229
+				} catch(PDOException $e) {
1230
+						return "error : ".$e->getMessage();
1231
+				}
1232
+		}
1233 1233
 	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1234 1234
 		global $globalDBdriver;
1235 1235
 		if ($globalDBdriver == 'mysql') {
@@ -1245,14 +1245,14 @@  discard block
 block discarded – undo
1245 1245
 				$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; 
1246 1246
 			}
1247 1247
 		}
1248
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1249
-                 try {
1250
-                        $sth = $this->db->prepare($query);
1251
-                        $sth->execute($query_values);
1252
-                } catch(PDOException $e) {
1253
-                        return "error : ".$e->getMessage();
1254
-                }
1255
-        }
1248
+				$query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1249
+				 try {
1250
+						$sth = $this->db->prepare($query);
1251
+						$sth->execute($query_values);
1252
+				} catch(PDOException $e) {
1253
+						return "error : ".$e->getMessage();
1254
+				}
1255
+		}
1256 1256
 	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1257 1257
 		global $globalDBdriver;
1258 1258
 		if ($airport_icao != '') {
@@ -1276,8 +1276,8 @@  discard block
 block discarded – undo
1276 1276
 			} catch(PDOException $e) {
1277 1277
 				return "error : ".$e->getMessage();
1278 1278
 			}
1279
-                }
1280
-        }
1279
+				}
1280
+		}
1281 1281
 	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1282 1282
 		global $globalDBdriver;
1283 1283
 		if ($airport_icao != '') {
@@ -1293,8 +1293,8 @@  discard block
 block discarded – undo
1293 1293
 			} catch(PDOException $e) {
1294 1294
 				return "error : ".$e->getMessage();
1295 1295
 			}
1296
-                }
1297
-        }
1296
+				}
1297
+		}
1298 1298
 	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1299 1299
 		global $globalDBdriver;
1300 1300
 		if ($airport_icao != '') {
@@ -1311,15 +1311,15 @@  discard block
 block discarded – undo
1311 1311
 					$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1312 1312
 				}
1313 1313
 			}
1314
-	                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1314
+					$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1315 1315
 			 try {
1316
-                    		$sth = $this->db->prepare($query);
1317
-	                        $sth->execute($query_values);
1318
-    		        } catch(PDOException $e) {
1319
-            		        return "error : ".$e->getMessage();
1320
-	                }
1321
-	        }
1322
-        }
1316
+							$sth = $this->db->prepare($query);
1317
+							$sth->execute($query_values);
1318
+					} catch(PDOException $e) {
1319
+							return "error : ".$e->getMessage();
1320
+					}
1321
+			}
1322
+		}
1323 1323
 	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1324 1324
 		global $globalDBdriver;
1325 1325
 		if ($airport_icao != '') {
@@ -1335,46 +1335,46 @@  discard block
 block discarded – undo
1335 1335
 			} catch(PDOException $e) {
1336 1336
 				return "error : ".$e->getMessage();
1337 1337
 			}
1338
-                }
1339
-        }
1338
+				}
1339
+		}
1340 1340
 
1341 1341
 	public function deleteStat($id) {
1342
-                $query = "DELETE FROM stats WHERE stats_id = :id";
1343
-                $query_values = array(':id' => $id);
1344
-                 try {
1345
-                        $sth = $this->db->prepare($query);
1346
-                        $sth->execute($query_values);
1347
-                } catch(PDOException $e) {
1348
-                        return "error : ".$e->getMessage();
1349
-                }
1350
-        }
1342
+				$query = "DELETE FROM stats WHERE stats_id = :id";
1343
+				$query_values = array(':id' => $id);
1344
+				 try {
1345
+						$sth = $this->db->prepare($query);
1346
+						$sth->execute($query_values);
1347
+				} catch(PDOException $e) {
1348
+						return "error : ".$e->getMessage();
1349
+				}
1350
+		}
1351 1351
 	public function deleteStatFlight($type) {
1352
-                $query = "DELETE FROM stats_flight WHERE stats_type = :type";
1353
-                $query_values = array(':type' => $type);
1354
-                 try {
1355
-                        $sth = $this->db->prepare($query);
1356
-                        $sth->execute($query_values);
1357
-                } catch(PDOException $e) {
1358
-                        return "error : ".$e->getMessage();
1359
-                }
1360
-        }
1352
+				$query = "DELETE FROM stats_flight WHERE stats_type = :type";
1353
+				$query_values = array(':type' => $type);
1354
+				 try {
1355
+						$sth = $this->db->prepare($query);
1356
+						$sth->execute($query_values);
1357
+				} catch(PDOException $e) {
1358
+						return "error : ".$e->getMessage();
1359
+				}
1360
+		}
1361 1361
 	public function deleteStatAirport($type) {
1362
-                $query = "DELETE FROM stats_airport WHERE stats_type = :type";
1363
-                $query_values = array(':type' => $type);
1364
-                 try {
1365
-                        $sth = $this->db->prepare($query);
1366
-                        $sth->execute($query_values);
1367
-                } catch(PDOException $e) {
1368
-                        return "error : ".$e->getMessage();
1369
-                }
1370
-        }
1362
+				$query = "DELETE FROM stats_airport WHERE stats_type = :type";
1363
+				$query_values = array(':type' => $type);
1364
+				 try {
1365
+						$sth = $this->db->prepare($query);
1366
+						$sth->execute($query_values);
1367
+				} catch(PDOException $e) {
1368
+						return "error : ".$e->getMessage();
1369
+				}
1370
+		}
1371 1371
         
1372
-        public function addOldStats() {
1373
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1374
-    		$Common = new Common();
1375
-    		$Connection = new Connection();
1376
-    		date_default_timezone_set('UTC');
1377
-    		$last_update = $this->getLastStatsUpdate('last_update_stats');
1372
+		public function addOldStats() {
1373
+			global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1374
+			$Common = new Common();
1375
+			$Connection = new Connection();
1376
+			date_default_timezone_set('UTC');
1377
+			$last_update = $this->getLastStatsUpdate('last_update_stats');
1378 1378
 			if ($globalDebug) echo 'Update stats !'."\n";
1379 1379
 			if (isset($last_update[0]['value'])) {
1380 1380
 				$last_update_day = $last_update[0]['value'];
@@ -1420,24 +1420,24 @@  discard block
 block discarded – undo
1420 1420
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1421 1421
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1422 1422
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1423
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1423
+				$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1424 1424
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1425
-	        	$alldata = array();
1425
+				$alldata = array();
1426 1426
 	        	
1427
-    			foreach ($pall as $value) {
1428
-	        		$icao = $value['airport_departure_icao'];
1429
-    				$alldata[$icao] = $value;
1430
-	        	}
1431
-	        	foreach ($dall as $value) {
1432
-    				$icao = $value['airport_departure_icao'];
1433
-        			if (isset($alldata[$icao])) {
1434
-    					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1435
-        			} else $alldata[$icao] = $value;
1436
-			}
1437
-    			$count = array();
1438
-    			foreach ($alldata as $key => $row) {
1439
-    				$count[$key] = $row['airport_departure_icao_count'];
1440
-        		}
1427
+				foreach ($pall as $value) {
1428
+					$icao = $value['airport_departure_icao'];
1429
+					$alldata[$icao] = $value;
1430
+				}
1431
+				foreach ($dall as $value) {
1432
+					$icao = $value['airport_departure_icao'];
1433
+					if (isset($alldata[$icao])) {
1434
+						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1435
+					} else $alldata[$icao] = $value;
1436
+			}
1437
+				$count = array();
1438
+				foreach ($alldata as $key => $row) {
1439
+					$count[$key] = $row['airport_departure_icao_count'];
1440
+				}
1441 1441
 			array_multisort($count,SORT_DESC,$alldata);
1442 1442
 			foreach ($alldata as $number) {
1443 1443
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
@@ -1445,25 +1445,25 @@  discard block
 block discarded – undo
1445 1445
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1446 1446
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1447 1447
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1448
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1448
+				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1449 1449
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1450
-	        	$alldata = array();
1451
-    			foreach ($pall as $value) {
1452
-	        		$icao = $value['airport_arrival_icao'];
1453
-    				$alldata[$icao] = $value;
1454
-	        	}
1455
-	        	foreach ($dall as $value) {
1456
-    				$icao = $value['airport_arrival_icao'];
1457
-        			if (isset($alldata[$icao])) {
1458
-        				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1459
-	        		} else $alldata[$icao] = $value;
1460
-    			}
1461
-        		$count = array();
1462
-        		foreach ($alldata as $key => $row) {
1463
-        			$count[$key] = $row['airport_arrival_icao_count'];
1464
-	        	}
1465
-    			array_multisort($count,SORT_DESC,$alldata);
1466
-                        foreach ($alldata as $number) {
1450
+				$alldata = array();
1451
+				foreach ($pall as $value) {
1452
+					$icao = $value['airport_arrival_icao'];
1453
+					$alldata[$icao] = $value;
1454
+				}
1455
+				foreach ($dall as $value) {
1456
+					$icao = $value['airport_arrival_icao'];
1457
+					if (isset($alldata[$icao])) {
1458
+						$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1459
+					} else $alldata[$icao] = $value;
1460
+				}
1461
+				$count = array();
1462
+				foreach ($alldata as $key => $row) {
1463
+					$count[$key] = $row['airport_arrival_icao_count'];
1464
+				}
1465
+				array_multisort($count,SORT_DESC,$alldata);
1466
+						foreach ($alldata as $number) {
1467 1467
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
1468 1468
 			}
1469 1469
 			if ($Connection->tableExists('countries')) {
@@ -1523,8 +1523,8 @@  discard block
 block discarded – undo
1523 1523
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1524 1524
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1525 1525
 			$pall = $Spotter->getLast7DaysAirportsDeparture();
1526
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1527
-        		/*
1526
+				$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1527
+				/*
1528 1528
 	        	$alldata = array();
1529 1529
     			foreach ($pall as $value) {
1530 1530
 	        		$icao = $value['departure_airport_icao'];
@@ -1543,29 +1543,29 @@  discard block
 block discarded – undo
1543 1543
 	        	}
1544 1544
     			array_multisort($count,SORT_DESC,$alldata);
1545 1545
     			*/
1546
-    			foreach ($dall as $value) {
1547
-    				$icao = $value['departure_airport_icao'];
1548
-    				$ddate = $value['date'];
1549
-    				$find = false;
1550
-    				foreach ($pall as $pvalue) {
1551
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1552
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1553
-    						$find = true;
1554
-    						break;
1555
-    					}
1556
-    				}
1557
-    				if ($find === false) {
1558
-    					$pall[] = $value;
1559
-    				}
1560
-    			}
1561
-    			$alldata = $pall;
1546
+				foreach ($dall as $value) {
1547
+					$icao = $value['departure_airport_icao'];
1548
+					$ddate = $value['date'];
1549
+					$find = false;
1550
+					foreach ($pall as $pvalue) {
1551
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1552
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1553
+							$find = true;
1554
+							break;
1555
+						}
1556
+					}
1557
+					if ($find === false) {
1558
+						$pall[] = $value;
1559
+					}
1560
+				}
1561
+				$alldata = $pall;
1562 1562
 			foreach ($alldata as $number) {
1563 1563
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1564 1564
 			}
1565 1565
 			echo '...Arrival'."\n";
1566 1566
 			$pall = $Spotter->getLast7DaysAirportsArrival();
1567
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1568
-        		/*
1567
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1568
+				/*
1569 1569
 	        	$alldata = array();
1570 1570
     			foreach ($pall as $value) {
1571 1571
 	        		$icao = $value['arrival_airport_icao'];
@@ -1585,22 +1585,22 @@  discard block
 block discarded – undo
1585 1585
     			*/
1586 1586
 
1587 1587
 
1588
-    			foreach ($dall as $value) {
1589
-    				$icao = $value['arrival_airport_icao'];
1590
-    				$ddate = $value['date'];
1591
-    				$find = false;
1592
-    				foreach ($pall as $pvalue) {
1593
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1594
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1595
-    						$find = true;
1596
-    						break;
1597
-    					}
1598
-    				}
1599
-    				if ($find === false) {
1600
-    					$pall[] = $value;
1601
-    				}
1602
-    			}
1603
-    			$alldata = $pall;
1588
+				foreach ($dall as $value) {
1589
+					$icao = $value['arrival_airport_icao'];
1590
+					$ddate = $value['date'];
1591
+					$find = false;
1592
+					foreach ($pall as $pvalue) {
1593
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1594
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1595
+							$find = true;
1596
+							break;
1597
+						}
1598
+					}
1599
+					if ($find === false) {
1600
+						$pall[] = $value;
1601
+					}
1602
+				}
1603
+				$alldata = $pall;
1604 1604
 			foreach ($alldata as $number) {
1605 1605
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1606 1606
 			}
@@ -1675,51 +1675,51 @@  discard block
 block discarded – undo
1675 1675
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1676 1676
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1677 1677
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1678
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1678
+	   			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1679 1679
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1680
-	        	//$alldata = array();
1681
-    			foreach ($dall as $value) {
1682
-    				$icao = $value['airport_departure_icao'];
1683
-    				$dicao = $value['airline_icao'];
1684
-    				$find = false;
1685
-    				foreach ($pall as $pvalue) {
1686
-    					if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1687
-    						$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1688
-    						$find = true;
1689
-    						break;
1690
-    					}
1691
-    				}
1692
-    				if ($find === false) {
1693
-    					$pall[] = $value;
1694
-    				}
1695
-    			}
1696
-    			$alldata = $pall;
1680
+				//$alldata = array();
1681
+				foreach ($dall as $value) {
1682
+					$icao = $value['airport_departure_icao'];
1683
+					$dicao = $value['airline_icao'];
1684
+					$find = false;
1685
+					foreach ($pall as $pvalue) {
1686
+						if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1687
+							$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1688
+							$find = true;
1689
+							break;
1690
+						}
1691
+					}
1692
+					if ($find === false) {
1693
+						$pall[] = $value;
1694
+					}
1695
+				}
1696
+				$alldata = $pall;
1697 1697
 			foreach ($alldata as $number) {
1698 1698
 				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);
1699 1699
 			}
1700 1700
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1701 1701
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1702 1702
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1703
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1703
+				$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1704 1704
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1705
-	        	//$alldata = array();
1706
-    			foreach ($dall as $value) {
1707
-    				$icao = $value['airport_arrival_icao'];
1708
-    				$dicao = $value['airline_icao'];
1709
-    				$find = false;
1710
-    				foreach ($pall as $pvalue) {
1711
-    					if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1712
-    						$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1713
-    						$find = true;
1714
-    						break;
1715
-    					}
1716
-    				}
1717
-    				if ($find === false) {
1718
-    					$pall[] = $value;
1719
-    				}
1720
-    			}
1721
-    			$alldata = $pall;
1722
-                        foreach ($alldata as $number) {
1705
+				//$alldata = array();
1706
+				foreach ($dall as $value) {
1707
+					$icao = $value['airport_arrival_icao'];
1708
+					$dicao = $value['airline_icao'];
1709
+					$find = false;
1710
+					foreach ($pall as $pvalue) {
1711
+						if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1712
+							$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1713
+							$find = true;
1714
+							break;
1715
+						}
1716
+					}
1717
+					if ($find === false) {
1718
+						$pall[] = $value;
1719
+					}
1720
+				}
1721
+				$alldata = $pall;
1722
+						foreach ($alldata as $number) {
1723 1723
 				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);
1724 1724
 			}
1725 1725
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
@@ -1752,47 +1752,47 @@  discard block
 block discarded – undo
1752 1752
 			}
1753 1753
 			if ($globalDebug) echo '...Departure'."\n";
1754 1754
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1755
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1756
-    			foreach ($dall as $value) {
1757
-    				$icao = $value['departure_airport_icao'];
1758
-    				$airline = $value['airline_icao'];
1759
-    				$ddate = $value['date'];
1760
-    				$find = false;
1761
-    				foreach ($pall as $pvalue) {
1762
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1763
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1764
-    						$find = true;
1765
-    						break;
1766
-    					}
1767
-    				}
1768
-    				if ($find === false) {
1769
-    					$pall[] = $value;
1770
-    				}
1771
-    			}
1772
-    			$alldata = $pall;
1755
+				$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1756
+				foreach ($dall as $value) {
1757
+					$icao = $value['departure_airport_icao'];
1758
+					$airline = $value['airline_icao'];
1759
+					$ddate = $value['date'];
1760
+					$find = false;
1761
+					foreach ($pall as $pvalue) {
1762
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1763
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1764
+							$find = true;
1765
+							break;
1766
+						}
1767
+					}
1768
+					if ($find === false) {
1769
+						$pall[] = $value;
1770
+					}
1771
+				}
1772
+				$alldata = $pall;
1773 1773
 			foreach ($alldata as $number) {
1774 1774
 				$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']);
1775 1775
 			}
1776 1776
 			if ($globalDebug) echo '...Arrival'."\n";
1777 1777
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1778
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1779
-    			foreach ($dall as $value) {
1780
-    				$icao = $value['arrival_airport_icao'];
1781
-    				$airline = $value['airline_icao'];
1782
-    				$ddate = $value['date'];
1783
-    				$find = false;
1784
-    				foreach ($pall as $pvalue) {
1785
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1786
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1787
-    						$find = true;
1788
-    						break;
1789
-    					}
1790
-    				}
1791
-    				if ($find === false) {
1792
-    					$pall[] = $value;
1793
-    				}
1794
-    			}
1795
-    			$alldata = $pall;
1778
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1779
+				foreach ($dall as $value) {
1780
+					$icao = $value['arrival_airport_icao'];
1781
+					$airline = $value['airline_icao'];
1782
+					$ddate = $value['date'];
1783
+					$find = false;
1784
+					foreach ($pall as $pvalue) {
1785
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1786
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1787
+							$find = true;
1788
+							break;
1789
+						}
1790
+					}
1791
+					if ($find === false) {
1792
+						$pall[] = $value;
1793
+					}
1794
+				}
1795
+				$alldata = $pall;
1796 1796
 			foreach ($alldata as $number) {
1797 1797
 				$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']);
1798 1798
 			}
@@ -1863,44 +1863,44 @@  discard block
 block discarded – undo
1863 1863
 					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
1864 1864
 				}
1865 1865
 				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1866
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1867
-		        	$alldata = array();
1868
-	    			foreach ($pall as $value) {
1869
-		        		$icao = $value['airport_departure_icao'];
1870
-    					$alldata[$icao] = $value;
1871
-	    			}
1872
-		        	foreach ($dall as $value) {
1873
-	    				$icao = $value['airport_departure_icao'];
1874
-        				if (isset($alldata[$icao])) {
1875
-    						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1876
-        				} else $alldata[$icao] = $value;
1877
-				}
1878
-	    			$count = array();
1879
-    				foreach ($alldata as $key => $row) {
1880
-    					$count[$key] = $row['airport_departure_icao_count'];
1881
-    				}
1866
+		   			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1867
+					$alldata = array();
1868
+					foreach ($pall as $value) {
1869
+						$icao = $value['airport_departure_icao'];
1870
+						$alldata[$icao] = $value;
1871
+					}
1872
+					foreach ($dall as $value) {
1873
+						$icao = $value['airport_departure_icao'];
1874
+						if (isset($alldata[$icao])) {
1875
+							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1876
+						} else $alldata[$icao] = $value;
1877
+				}
1878
+					$count = array();
1879
+					foreach ($alldata as $key => $row) {
1880
+						$count[$key] = $row['airport_departure_icao_count'];
1881
+					}
1882 1882
 				array_multisort($count,SORT_DESC,$alldata);
1883 1883
 				foreach ($alldata as $number) {
1884
-    					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);
1884
+						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);
1885 1885
 				}
1886 1886
 				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
1887
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1887
+					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1888 1888
 				$alldata = array();
1889
-    				foreach ($pall as $value) {
1890
-		        		$icao = $value['airport_arrival_icao'];
1891
-    					$alldata[$icao] = $value;
1892
-	    			}
1893
-		        	foreach ($dall as $value) {
1894
-	    				$icao = $value['airport_arrival_icao'];
1895
-        				if (isset($alldata[$icao])) {
1896
-        					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1897
-		        		} else $alldata[$icao] = $value;
1898
-	    			}
1899
-        			$count = array();
1900
-        			foreach ($alldata as $key => $row) {
1901
-    					$count[$key] = $row['airport_arrival_icao_count'];
1902
-		        	}
1903
-        			array_multisort($count,SORT_DESC,$alldata);
1889
+					foreach ($pall as $value) {
1890
+						$icao = $value['airport_arrival_icao'];
1891
+						$alldata[$icao] = $value;
1892
+					}
1893
+					foreach ($dall as $value) {
1894
+						$icao = $value['airport_arrival_icao'];
1895
+						if (isset($alldata[$icao])) {
1896
+							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1897
+						} else $alldata[$icao] = $value;
1898
+					}
1899
+					$count = array();
1900
+					foreach ($alldata as $key => $row) {
1901
+						$count[$key] = $row['airport_arrival_icao_count'];
1902
+					}
1903
+					array_multisort($count,SORT_DESC,$alldata);
1904 1904
 				foreach ($alldata as $number) {
1905 1905
 					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);
1906 1906
 				}
@@ -1933,45 +1933,45 @@  discard block
 block discarded – undo
1933 1933
 				}
1934 1934
 				echo '...Departure'."\n";
1935 1935
 				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1936
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1936
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1937 1937
 				foreach ($dall as $value) {
1938
-    					$icao = $value['departure_airport_icao'];
1939
-    					$ddate = $value['date'];
1940
-    					$find = false;
1941
-    					foreach ($pall as $pvalue) {
1942
-    						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1943
-    							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1944
-	    						$find = true;
1945
-    							break;
1946
-    						}
1947
-    					}
1948
-    					if ($find === false) {
1949
-    						$pall[] = $value;
1950
-	    				}
1951
-    				}
1952
-	    			$alldata = $pall;
1938
+						$icao = $value['departure_airport_icao'];
1939
+						$ddate = $value['date'];
1940
+						$find = false;
1941
+						foreach ($pall as $pvalue) {
1942
+							if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1943
+								$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1944
+								$find = true;
1945
+								break;
1946
+							}
1947
+						}
1948
+						if ($find === false) {
1949
+							$pall[] = $value;
1950
+						}
1951
+					}
1952
+					$alldata = $pall;
1953 1953
 				foreach ($alldata as $number) {
1954 1954
 					$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);
1955 1955
 				}
1956 1956
 				echo '...Arrival'."\n";
1957 1957
 				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
1958
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1958
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1959 1959
 				foreach ($dall as $value) {
1960 1960
 					$icao = $value['arrival_airport_icao'];
1961 1961
 					$ddate = $value['date'];
1962
-    					$find = false;
1962
+						$find = false;
1963 1963
 					foreach ($pall as $pvalue) {
1964
-    						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1965
-    							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1966
-    							$find = true;
1967
-    							break;
1968
-	    					}
1969
-    					}
1970
-    					if ($find === false) {
1971
-    						$pall[] = $value;
1972
-	    				}
1973
-    				}
1974
-    				$alldata = $pall;
1964
+							if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1965
+								$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1966
+								$find = true;
1967
+								break;
1968
+							}
1969
+						}
1970
+						if ($find === false) {
1971
+							$pall[] = $value;
1972
+						}
1973
+					}
1974
+					$alldata = $pall;
1975 1975
 				foreach ($alldata as $number) {
1976 1976
 					$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);
1977 1977
 				}
Please login to merge, or discard this patch.
Spacing   +344 added lines, -344 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 		$this->db = $Connection->db();
18 18
         }
19 19
               
20
-	public function addLastStatsUpdate($type,$stats_date) {
20
+	public function addLastStatsUpdate($type, $stats_date) {
21 21
                 $query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
23
+                $query_values = array('type' => $type, ':stats_date' => $stats_date);
24 24
                  try {
25 25
                         $sth = $this->db->prepare($query);
26 26
                         $sth->execute($query_values);
27
-                } catch(PDOException $e) {
27
+                } catch (PDOException $e) {
28 28
                         return "error : ".$e->getMessage();
29 29
                 }
30 30
         }
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
                  try {
35 35
                         $sth = $this->db->prepare($query);
36 36
                         $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
37
+                } catch (PDOException $e) {
38 38
                         echo "error : ".$e->getMessage();
39 39
                 }
40 40
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                  try {
55 55
                         $sth = $this->db->prepare($query);
56 56
                         $sth->execute(array(':filter_name' => $filter_name));
57
-                } catch(PDOException $e) {
57
+                } catch (PDOException $e) {
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
         }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
                  try {
65 65
                         $sth = $this->db->prepare($query);
66 66
                         $sth->execute();
67
-                } catch(PDOException $e) {
67
+                } catch (PDOException $e) {
68 68
                         return "error : ".$e->getMessage();
69 69
                 }
70 70
                 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                  try {
73 73
                         $sth = $this->db->prepare($query);
74 74
                         $sth->execute(array(':filter_name' => $filter_name));
75
-                } catch(PDOException $e) {
75
+                } catch (PDOException $e) {
76 76
                         return "error : ".$e->getMessage();
77 77
                 }
78 78
         }
@@ -82,69 +82,69 @@  discard block
 block discarded – undo
82 82
                  try {
83 83
                         $sth = $this->db->prepare($query);
84 84
                         $sth->execute(array(':filter_name' => $filter_name));
85
-                } catch(PDOException $e) {
85
+                } catch (PDOException $e) {
86 86
                         echo "error : ".$e->getMessage();
87 87
                 }
88 88
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
89 89
                 return $all;
90 90
         }
91
-	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
91
+	public function getAllAircraftTypes($stats_airline = '', $filter_name = '') {
92 92
 		if ($filter_name == '') $filter_name = $this->filter_name;
93 93
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94 94
                  try {
95 95
                         $sth = $this->db->prepare($query);
96
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
-                } catch(PDOException $e) {
96
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
97
+                } catch (PDOException $e) {
98 98
                         echo "error : ".$e->getMessage();
99 99
                 }
100 100
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
101 101
                 return $all;
102 102
         }
103
-	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
103
+	public function getAllManufacturers($stats_airline = '', $filter_name = '') {
104 104
 		if ($filter_name == '') $filter_name = $this->filter_name;
105 105
                 $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106 106
                  try {
107 107
                         $sth = $this->db->prepare($query);
108
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
-                } catch(PDOException $e) {
108
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
109
+                } catch (PDOException $e) {
110 110
                         echo "error : ".$e->getMessage();
111 111
                 }
112 112
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
113 113
                 return $all;
114 114
         }
115
-	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
115
+	public function getAllAirportNames($stats_airline = '', $filter_name = '') {
116 116
 		if ($filter_name == '') $filter_name = $this->filter_name;
117 117
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118 118
                  try {
119 119
                         $sth = $this->db->prepare($query);
120
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
-                } catch(PDOException $e) {
120
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
121
+                } catch (PDOException $e) {
122 122
                         echo "error : ".$e->getMessage();
123 123
                 }
124 124
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
125 125
                 return $all;
126 126
         }
127 127
 
128
-	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
128
+	public function getAllOwnerNames($stats_airline = '', $filter_name = '') {
129 129
 		if ($filter_name == '') $filter_name = $this->filter_name;
130 130
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131 131
                  try {
132 132
                         $sth = $this->db->prepare($query);
133
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
134
-                } catch(PDOException $e) {
133
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
134
+                } catch (PDOException $e) {
135 135
                         echo "error : ".$e->getMessage();
136 136
                 }
137 137
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
138 138
                 return $all;
139 139
         }
140 140
 
141
-	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
141
+	public function getAllPilotNames($stats_airline = '', $filter_name = '') {
142 142
 		if ($filter_name == '') $filter_name = $this->filter_name;
143 143
                 $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144 144
                  try {
145 145
                         $sth = $this->db->prepare($query);
146
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
147
-                } catch(PDOException $e) {
146
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
147
+                } catch (PDOException $e) {
148 148
                         echo "error : ".$e->getMessage();
149 149
                 }
150 150
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
         }
153 153
 
154 154
 
155
-	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
155
+	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
156 156
 		global $globalStatsFilters;
157 157
 		if ($filter_name == '') $filter_name = $this->filter_name;
158 158
 		if ($year == '' && $month == '') {
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 			else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
161 161
 			try {
162 162
 				$sth = $this->db->prepare($query);
163
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
164
-			} catch(PDOException $e) {
163
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
164
+			} catch (PDOException $e) {
165 165
 				echo "error : ".$e->getMessage();
166 166
 			}
167 167
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -169,14 +169,14 @@  discard block
 block discarded – undo
169 169
                 if (empty($all)) {
170 170
             	    $filters = array('airlines' => array($stats_airline));
171 171
             	    if ($filter_name != '') {
172
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
172
+            		    $filters = array_merge($filters, $globalStatsFilters[$filter_name]);
173 173
             	    }
174 174
             	    $Spotter = new Spotter($this->db);
175
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
175
+            	    $all = $Spotter->countAllAircraftTypes($limit, 0, '', $filters, $year, $month);
176 176
                 }
177 177
                 return $all;
178 178
 	}
179
-	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
179
+	public function countAllAirlineCountries($limit = true, $filter_name = '', $year = '', $month = '') {
180 180
 		global $globalStatsFilters;
181 181
 		if ($filter_name == '') $filter_name = $this->filter_name;
182 182
 		if ($year == '' && $month == '') {
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 			try {
186 186
 				$sth = $this->db->prepare($query);
187 187
 				$sth->execute(array(':filter_name' => $filter_name));
188
-			} catch(PDOException $e) {
188
+			} catch (PDOException $e) {
189 189
 				echo "error : ".$e->getMessage();
190 190
 			}
191 191
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -194,13 +194,13 @@  discard block
 block discarded – undo
194 194
             		$Spotter = new Spotter($this->db);
195 195
             		$filters = array();
196 196
             		if ($filter_name != '') {
197
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
197
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
198 198
 			}
199
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
199
+            		$all = $Spotter->countAllAirlineCountries($limit, $filters, $year, $month);
200 200
                 }
201 201
                 return $all;
202 202
 	}
203
-	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
203
+	public function countAllAircraftManufacturers($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
204 204
 		global $globalStatsFilters;
205 205
 		if ($filter_name == '') $filter_name = $this->filter_name;
206 206
 		if ($year == '' && $month == '') {
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 			else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
209 209
 			try {
210 210
 				$sth = $this->db->prepare($query);
211
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
212
-			} catch(PDOException $e) {
211
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
212
+			} catch (PDOException $e) {
213 213
 				echo "error : ".$e->getMessage();
214 214
 			}
215 215
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
217 217
 		if (empty($all)) {
218 218
 			$filters = array('airlines' => array($stats_airline));
219 219
 			if ($filter_name != '') {
220
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
220
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
221 221
 			}
222 222
 			$Spotter = new Spotter($this->db);
223
-			$all = $Spotter->countAllAircraftManufacturers($filters,$year,$month);
223
+			$all = $Spotter->countAllAircraftManufacturers($filters, $year, $month);
224 224
 		}
225 225
 		return $all;
226 226
 	}
227 227
 
228
-	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
228
+	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
229 229
 		global $globalStatsFilters;
230 230
 		if ($filter_name == '') $filter_name = $this->filter_name;
231 231
 		if ($year == '' && $month == '') {
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 			else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
234 234
 			try {
235 235
 				$sth = $this->db->prepare($query);
236
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
237
-			} catch(PDOException $e) {
236
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
237
+			} catch (PDOException $e) {
238 238
 				echo "error : ".$e->getMessage();
239 239
 			}
240 240
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
                 if (empty($all)) {
243 243
 			$filters = array('airlines' => array($stats_airline));
244 244
 			if ($filter_name != '') {
245
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
245
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
246 246
 			}
247 247
 			$Spotter = new Spotter($this->db);
248
-			$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
248
+			$all = $Spotter->countAllArrivalCountries($limit, $filters, $year, $month);
249 249
                 }
250 250
                 return $all;
251 251
 	}
@@ -256,23 +256,23 @@  discard block
 block discarded – undo
256 256
 		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
257 257
                  try {
258 258
                         $sth = $this->db->prepare($query);
259
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
260
-                } catch(PDOException $e) {
259
+                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
260
+                } catch (PDOException $e) {
261 261
                         echo "error : ".$e->getMessage();
262 262
                 }
263 263
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
264 264
                 if (empty($all)) {
265 265
 			$filters = array('airlines' => array($stats_airline));
266 266
 			if ($filter_name != '') {
267
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
267
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
268 268
 			}
269 269
 			$Spotter = new Spotter($this->db);
270
-			$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
270
+			$all = $Spotter->countAllDepartureCountries($filters, $year, $month);
271 271
                 }
272 272
                 return $all;
273 273
 	}
274 274
 
275
-	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
275
+	public function countAllAirlines($limit = true, $filter_name = '', $year = '', $month = '') {
276 276
 		global $globalStatsFilters;
277 277
 		if ($filter_name == '') $filter_name = $this->filter_name;
278 278
 		if ($year == '' && $month == '') {
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 			try {
282 282
 				$sth = $this->db->prepare($query);
283 283
 				$sth->execute(array(':filter_name' => $filter_name));
284
-			} catch(PDOException $e) {
284
+			} catch (PDOException $e) {
285 285
 				echo "error : ".$e->getMessage();
286 286
 			}
287 287
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
 	                $Spotter = new Spotter($this->db);
291 291
             		$filters = array();
292 292
             		if ($filter_name != '') {
293
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
293
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
294 294
 			}
295 295
 
296
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
296
+    		        $all = $Spotter->countAllAirlines($limit, 0, '', $filters, $year, $month);
297 297
                 }
298 298
                 return $all;
299 299
 	}
300
-	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
300
+	public function countAllAircraftRegistrations($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
301 301
 		global $globalStatsFilters;
302 302
 		if ($filter_name == '') $filter_name = $this->filter_name;
303 303
 		if ($year == '' && $month == '') {
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
 			else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
306 306
 			try {
307 307
 				$sth = $this->db->prepare($query);
308
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
309
-			} catch(PDOException $e) {
308
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
309
+			} catch (PDOException $e) {
310 310
 				echo "error : ".$e->getMessage();
311 311
 			}
312 312
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -314,14 +314,14 @@  discard block
 block discarded – undo
314 314
                 if (empty($all)) {
315 315
 			$filters = array('airlines' => array($stats_airline));
316 316
 			if ($filter_name != '') {
317
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
317
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
318 318
 			}
319 319
 	                $Spotter = new Spotter($this->db);
320
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
320
+    		        $all = $Spotter->countAllAircraftRegistrations($limit, 0, '', $filters, $year, $month);
321 321
                 }
322 322
                 return $all;
323 323
 	}
324
-	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
324
+	public function countAllCallsigns($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
325 325
 		global $globalStatsFilters;
326 326
 		if ($filter_name == '') $filter_name = $this->filter_name;
327 327
 		if ($year == '' && $month == '') {
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
 			else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
330 330
 			 try {
331 331
 				$sth = $this->db->prepare($query);
332
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
333
-			} catch(PDOException $e) {
332
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
333
+			} catch (PDOException $e) {
334 334
 				echo "error : ".$e->getMessage();
335 335
 			}
336 336
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -338,14 +338,14 @@  discard block
 block discarded – undo
338 338
 		if (empty($all)) {
339 339
 			$filters = array('airlines' => array($stats_airline));
340 340
 			if ($filter_name != '') {
341
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
341
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
342 342
 			}
343 343
 			$Spotter = new Spotter($this->db);
344
-			$all = $Spotter->countAllCallsigns($limit,0,'',$filters,$year,$month);
344
+			$all = $Spotter->countAllCallsigns($limit, 0, '', $filters, $year, $month);
345 345
 		}
346 346
 		return $all;
347 347
 	}
348
-	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
348
+	public function countAllFlightOverCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
349 349
 		$Connection = new Connection();
350 350
 		if ($filter_name == '') $filter_name = $this->filter_name;
351 351
 		if ($Connection->tableExists('countries')) {
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 				else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
355 355
 				 try {
356 356
 					$sth = $this->db->prepare($query);
357
-					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
358
-				} catch(PDOException $e) {
357
+					$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
358
+				} catch (PDOException $e) {
359 359
 					echo "error : ".$e->getMessage();
360 360
 				}
361 361
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 			return array();
372 372
 		}
373 373
 	}
374
-	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
374
+	public function countAllPilots($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
375 375
 		global $globalStatsFilters;
376 376
 		if ($filter_name == '') $filter_name = $this->filter_name;
377 377
 		if ($year == '' && $month == '') {
@@ -379,8 +379,8 @@  discard block
 block discarded – undo
379 379
 			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
380 380
 			try {
381 381
 				$sth = $this->db->prepare($query);
382
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
383
-			} catch(PDOException $e) {
382
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
383
+			} catch (PDOException $e) {
384 384
 				echo "error : ".$e->getMessage();
385 385
 			}
386 386
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -388,15 +388,15 @@  discard block
 block discarded – undo
388 388
 		if (empty($all)) {
389 389
 			$filters = array('airlines' => array($stats_airline));
390 390
 			if ($filter_name != '') {
391
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
391
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
392 392
 			}
393 393
 			$Spotter = new Spotter($this->db);
394
-			$all = $Spotter->countAllPilots($limit,0,'',$filters,$year,$month);
394
+			$all = $Spotter->countAllPilots($limit, 0, '', $filters, $year, $month);
395 395
 		}
396 396
 		return $all;
397 397
 	}
398 398
 
399
-	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
399
+	public function countAllOwners($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
400 400
 		global $globalStatsFilters;
401 401
 		if ($filter_name == '') $filter_name = $this->filter_name;
402 402
 		if ($year == '' && $month == '') {
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 			else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
405 405
 			try {
406 406
 				$sth = $this->db->prepare($query);
407
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
408
-			} catch(PDOException $e) {
407
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
408
+			} catch (PDOException $e) {
409 409
 				echo "error : ".$e->getMessage();
410 410
 			}
411 411
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -413,14 +413,14 @@  discard block
 block discarded – undo
413 413
                 if (empty($all)) {
414 414
 			$filters = array('airlines' => array($stats_airline));
415 415
 			if ($filter_name != '') {
416
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
416
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
417 417
 			}
418 418
             		$Spotter = new Spotter($this->db);
419
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
419
+            		$all = $Spotter->countAllOwners($limit, 0, '', $filters, $year, $month);
420 420
                 }
421 421
                 return $all;
422 422
 	}
423
-	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
423
+	public function countAllDepartureAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
424 424
 		global $globalStatsFilters;
425 425
 		if ($filter_name == '') $filter_name = $this->filter_name;
426 426
 		if ($year == '' && $month == '') {
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
 			else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
429 429
 			try {
430 430
 				$sth = $this->db->prepare($query);
431
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
432
-			} catch(PDOException $e) {
431
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
432
+			} catch (PDOException $e) {
433 433
 				echo "error : ".$e->getMessage();
434 434
 			}
435 435
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -437,11 +437,11 @@  discard block
 block discarded – undo
437 437
                 if (empty($all)) {
438 438
 			$filters = array('airlines' => array($stats_airline));
439 439
             		if ($filter_name != '') {
440
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
440
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
441 441
 			}
442 442
             		$Spotter = new Spotter($this->db);
443
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
444
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
443
+            		$pall = $Spotter->countAllDepartureAirports($limit, 0, '', $filters, $year, $month);
444
+        		$dall = $Spotter->countAllDetectedDepartureAirports($limit, 0, '', $filters, $year, $month);
445 445
         		$all = array();
446 446
         		foreach ($pall as $value) {
447 447
         			$icao = $value['airport_departure_icao'];
@@ -458,11 +458,11 @@  discard block
 block discarded – undo
458 458
         		foreach ($all as $key => $row) {
459 459
         			$count[$key] = $row['airport_departure_icao_count'];
460 460
         		}
461
-        		array_multisort($count,SORT_DESC,$all);
461
+        		array_multisort($count, SORT_DESC, $all);
462 462
                 }
463 463
                 return $all;
464 464
 	}
465
-	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
465
+	public function countAllArrivalAirports($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
466 466
 		global $globalStatsFilters;
467 467
 		if ($filter_name == '') $filter_name = $this->filter_name;
468 468
 		if ($year == '' && $month == '') {
@@ -470,8 +470,8 @@  discard block
 block discarded – undo
470 470
 			else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
471 471
 			try {
472 472
 				$sth = $this->db->prepare($query);
473
-				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
474
-			} catch(PDOException $e) {
473
+				$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
474
+			} catch (PDOException $e) {
475 475
 				echo "error : ".$e->getMessage();
476 476
 			}
477 477
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -479,11 +479,11 @@  discard block
 block discarded – undo
479 479
 		if (empty($all)) {
480 480
 			$filters = array('airlines' => array($stats_airline));
481 481
 			if ($filter_name != '') {
482
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
482
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
483 483
 			}
484 484
 			$Spotter = new Spotter($this->db);
485
-			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
486
-			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
485
+			$pall = $Spotter->countAllArrivalAirports($limit, 0, '', false, $filters, $year, $month);
486
+			$dall = $Spotter->countAllDetectedArrivalAirports($limit, 0, '', false, $filters, $year, $month);
487 487
         		$all = array();
488 488
         		foreach ($pall as $value) {
489 489
         			$icao = $value['airport_arrival_icao'];
@@ -500,12 +500,12 @@  discard block
 block discarded – undo
500 500
         		foreach ($all as $key => $row) {
501 501
         			$count[$key] = $row['airport_arrival_icao_count'];
502 502
         		}
503
-        		array_multisort($count,SORT_DESC,$all);
503
+        		array_multisort($count, SORT_DESC, $all);
504 504
                 }
505 505
  
506 506
                 return $all;
507 507
 	}
508
-	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
508
+	public function countAllMonthsLastYear($limit = true, $stats_airline = '', $filter_name = '') {
509 509
 		global $globalDBdriver, $globalStatsFilters;
510 510
 		if ($filter_name == '') $filter_name = $this->filter_name;
511 511
 		if ($globalDBdriver == 'mysql') {
@@ -515,18 +515,18 @@  discard block
 block discarded – undo
515 515
 			if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
516 516
 			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
517 517
 		}
518
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
518
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
519 519
                  try {
520 520
                         $sth = $this->db->prepare($query);
521 521
                         $sth->execute($query_data);
522
-                } catch(PDOException $e) {
522
+                } catch (PDOException $e) {
523 523
                         echo "error : ".$e->getMessage();
524 524
                 }
525 525
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
526 526
                 if (empty($all)) {
527 527
 			$filters = array('airlines' => array($stats_airline));
528 528
 			if ($filter_name != '') {
529
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
529
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
530 530
 			}
531 531
             		$Spotter = new Spotter($this->db);
532 532
             		$all = $Spotter->countAllMonthsLastYear($filters);
@@ -535,29 +535,29 @@  discard block
 block discarded – undo
535 535
                 return $all;
536 536
 	}
537 537
 	
538
-	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
538
+	public function countAllDatesLastMonth($stats_airline = '', $filter_name = '') {
539 539
 		global $globalStatsFilters;
540 540
 		if ($filter_name == '') $filter_name = $this->filter_name;
541 541
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
542
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
542
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
543 543
                  try {
544 544
                         $sth = $this->db->prepare($query);
545 545
                         $sth->execute($query_data);
546
-                } catch(PDOException $e) {
546
+                } catch (PDOException $e) {
547 547
                         echo "error : ".$e->getMessage();
548 548
                 }
549 549
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
550 550
                 if (empty($all)) {
551 551
 			$filters = array('airlines' => array($stats_airline));
552 552
 			if ($filter_name != '') {
553
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
553
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
554 554
 			}
555 555
             		$Spotter = new Spotter($this->db);
556 556
             		$all = $Spotter->countAllDatesLastMonth($filters);
557 557
                 }
558 558
                 return $all;
559 559
 	}
560
-	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
560
+	public function countAllDatesLast7Days($stats_airline = '', $filter_name = '') {
561 561
 		global $globalDBdriver, $globalStatsFilters;
562 562
 		if ($filter_name == '') $filter_name = $this->filter_name;
563 563
 		if ($globalDBdriver == 'mysql') {
@@ -565,40 +565,40 @@  discard block
 block discarded – undo
565 565
 		} else {
566 566
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
567 567
 		}
568
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
568
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
569 569
                  try {
570 570
                         $sth = $this->db->prepare($query);
571 571
                         $sth->execute($query_data);
572
-                } catch(PDOException $e) {
572
+                } catch (PDOException $e) {
573 573
                         echo "error : ".$e->getMessage();
574 574
                 }
575 575
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
576 576
                 if (empty($all)) {
577 577
 			$filters = array('airlines' => array($stats_airline));
578 578
 			if ($filter_name != '') {
579
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
579
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
580 580
 			}
581 581
             		$Spotter = new Spotter($this->db);
582 582
             		$all = $Spotter->countAllDatesLast7Days($filters);
583 583
                 }
584 584
                 return $all;
585 585
 	}
586
-	public function countAllDates($stats_airline = '',$filter_name = '') {
586
+	public function countAllDates($stats_airline = '', $filter_name = '') {
587 587
 		global $globalStatsFilters;
588 588
 		if ($filter_name == '') $filter_name = $this->filter_name;
589 589
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
590
-		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
590
+		$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
591 591
                  try {
592 592
                         $sth = $this->db->prepare($query);
593 593
                         $sth->execute($query_data);
594
-                } catch(PDOException $e) {
594
+                } catch (PDOException $e) {
595 595
                         echo "error : ".$e->getMessage();
596 596
                 }
597 597
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
598 598
                 if (empty($all)) {
599 599
 			$filters = array('airlines' => array($stats_airline));
600 600
 			if ($filter_name != '') {
601
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
601
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
602 602
 			}
603 603
             		$Spotter = new Spotter($this->db);
604 604
             		$all = $Spotter->countAllDates($filters);
@@ -613,28 +613,28 @@  discard block
 block discarded – undo
613 613
                  try {
614 614
                         $sth = $this->db->prepare($query);
615 615
                         $sth->execute($query_data);
616
-                } catch(PDOException $e) {
616
+                } catch (PDOException $e) {
617 617
                         echo "error : ".$e->getMessage();
618 618
                 }
619 619
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
620 620
                 if (empty($all)) {
621 621
             		$filters = array();
622 622
             		if ($filter_name != '') {
623
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
623
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
624 624
 			}
625 625
             		$Spotter = new Spotter($this->db);
626 626
             		$all = $Spotter->countAllDatesByAirlines($filters);
627 627
                 }
628 628
                 return $all;
629 629
 	}
630
-	public function countAllMonths($stats_airline = '',$filter_name = '') {
630
+	public function countAllMonths($stats_airline = '', $filter_name = '') {
631 631
 		global $globalStatsFilters;
632 632
 		if ($filter_name == '') $filter_name = $this->filter_name;
633 633
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
634 634
                  try {
635 635
                         $sth = $this->db->prepare($query);
636 636
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
637
-                } catch(PDOException $e) {
637
+                } catch (PDOException $e) {
638 638
                         echo "error : ".$e->getMessage();
639 639
                 }
640 640
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
                 if (empty($all)) {
643 643
 			$filters = array('airlines' => array($stats_airline));
644 644
 			if ($filter_name != '') {
645
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
645
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
646 646
 			}
647 647
             		$Spotter = new Spotter($this->db);
648 648
             		$all = $Spotter->countAllMonths($filters);
@@ -657,21 +657,21 @@  discard block
 block discarded – undo
657 657
                  try {
658 658
                         $sth = $this->db->prepare($query);
659 659
                         $sth->execute(array(':filter_name' => $filter_name));
660
-                } catch(PDOException $e) {
660
+                } catch (PDOException $e) {
661 661
                         echo "error : ".$e->getMessage();
662 662
                 }
663 663
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
664 664
                 if (empty($all)) {
665 665
             		$filters = array();
666 666
             		if ($filter_name != '') {
667
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
667
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
668 668
 			}
669 669
             		$Spotter = new Spotter($this->db);
670 670
             		$all = $Spotter->countAllMilitaryMonths($filters);
671 671
                 }
672 672
                 return $all;
673 673
 	}
674
-	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
674
+	public function countAllHours($orderby = 'hour', $limit = true, $stats_airline = '', $filter_name = '') {
675 675
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
676 676
 		if ($filter_name == '') $filter_name = $this->filter_name;
677 677
 		if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -688,82 +688,82 @@  discard block
 block discarded – undo
688 688
                  try {
689 689
                         $sth = $this->db->prepare($query);
690 690
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
691
-                } catch(PDOException $e) {
691
+                } catch (PDOException $e) {
692 692
                         echo "error : ".$e->getMessage();
693 693
                 }
694 694
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
695 695
                 if (empty($all)) {
696 696
 			$filters = array('airlines' => array($stats_airline));
697 697
 			if ($filter_name != '') {
698
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
698
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
699 699
 			}
700 700
             		$Spotter = new Spotter($this->db);
701
-            		$all = $Spotter->countAllHours($orderby,$filters);
701
+            		$all = $Spotter->countAllHours($orderby, $filters);
702 702
                 }
703 703
                 return $all;
704 704
 	}
705 705
 	
706
-	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
706
+	public function countOverallFlights($stats_airline = '', $filter_name = '', $year = '', $month = '') {
707 707
 		global $globalStatsFilters;
708 708
 		if ($filter_name == '') $filter_name = $this->filter_name;
709 709
 		if ($year == '') $year = date('Y');
710
-		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
710
+		$all = $this->getSumStats('flights_bymonth', $year, $stats_airline, $filter_name, $month);
711 711
 		if (empty($all)) {
712 712
 			$filters = array('airlines' => array($stats_airline));
713 713
 			if ($filter_name != '') {
714
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
714
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
715 715
 			}
716 716
 			$Spotter = new Spotter($this->db);
717
-			$all = $Spotter->countOverallFlights($filters,$year,$month);
717
+			$all = $Spotter->countOverallFlights($filters, $year, $month);
718 718
 		}
719 719
 		return $all;
720 720
 	}
721
-	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
721
+	public function countOverallMilitaryFlights($filter_name = '', $year = '', $month = '') {
722 722
 		global $globalStatsFilters;
723 723
 		if ($filter_name == '') $filter_name = $this->filter_name;
724 724
 		if ($year == '') $year = date('Y');
725
-		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
725
+		$all = $this->getSumStats('military_flights_bymonth', $year, '', $filter_name, $month);
726 726
 		if (empty($all)) {
727 727
 		        $filters = array();
728 728
             		if ($filter_name != '') {
729
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
729
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
730 730
 			}
731 731
 			$Spotter = new Spotter($this->db);
732
-			$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
732
+			$all = $Spotter->countOverallMilitaryFlights($filters, $year, $month);
733 733
 		}
734 734
 		return $all;
735 735
 	}
736
-	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
736
+	public function countOverallArrival($stats_airline = '', $filter_name = '', $year = '', $month = '') {
737 737
 		global $globalStatsFilters;
738 738
 		if ($filter_name == '') $filter_name = $this->filter_name;
739 739
 		if ($year == '') $year = date('Y');
740
-		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
740
+		$all = $this->getSumStats('realarrivals_bymonth', $year, $stats_airline, $filter_name, $month);
741 741
 		if (empty($all)) {
742 742
 			$filters = array('airlines' => array($stats_airline));
743 743
 			if ($filter_name != '') {
744
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
744
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
745 745
 			}
746 746
 			$Spotter = new Spotter($this->db);
747
-			$all = $Spotter->countOverallArrival($filters,$year,$month);
747
+			$all = $Spotter->countOverallArrival($filters, $year, $month);
748 748
 		}
749 749
 		return $all;
750 750
 	}
751
-	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
751
+	public function countOverallAircrafts($stats_airline = '', $filter_name = '', $year = '', $month = '') {
752 752
 		global $globalStatsFilters;
753 753
 		if ($filter_name == '') $filter_name = $this->filter_name;
754 754
 		if ($year == '') $year = date('Y');
755
-		$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
755
+		$all = $this->getSumStats('aircrafts_bymonth', $year, $stats_airline, $filter_name, $month);
756 756
 		if (empty($all)) {
757 757
 			$filters = array('airlines' => array($stats_airline));
758 758
 			if ($filter_name != '') {
759
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
759
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
760 760
 			}
761 761
 			$Spotter = new Spotter($this->db);
762
-			$all = $Spotter->countOverallAircrafts($filters,$year,$month);
762
+			$all = $Spotter->countOverallAircrafts($filters, $year, $month);
763 763
 		}
764 764
 		return $all;
765 765
 	}
766
-	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
766
+	public function countOverallAirlines($filter_name = '', $year = '', $month = '') {
767 767
 		global $globalStatsFilters;
768 768
 		if ($filter_name == '') $filter_name = $this->filter_name;
769 769
 		if ($year == '' && $month == '') {
@@ -771,23 +771,23 @@  discard block
 block discarded – undo
771 771
 			try {
772 772
 				$sth = $this->db->prepare($query);
773 773
 				$sth->execute(array(':filter_name' => $filter_name));
774
-			} catch(PDOException $e) {
774
+			} catch (PDOException $e) {
775 775
 				echo "error : ".$e->getMessage();
776 776
 			}
777 777
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
778 778
 			$all = $result[0]['nb_airline'];
779
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
779
+		} else $all = $this->getSumStats('airlines_bymonth', $year, '', $filter_name, $month);
780 780
 		if (empty($all)) {
781 781
             		$filters = array();
782 782
             		if ($filter_name != '') {
783
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
783
+            			$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
784 784
 			}
785 785
 			$Spotter = new Spotter($this->db);
786
-			$all = $Spotter->countOverallAirlines($filters,$year,$month);
786
+			$all = $Spotter->countOverallAirlines($filters, $year, $month);
787 787
 		}
788 788
 		return $all;
789 789
 	}
790
-	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
790
+	public function countOverallOwners($stats_airline = '', $filter_name = '', $year = '', $month = '') {
791 791
 		global $globalStatsFilters;
792 792
 		if ($filter_name == '') $filter_name = $this->filter_name;
793 793
 		if ($year == '') $year = date('Y');
@@ -802,83 +802,83 @@  discard block
 block discarded – undo
802 802
                 $result = $sth->fetchAll(PDO::FETCH_ASSOC);
803 803
                 $all = $result[0]['nb_owner'];
804 804
                 */
805
-		$all = $this->getSumStats('owners_bymonth',$year,$stats_airline,$filter_name,$month);
805
+		$all = $this->getSumStats('owners_bymonth', $year, $stats_airline, $filter_name, $month);
806 806
 		if (empty($all)) {
807 807
 			$filters = array('airlines' => array($stats_airline));
808 808
 			if ($filter_name != '') {
809
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
809
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
810 810
 			}
811 811
 			$Spotter = new Spotter($this->db);
812
-			$all = $Spotter->countOverallOwners($filters,$year,$month);
812
+			$all = $Spotter->countOverallOwners($filters, $year, $month);
813 813
 		}
814 814
 		return $all;
815 815
 	}
816
-	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
816
+	public function countOverallPilots($stats_airline = '', $filter_name = '', $year = '', $month = '') {
817 817
 		global $globalStatsFilters;
818 818
 		if ($filter_name == '') $filter_name = $this->filter_name;
819 819
 		if ($year == '') $year = date('Y');
820
-		$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
820
+		$all = $this->getSumStats('pilots_bymonth', $year, $stats_airline, $filter_name, $month);
821 821
 		if (empty($all)) {
822 822
 			$filters = array('airlines' => array($stats_airline));
823 823
 			if ($filter_name != '') {
824
-				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
824
+				$filters = array_merge($filters, $globalStatsFilters[$filter_name]);
825 825
 			}
826 826
 			$Spotter = new Spotter($this->db);
827
-			$all = $Spotter->countOverallPilots($filters,$year,$month);
827
+			$all = $Spotter->countOverallPilots($filters, $year, $month);
828 828
 		}
829 829
 		return $all;
830 830
 	}
831 831
 
832
-	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
832
+	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '', $filter_name = '') {
833 833
 		if ($filter_name == '') $filter_name = $this->filter_name;
834 834
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
835
-		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
835
+		$query_values = array(':airport_icao' => $airport_icao, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
836 836
                  try {
837 837
                         $sth = $this->db->prepare($query);
838 838
                         $sth->execute($query_values);
839
-                } catch(PDOException $e) {
839
+                } catch (PDOException $e) {
840 840
                         echo "error : ".$e->getMessage();
841 841
                 }
842 842
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
843 843
                 return $all;
844 844
 	}
845
-	public function getStats($type,$stats_airline = '', $filter_name = '') {
845
+	public function getStats($type, $stats_airline = '', $filter_name = '') {
846 846
 		if ($filter_name == '') $filter_name = $this->filter_name;
847 847
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
848
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
848
+                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
849 849
                  try {
850 850
                         $sth = $this->db->prepare($query);
851 851
                         $sth->execute($query_values);
852
-                } catch(PDOException $e) {
852
+                } catch (PDOException $e) {
853 853
                         echo "error : ".$e->getMessage();
854 854
                 }
855 855
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
856 856
                 return $all;
857 857
         }
858
-	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
858
+	public function getSumStats($type, $year, $stats_airline = '', $filter_name = '', $month = '') {
859 859
 		if ($filter_name == '') $filter_name = $this->filter_name;
860 860
     		global $globalArchiveMonths, $globalDBdriver;
861 861
     		if ($globalDBdriver == 'mysql') {
862 862
     			if ($month == '') {
863 863
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
864
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
864
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
865 865
 			} else {
866 866
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND MONTH(stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
867
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
867
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
868 868
 			}
869 869
 		} else {
870 870
 			if ($month == '') {
871 871
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
872
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
872
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
873 873
 			} else {
874 874
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
875
-				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
875
+				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':month' => $month);
876 876
 			}
877 877
                 }
878 878
                  try {
879 879
                         $sth = $this->db->prepare($query);
880 880
                         $sth->execute($query_values);
881
-                } catch(PDOException $e) {
881
+                } catch (PDOException $e) {
882 882
                         echo "error : ".$e->getMessage();
883 883
                 }
884 884
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
                  try {
897 897
                         $sth = $this->db->prepare($query);
898 898
                         $sth->execute($query_values);
899
-                } catch(PDOException $e) {
899
+                } catch (PDOException $e) {
900 900
                         echo "error : ".$e->getMessage();
901 901
                 }
902 902
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
                  try {
914 914
                         $sth = $this->db->prepare($query);
915 915
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
916
-                } catch(PDOException $e) {
916
+                } catch (PDOException $e) {
917 917
                         echo "error : ".$e->getMessage();
918 918
                 }
919 919
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
                  try {
931 931
                         $sth = $this->db->prepare($query);
932 932
                         $sth->execute(array(':filter_name' => $filter_name));
933
-                } catch(PDOException $e) {
933
+                } catch (PDOException $e) {
934 934
                         echo "error : ".$e->getMessage();
935 935
                 }
936 936
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
                  try {
948 948
                         $sth = $this->db->prepare($query);
949 949
                         $sth->execute(array(':filter_name' => $filter_name));
950
-                } catch(PDOException $e) {
950
+                } catch (PDOException $e) {
951 951
                         echo "error : ".$e->getMessage();
952 952
                 }
953 953
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -964,14 +964,14 @@  discard block
 block discarded – undo
964 964
                  try {
965 965
                         $sth = $this->db->prepare($query);
966 966
                         $sth->execute(array(':filter_name' => $filter_name));
967
-                } catch(PDOException $e) {
967
+                } catch (PDOException $e) {
968 968
                         echo "error : ".$e->getMessage();
969 969
                 }
970 970
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
971 971
                 return $all[0]['total'];
972 972
         }
973 973
 
974
-	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
974
+	public function addStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
975 975
 		global $globalDBdriver;
976 976
 		if ($filter_name == '') $filter_name = $this->filter_name;
977 977
 		if ($globalDBdriver == 'mysql') {
@@ -979,15 +979,15 @@  discard block
 block discarded – undo
979 979
                 } else {
980 980
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
981 981
 		}
982
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
982
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
983 983
                  try {
984 984
                         $sth = $this->db->prepare($query);
985 985
                         $sth->execute($query_values);
986
-                } catch(PDOException $e) {
986
+                } catch (PDOException $e) {
987 987
                         return "error : ".$e->getMessage();
988 988
                 }
989 989
         }
990
-	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
990
+	public function updateStat($type, $cnt, $stats_date, $stats_airline = '', $filter_name = '') {
991 991
 		global $globalDBdriver;
992 992
 		if ($filter_name == '') $filter_name = $this->filter_name;
993 993
 		if ($globalDBdriver == 'mysql') {
@@ -996,11 +996,11 @@  discard block
 block discarded – undo
996 996
             		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
997 997
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
998 998
                 }
999
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
999
+                $query_values = array(':type' => $type, ':cnt' => $cnt, ':stats_date' => $stats_date, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1000 1000
                  try {
1001 1001
                         $sth = $this->db->prepare($query);
1002 1002
                         $sth->execute($query_values);
1003
-                } catch(PDOException $e) {
1003
+                } catch (PDOException $e) {
1004 1004
                         return "error : ".$e->getMessage();
1005 1005
                 }
1006 1006
         }
@@ -1024,75 +1024,75 @@  discard block
 block discarded – undo
1024 1024
         }
1025 1025
         */
1026 1026
 
1027
-	public function getStatsSource($stats_type,$year = '',$month = '',$day = '') {
1027
+	public function getStatsSource($stats_type, $year = '', $month = '', $day = '') {
1028 1028
 		global $globalDBdriver;
1029 1029
 		$query = "SELECT * FROM stats_source WHERE stats_type = :stats_type";
1030 1030
 		$query_values = array();
1031 1031
 		if ($globalDBdriver == 'mysql') {
1032 1032
 			if ($year != '') {
1033 1033
 				$query .= ' AND YEAR(stats_date) = :year';
1034
-				$query_values = array_merge($query_values,array(':year' => $year));
1034
+				$query_values = array_merge($query_values, array(':year' => $year));
1035 1035
 			}
1036 1036
 			if ($month != '') {
1037 1037
 				$query .= ' AND MONTH(stats_date) = :month';
1038
-				$query_values = array_merge($query_values,array(':month' => $month));
1038
+				$query_values = array_merge($query_values, array(':month' => $month));
1039 1039
 			}
1040 1040
 			if ($day != '') {
1041 1041
 				$query .= ' AND DAY(stats_date) = :day';
1042
-				$query_values = array_merge($query_values,array(':day' => $day));
1042
+				$query_values = array_merge($query_values, array(':day' => $day));
1043 1043
 			}
1044 1044
 		} else {
1045 1045
 			if ($year != '') {
1046 1046
 				$query .= ' AND EXTRACT(YEAR FROM stats_date) = :year';
1047
-				$query_values = array_merge($query_values,array(':year' => $year));
1047
+				$query_values = array_merge($query_values, array(':year' => $year));
1048 1048
 			}
1049 1049
 			if ($month != '') {
1050 1050
 				$query .= ' AND EXTRACT(MONTH FROM stats_date) = :month';
1051
-				$query_values = array_merge($query_values,array(':month' => $month));
1051
+				$query_values = array_merge($query_values, array(':month' => $month));
1052 1052
 			}
1053 1053
 			if ($day != '') {
1054 1054
 				$query .= ' AND EXTRACT(DAY FROM stats_date) = :day';
1055
-				$query_values = array_merge($query_values,array(':day' => $day));
1055
+				$query_values = array_merge($query_values, array(':day' => $day));
1056 1056
 			}
1057 1057
 		}
1058 1058
 		$query .= " ORDER BY source_name";
1059
-		$query_values = array_merge($query_values,array(':stats_type' => $stats_type));
1059
+		$query_values = array_merge($query_values, array(':stats_type' => $stats_type));
1060 1060
 		try {
1061 1061
 			$sth = $this->db->prepare($query);
1062 1062
 			$sth->execute($query_values);
1063
-		} catch(PDOException $e) {
1063
+		} catch (PDOException $e) {
1064 1064
 			echo "error : ".$e->getMessage();
1065 1065
 		}
1066 1066
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1067 1067
 		return $all;
1068 1068
 	}
1069 1069
 
1070
-	public function addStatSource($data,$source_name,$stats_type,$date) {
1070
+	public function addStatSource($data, $source_name, $stats_type, $date) {
1071 1071
 		global $globalDBdriver;
1072 1072
 		if ($globalDBdriver == 'mysql') {
1073 1073
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
1074 1074
 		} else {
1075 1075
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
1076 1076
                 }
1077
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1077
+                $query_values = array(':data' => $data, ':stats_date' => $date, ':source_name' => $source_name, ':stats_type' => $stats_type);
1078 1078
                  try {
1079 1079
                         $sth = $this->db->prepare($query);
1080 1080
                         $sth->execute($query_values);
1081
-                } catch(PDOException $e) {
1081
+                } catch (PDOException $e) {
1082 1082
                         return "error : ".$e->getMessage();
1083 1083
                 }
1084 1084
         }
1085
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1085
+	public function addStatFlight($type, $date_name, $cnt, $stats_airline = '', $filter_name = '') {
1086 1086
                 $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1087
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1087
+                $query_values = array(':type' => $type, ':flight_date' => $date_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1088 1088
                  try {
1089 1089
                         $sth = $this->db->prepare($query);
1090 1090
                         $sth->execute($query_values);
1091
-                } catch(PDOException $e) {
1091
+                } catch (PDOException $e) {
1092 1092
                         return "error : ".$e->getMessage();
1093 1093
                 }
1094 1094
         }
1095
-	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1095
+	public function addStatAircraftRegistration($registration, $cnt, $aircraft_icao = '', $airline_icao = '', $filter_name = '', $reset = false) {
1096 1096
 		global $globalDBdriver;
1097 1097
 		if ($globalDBdriver == 'mysql') {
1098 1098
 			if ($reset) {
@@ -1107,15 +1107,15 @@  discard block
 block discarded – undo
1107 1107
 				$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1108 1108
 			}
1109 1109
 		}
1110
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1110
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':registration' => $registration, ':cnt' => $cnt, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1111 1111
                  try {
1112 1112
                         $sth = $this->db->prepare($query);
1113 1113
                         $sth->execute($query_values);
1114
-                } catch(PDOException $e) {
1114
+                } catch (PDOException $e) {
1115 1115
                         return "error : ".$e->getMessage();
1116 1116
                 }
1117 1117
         }
1118
-	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1118
+	public function addStatCallsign($callsign_icao, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1119 1119
 		global $globalDBdriver;
1120 1120
 		if ($globalDBdriver == 'mysql') {
1121 1121
 			if ($reset) {
@@ -1130,15 +1130,15 @@  discard block
 block discarded – undo
1130 1130
 				$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; 
1131 1131
 			}
1132 1132
 		}
1133
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1133
+                $query_values = array(':callsign_icao' => $callsign_icao, ':airline_icao' => $airline_icao, ':cnt' => $cnt, ':filter_name' => $filter_name);
1134 1134
                  try {
1135 1135
                         $sth = $this->db->prepare($query);
1136 1136
                         $sth->execute($query_values);
1137
-                } catch(PDOException $e) {
1137
+                } catch (PDOException $e) {
1138 1138
                         return "error : ".$e->getMessage();
1139 1139
                 }
1140 1140
         }
1141
-	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1141
+	public function addStatCountry($iso2, $iso3, $name, $cnt, $airline_icao = '', $filter_name = '', $reset = false) {
1142 1142
 		global $globalDBdriver;
1143 1143
 		if ($globalDBdriver == 'mysql') {
1144 1144
 			if ($reset) {
@@ -1153,15 +1153,15 @@  discard block
 block discarded – undo
1153 1153
 				$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);"; 
1154 1154
 			}
1155 1155
 		}
1156
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1156
+                $query_values = array(':iso2' => $iso2, ':iso3' => $iso3, ':name' => $name, ':cnt' => $cnt, ':filter_name' => $filter_name, ':airline' => $airline_icao);
1157 1157
                  try {
1158 1158
                         $sth = $this->db->prepare($query);
1159 1159
                         $sth->execute($query_values);
1160
-                } catch(PDOException $e) {
1160
+                } catch (PDOException $e) {
1161 1161
                         return "error : ".$e->getMessage();
1162 1162
                 }
1163 1163
         }
1164
-	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1164
+	public function addStatAircraft($aircraft_icao, $cnt, $aircraft_name = '', $aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1165 1165
 		global $globalDBdriver;
1166 1166
 		if ($globalDBdriver == 'mysql') {
1167 1167
 			if ($reset) {
@@ -1176,15 +1176,15 @@  discard block
 block discarded – undo
1176 1176
 				$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1177 1177
 			}
1178 1178
 		}
1179
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1179
+                $query_values = array(':aircraft_icao' => $aircraft_icao, ':aircraft_name' => $aircraft_name, ':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1180 1180
                  try {
1181 1181
                         $sth = $this->db->prepare($query);
1182 1182
                         $sth->execute($query_values);
1183
-                } catch(PDOException $e) {
1183
+                } catch (PDOException $e) {
1184 1184
                         return "error : ".$e->getMessage();
1185 1185
                 }
1186 1186
         }
1187
-	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1187
+	public function addStatAirline($airline_icao, $cnt, $airline_name = '', $filter_name = '', $reset = false) {
1188 1188
 		global $globalDBdriver;
1189 1189
 		if ($globalDBdriver == 'mysql') {
1190 1190
 			if ($reset) {
@@ -1199,15 +1199,15 @@  discard block
 block discarded – undo
1199 1199
 				$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; 
1200 1200
 			}
1201 1201
 		}
1202
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1202
+                $query_values = array(':airline_icao' => $airline_icao, ':airline_name' => $airline_name, ':cnt' => $cnt, ':filter_name' => $filter_name);
1203 1203
                  try {
1204 1204
                         $sth = $this->db->prepare($query);
1205 1205
                         $sth->execute($query_values);
1206
-                } catch(PDOException $e) {
1206
+                } catch (PDOException $e) {
1207 1207
                         return "error : ".$e->getMessage();
1208 1208
                 }
1209 1209
         }
1210
-	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1210
+	public function addStatOwner($owner_name, $cnt, $stats_airline = '', $filter_name = '', $reset = false) {
1211 1211
 		global $globalDBdriver;
1212 1212
 		if ($globalDBdriver == 'mysql') {
1213 1213
 			if ($reset) {
@@ -1222,15 +1222,15 @@  discard block
 block discarded – undo
1222 1222
 				$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1223 1223
 			}
1224 1224
 		}
1225
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1225
+                $query_values = array(':owner_name' => $owner_name, ':cnt' => $cnt, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1226 1226
                  try {
1227 1227
                         $sth = $this->db->prepare($query);
1228 1228
                         $sth->execute($query_values);
1229
-                } catch(PDOException $e) {
1229
+                } catch (PDOException $e) {
1230 1230
                         return "error : ".$e->getMessage();
1231 1231
                 }
1232 1232
         }
1233
-	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1233
+	public function addStatPilot($pilot_id, $cnt, $pilot_name, $stats_airline = '', $filter_name = '', $format_source = '', $reset = false) {
1234 1234
 		global $globalDBdriver;
1235 1235
 		if ($globalDBdriver == 'mysql') {
1236 1236
 			if ($reset) {
@@ -1245,15 +1245,15 @@  discard block
 block discarded – undo
1245 1245
 				$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; 
1246 1246
 			}
1247 1247
 		}
1248
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1248
+                $query_values = array(':pilot_id' => $pilot_id, ':cnt' => $cnt, ':pilot_name' => $pilot_name, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name, ':format_source' => $format_source);
1249 1249
                  try {
1250 1250
                         $sth = $this->db->prepare($query);
1251 1251
                         $sth->execute($query_values);
1252
-                } catch(PDOException $e) {
1252
+                } catch (PDOException $e) {
1253 1253
                         return "error : ".$e->getMessage();
1254 1254
                 }
1255 1255
         }
1256
-	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1256
+	public function addStatDepartureAirports($airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '', $reset = false) {
1257 1257
 		global $globalDBdriver;
1258 1258
 		if ($airport_icao != '') {
1259 1259
 			if ($globalDBdriver == 'mysql') {
@@ -1269,16 +1269,16 @@  discard block
 block discarded – undo
1269 1269
 					$query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1270 1270
 				}
1271 1271
 			}
1272
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1272
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1273 1273
 			try {
1274 1274
 				$sth = $this->db->prepare($query);
1275 1275
 				$sth->execute($query_values);
1276
-			} catch(PDOException $e) {
1276
+			} catch (PDOException $e) {
1277 1277
 				return "error : ".$e->getMessage();
1278 1278
 			}
1279 1279
                 }
1280 1280
         }
1281
-	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1281
+	public function addStatDepartureAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $departure, $airline_icao = '', $filter_name = '') {
1282 1282
 		global $globalDBdriver;
1283 1283
 		if ($airport_icao != '') {
1284 1284
 			if ($globalDBdriver == 'mysql') {
@@ -1286,16 +1286,16 @@  discard block
 block discarded – undo
1286 1286
 			} else {
1287 1287
 				$query = "UPDATE stats_airport SET departure = :departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1288 1288
 			}
1289
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1289
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':departure' => $departure, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1290 1290
 			 try {
1291 1291
 				$sth = $this->db->prepare($query);
1292 1292
 				$sth->execute($query_values);
1293
-			} catch(PDOException $e) {
1293
+			} catch (PDOException $e) {
1294 1294
 				return "error : ".$e->getMessage();
1295 1295
 			}
1296 1296
                 }
1297 1297
         }
1298
-	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1298
+	public function addStatArrivalAirports($airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '', $reset = false) {
1299 1299
 		global $globalDBdriver;
1300 1300
 		if ($airport_icao != '') {
1301 1301
 			if ($globalDBdriver == 'mysql') {
@@ -1311,16 +1311,16 @@  discard block
 block discarded – undo
1311 1311
 					$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1312 1312
 				}
1313 1313
 			}
1314
-	                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1314
+	                $query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1315 1315
 			 try {
1316 1316
                     		$sth = $this->db->prepare($query);
1317 1317
 	                        $sth->execute($query_values);
1318
-    		        } catch(PDOException $e) {
1318
+    		        } catch (PDOException $e) {
1319 1319
             		        return "error : ".$e->getMessage();
1320 1320
 	                }
1321 1321
 	        }
1322 1322
         }
1323
-	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1323
+	public function addStatArrivalAirportsDaily($date, $airport_icao, $airport_name, $airport_city, $airport_country, $arrival, $airline_icao = '', $filter_name = '') {
1324 1324
 		global $globalDBdriver;
1325 1325
 		if ($airport_icao != '') {
1326 1326
 			if ($globalDBdriver == 'mysql') {
@@ -1328,11 +1328,11 @@  discard block
 block discarded – undo
1328 1328
 			} else {
1329 1329
 				$query = "UPDATE stats_airport SET arrival = :arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1330 1330
 			}
1331
-			$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1331
+			$query_values = array(':airport_icao' => $airport_icao, ':airport_name' => $airport_name, ':airport_city' => $airport_city, ':airport_country' => $airport_country, ':arrival' => $arrival, ':date' => $date, ':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1332 1332
 			try {
1333 1333
 				$sth = $this->db->prepare($query);
1334 1334
 				$sth->execute($query_values);
1335
-			} catch(PDOException $e) {
1335
+			} catch (PDOException $e) {
1336 1336
 				return "error : ".$e->getMessage();
1337 1337
 			}
1338 1338
                 }
@@ -1344,7 +1344,7 @@  discard block
 block discarded – undo
1344 1344
                  try {
1345 1345
                         $sth = $this->db->prepare($query);
1346 1346
                         $sth->execute($query_values);
1347
-                } catch(PDOException $e) {
1347
+                } catch (PDOException $e) {
1348 1348
                         return "error : ".$e->getMessage();
1349 1349
                 }
1350 1350
         }
@@ -1354,7 +1354,7 @@  discard block
 block discarded – undo
1354 1354
                  try {
1355 1355
                         $sth = $this->db->prepare($query);
1356 1356
                         $sth->execute($query_values);
1357
-                } catch(PDOException $e) {
1357
+                } catch (PDOException $e) {
1358 1358
                         return "error : ".$e->getMessage();
1359 1359
                 }
1360 1360
         }
@@ -1364,13 +1364,13 @@  discard block
 block discarded – undo
1364 1364
                  try {
1365 1365
                         $sth = $this->db->prepare($query);
1366 1366
                         $sth->execute($query_values);
1367
-                } catch(PDOException $e) {
1367
+                } catch (PDOException $e) {
1368 1368
                         return "error : ".$e->getMessage();
1369 1369
                 }
1370 1370
         }
1371 1371
         
1372 1372
         public function addOldStats() {
1373
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1373
+    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters, $globalDeleteLastYearStats, $globalStatsReset, $globalStatsResetYear;
1374 1374
     		$Common = new Common();
1375 1375
     		$Connection = new Connection();
1376 1376
     		date_default_timezone_set('UTC');
@@ -1387,40 +1387,40 @@  discard block
 block discarded – undo
1387 1387
 			$Spotter = new Spotter($this->db);
1388 1388
 
1389 1389
 			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1390
-			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1390
+			$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day);
1391 1391
 			foreach ($alldata as $number) {
1392
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1392
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', '', $reset);
1393 1393
 			}
1394 1394
 			if ($globalDebug) echo 'Count all airlines...'."\n";
1395
-			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1395
+			$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day);
1396 1396
 			foreach ($alldata as $number) {
1397
-				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1397
+				$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], '', $reset);
1398 1398
 			}
1399 1399
 			if ($globalDebug) echo 'Count all registrations...'."\n";
1400
-			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1400
+			$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day);
1401 1401
 			foreach ($alldata as $number) {
1402
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1402
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', '', $reset);
1403 1403
 			}
1404 1404
 			if ($globalDebug) echo 'Count all callsigns...'."\n";
1405
-			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1405
+			$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day);
1406 1406
 			foreach ($alldata as $number) {
1407
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1407
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1408 1408
 			}
1409 1409
 			if ($globalDebug) echo 'Count all owners...'."\n";
1410
-			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1410
+			$alldata = $Spotter->countAllOwners(false, 0, $last_update_day);
1411 1411
 			foreach ($alldata as $number) {
1412
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1412
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], '', '', $reset);
1413 1413
 			}
1414 1414
 			if ($globalDebug) echo 'Count all pilots...'."\n";
1415
-			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1415
+			$alldata = $Spotter->countAllPilots(false, 0, $last_update_day);
1416 1416
 			foreach ($alldata as $number) {
1417
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1417
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', '', $number['format_source'], $reset);
1418 1418
 			}
1419 1419
 			
1420 1420
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1421
-			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1421
+			$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day);
1422 1422
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1423
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1423
+        		$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day);
1424 1424
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1425 1425
 	        	$alldata = array();
1426 1426
 	        	
@@ -1438,14 +1438,14 @@  discard block
 block discarded – undo
1438 1438
     			foreach ($alldata as $key => $row) {
1439 1439
     				$count[$key] = $row['airport_departure_icao_count'];
1440 1440
         		}
1441
-			array_multisort($count,SORT_DESC,$alldata);
1441
+			array_multisort($count, SORT_DESC, $alldata);
1442 1442
 			foreach ($alldata as $number) {
1443
-				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
1443
+				echo $this->addStatDepartureAirports($number['airport_departure_icao'], $number['airport_departure_name'], $number['airport_departure_city'], $number['airport_departure_country'], $number['airport_departure_icao_count'], '', '', $reset);
1444 1444
 			}
1445 1445
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1446
-			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1446
+			$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day);
1447 1447
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1448
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1448
+        		$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day);
1449 1449
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1450 1450
 	        	$alldata = array();
1451 1451
     			foreach ($pall as $value) {
@@ -1462,16 +1462,16 @@  discard block
 block discarded – undo
1462 1462
         		foreach ($alldata as $key => $row) {
1463 1463
         			$count[$key] = $row['airport_arrival_icao_count'];
1464 1464
 	        	}
1465
-    			array_multisort($count,SORT_DESC,$alldata);
1465
+    			array_multisort($count, SORT_DESC, $alldata);
1466 1466
                         foreach ($alldata as $number) {
1467
-				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
1467
+				echo $this->addStatArrivalAirports($number['airport_arrival_icao'], $number['airport_arrival_name'], $number['airport_arrival_city'], $number['airport_arrival_country'], $number['airport_arrival_icao_count'], '', '', $reset);
1468 1468
 			}
1469 1469
 			if ($Connection->tableExists('countries')) {
1470 1470
 				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1471 1471
 				$SpotterArchive = new SpotterArchive();
1472
-				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1472
+				$alldata = $SpotterArchive->countAllFlightOverCountries(false, 0, $last_update_day);
1473 1473
 				foreach ($alldata as $number) {
1474
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],'','',$reset);
1474
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], '', '', $reset);
1475 1475
 				}
1476 1476
 			}
1477 1477
 			
@@ -1485,37 +1485,37 @@  discard block
 block discarded – undo
1485 1485
 			$lastyear = false;
1486 1486
 			foreach ($alldata as $number) {
1487 1487
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1488
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1488
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1489 1489
 			}
1490 1490
 			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1491 1491
 			$alldata = $Spotter->countAllMilitaryMonths();
1492 1492
 			foreach ($alldata as $number) {
1493
-				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1493
+				$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1494 1494
 			}
1495 1495
 			if ($globalDebug) echo 'Count all owners by months...'."\n";
1496 1496
 			$alldata = $Spotter->countAllMonthsOwners();
1497 1497
 			foreach ($alldata as $number) {
1498
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1498
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1499 1499
 			}
1500 1500
 			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1501 1501
 			$alldata = $Spotter->countAllMonthsPilots();
1502 1502
 			foreach ($alldata as $number) {
1503
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1503
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1504 1504
 			}
1505 1505
 			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1506 1506
 			$alldata = $Spotter->countAllMonthsAirlines();
1507 1507
 			foreach ($alldata as $number) {
1508
-				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1508
+				$this->addStat('airlines_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1509 1509
 			}
1510 1510
 			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1511 1511
 			$alldata = $Spotter->countAllMonthsAircrafts();
1512 1512
 			foreach ($alldata as $number) {
1513
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1513
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1514 1514
 			}
1515 1515
 			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1516 1516
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1517 1517
 			foreach ($alldata as $number) {
1518
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1518
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])));
1519 1519
 			}
1520 1520
 			if ($globalDebug) echo 'Airports data...'."\n";
1521 1521
 			if ($globalDebug) echo '...Departure'."\n";
@@ -1560,7 +1560,7 @@  discard block
 block discarded – undo
1560 1560
     			}
1561 1561
     			$alldata = $pall;
1562 1562
 			foreach ($alldata as $number) {
1563
-				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1563
+				$this->addStatDepartureAirportsDaily($number['date'], $number['departure_airport_icao'], $number['departure_airport_name'], $number['departure_airport_city'], $number['departure_airport_country'], $number['departure_airport_count']);
1564 1564
 			}
1565 1565
 			echo '...Arrival'."\n";
1566 1566
 			$pall = $Spotter->getLast7DaysAirportsArrival();
@@ -1602,7 +1602,7 @@  discard block
 block discarded – undo
1602 1602
     			}
1603 1603
     			$alldata = $pall;
1604 1604
 			foreach ($alldata as $number) {
1605
-				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1605
+				$this->addStatArrivalAirportsDaily($number['date'], $number['arrival_airport_icao'], $number['arrival_airport_name'], $number['arrival_airport_city'], $number['arrival_airport_country'], $number['arrival_airport_count']);
1606 1606
 			}
1607 1607
 
1608 1608
 			echo 'Flights data...'."\n";
@@ -1610,28 +1610,28 @@  discard block
 block discarded – undo
1610 1610
 			echo '-> countAllDatesLastMonth...'."\n";
1611 1611
 			$alldata = $Spotter->countAllDatesLastMonth();
1612 1612
 			foreach ($alldata as $number) {
1613
-				$this->addStatFlight('month',$number['date_name'],$number['date_count']);
1613
+				$this->addStatFlight('month', $number['date_name'], $number['date_count']);
1614 1614
 			}
1615 1615
 			echo '-> countAllDates...'."\n";
1616 1616
 			$previousdata = $this->countAllDates();
1617 1617
 			$previousdatabyairlines = $this->countAllDatesByAirlines();
1618 1618
 			$this->deleteStatFlight('date');
1619
-			$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates());
1619
+			$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates());
1620 1620
 			$values = array();
1621 1621
 			foreach ($alldata as $cnt) {
1622 1622
 				$values[] = $cnt['date_count'];
1623 1623
 			}
1624
-			array_multisort($values,SORT_DESC,$alldata);
1625
-			array_splice($alldata,11);
1624
+			array_multisort($values, SORT_DESC, $alldata);
1625
+			array_splice($alldata, 11);
1626 1626
 			foreach ($alldata as $number) {
1627
-				$this->addStatFlight('date',$number['date_name'],$number['date_count']);
1627
+				$this->addStatFlight('date', $number['date_name'], $number['date_count']);
1628 1628
 			}
1629 1629
 			
1630 1630
 			$this->deleteStatFlight('hour');
1631 1631
 			echo '-> countAllHours...'."\n";
1632 1632
 			$alldata = $Spotter->countAllHours('hour');
1633 1633
 			foreach ($alldata as $number) {
1634
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count']);
1634
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count']);
1635 1635
 			}
1636 1636
 
1637 1637
 
@@ -1641,41 +1641,41 @@  discard block
 block discarded – undo
1641 1641
 			if ($Connection->tableExists('countries')) {
1642 1642
 				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
1643 1643
 				$SpotterArchive = new SpotterArchive();
1644
-				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1644
+				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false, 0, $last_update_day);
1645 1645
 				foreach ($alldata as $number) {
1646
-					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
1646
+					$this->addStatCountry($number['flight_country_iso2'], $number['flight_country_iso3'], $number['flight_country'], $number['flight_count'], $number['airline_icao'], '', $reset);
1647 1647
 				}
1648 1648
 			}
1649 1649
 			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1650 1650
 			$Spotter = new Spotter($this->db);
1651
-			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1651
+			$alldata = $Spotter->countAllAircraftTypesByAirlines(false, 0, $last_update_day);
1652 1652
 			foreach ($alldata as $number) {
1653
-				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1653
+				$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], $number['airline_icao'], '', $reset);
1654 1654
 			}
1655 1655
 			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1656
-			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1656
+			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false, 0, $last_update_day);
1657 1657
 			foreach ($alldata as $number) {
1658
-				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1658
+				$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], $number['airline_icao'], '', $reset);
1659 1659
 			}
1660 1660
 			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1661
-			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1661
+			$alldata = $Spotter->countAllCallsignsByAirlines(false, 0, $last_update_day);
1662 1662
 			foreach ($alldata as $number) {
1663
-				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1663
+				$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], $number['airline_icao'], '', $reset);
1664 1664
 			}
1665 1665
 			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1666
-			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1666
+			$alldata = $Spotter->countAllOwnersByAirlines(false, 0, $last_update_day);
1667 1667
 			foreach ($alldata as $number) {
1668
-				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1668
+				$this->addStatOwner($number['owner_name'], $number['owner_count'], $number['airline_icao'], '', $reset);
1669 1669
 			}
1670 1670
 			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1671
-			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1671
+			$alldata = $Spotter->countAllPilotsByAirlines(false, 0, $last_update_day);
1672 1672
 			foreach ($alldata as $number) {
1673
-				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1673
+				$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], $number['airline_icao'], '', $number['format_source'], $reset);
1674 1674
 			}
1675 1675
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1676
-			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1676
+			$pall = $Spotter->countAllDepartureAirportsByAirlines(false, 0, $last_update_day);
1677 1677
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1678
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1678
+       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false, 0, $last_update_day);
1679 1679
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1680 1680
 	        	//$alldata = array();
1681 1681
     			foreach ($dall as $value) {
@@ -1695,12 +1695,12 @@  discard block
 block discarded – undo
1695 1695
     			}
1696 1696
     			$alldata = $pall;
1697 1697
 			foreach ($alldata as $number) {
1698
-				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);
1698
+				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);
1699 1699
 			}
1700 1700
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1701
-			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1701
+			$pall = $Spotter->countAllArrivalAirportsByAirlines(false, 0, $last_update_day);
1702 1702
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1703
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1703
+        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false, 0, $last_update_day);
1704 1704
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1705 1705
 	        	//$alldata = array();
1706 1706
     			foreach ($dall as $value) {
@@ -1720,7 +1720,7 @@  discard block
 block discarded – undo
1720 1720
     			}
1721 1721
     			$alldata = $pall;
1722 1722
                         foreach ($alldata as $number) {
1723
-				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);
1723
+				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);
1724 1724
 			}
1725 1725
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1726 1726
 			$Spotter = new Spotter($this->db);
@@ -1728,27 +1728,27 @@  discard block
 block discarded – undo
1728 1728
 			$lastyear = false;
1729 1729
 			foreach ($alldata as $number) {
1730 1730
 				if ($number['year_name'] != date('Y')) $lastyear = true;
1731
-				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1731
+				$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1732 1732
 			}
1733 1733
 			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1734 1734
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1735 1735
 			foreach ($alldata as $number) {
1736
-				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1736
+				$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1737 1737
 			}
1738 1738
 			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
1739 1739
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1740 1740
 			foreach ($alldata as $number) {
1741
-				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1741
+				$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1742 1742
 			}
1743 1743
 			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
1744 1744
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1745 1745
 			foreach ($alldata as $number) {
1746
-				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1746
+				$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1747 1747
 			}
1748 1748
 			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
1749 1749
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1750 1750
 			foreach ($alldata as $number) {
1751
-				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1751
+				$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), $number['airline_icao']);
1752 1752
 			}
1753 1753
 			if ($globalDebug) echo '...Departure'."\n";
1754 1754
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
@@ -1771,7 +1771,7 @@  discard block
 block discarded – undo
1771 1771
     			}
1772 1772
     			$alldata = $pall;
1773 1773
 			foreach ($alldata as $number) {
1774
-				$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']);
1774
+				$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']);
1775 1775
 			}
1776 1776
 			if ($globalDebug) echo '...Arrival'."\n";
1777 1777
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
@@ -1794,32 +1794,32 @@  discard block
 block discarded – undo
1794 1794
     			}
1795 1795
     			$alldata = $pall;
1796 1796
 			foreach ($alldata as $number) {
1797
-				$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']);
1797
+				$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']);
1798 1798
 			}
1799 1799
 
1800 1800
 			if ($globalDebug) echo 'Flights data...'."\n";
1801 1801
 			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
1802 1802
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1803 1803
 			foreach ($alldata as $number) {
1804
-				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1804
+				$this->addStatFlight('month', $number['date_name'], $number['date_count'], $number['airline_icao']);
1805 1805
 			}
1806 1806
 			if ($globalDebug) echo '-> countAllDates...'."\n";
1807 1807
 			//$previousdata = $this->countAllDatesByAirlines();
1808
-			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1808
+			$alldata = $Common->array_merge_noappend($previousdatabyairlines, $Spotter->countAllDatesByAirlines());
1809 1809
 			$values = array();
1810 1810
 			foreach ($alldata as $cnt) {
1811 1811
 				$values[] = $cnt['date_count'];
1812 1812
 			}
1813
-			array_multisort($values,SORT_DESC,$alldata);
1814
-			array_splice($alldata,11);
1813
+			array_multisort($values, SORT_DESC, $alldata);
1814
+			array_splice($alldata, 11);
1815 1815
 			foreach ($alldata as $number) {
1816
-				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1816
+				$this->addStatFlight('date', $number['date_name'], $number['date_count'], $number['airline_icao']);
1817 1817
 			}
1818 1818
 			
1819 1819
 			if ($globalDebug) echo '-> countAllHours...'."\n";
1820 1820
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1821 1821
 			foreach ($alldata as $number) {
1822
-				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
1822
+				$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], $number['airline_icao']);
1823 1823
 			}
1824 1824
 			
1825 1825
 
@@ -1838,32 +1838,32 @@  discard block
 block discarded – undo
1838 1838
 				// Count by filter
1839 1839
 				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
1840 1840
 				$Spotter = new Spotter($this->db);
1841
-				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1841
+				$alldata = $Spotter->countAllAircraftTypes(false, 0, $last_update_day, $filter);
1842 1842
 				foreach ($alldata as $number) {
1843
-					$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
1843
+					$this->addStatAircraft($number['aircraft_icao'], $number['aircraft_icao_count'], $number['aircraft_name'], $number['aircraft_manufacturer'], '', $filter_name, $reset);
1844 1844
 				}
1845
-				$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
1845
+				$alldata = $Spotter->countAllAirlines(false, 0, $last_update_day, $filter);
1846 1846
 				foreach ($alldata as $number) {
1847
-					$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
1847
+					$this->addStatAirline($number['airline_icao'], $number['airline_count'], $number['airline_name'], $filter_name, $reset);
1848 1848
 				}
1849
-				$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
1849
+				$alldata = $Spotter->countAllAircraftRegistrations(false, 0, $last_update_day, $filter);
1850 1850
 				foreach ($alldata as $number) {
1851
-					$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
1851
+					$this->addStatAircraftRegistration($number['registration'], $number['aircraft_registration_count'], $number['aircraft_icao'], '', $filter_name, $reset);
1852 1852
 				}
1853
-				$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
1853
+				$alldata = $Spotter->countAllCallsigns(false, 0, $last_update_day, $filter);
1854 1854
 				foreach ($alldata as $number) {
1855
-					$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
1855
+					$this->addStatCallsign($number['callsign_icao'], $number['callsign_icao_count'], '', $filter_name, $reset);
1856 1856
 				}
1857
-				$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
1857
+				$alldata = $Spotter->countAllOwners(false, 0, $last_update_day, $filter);
1858 1858
 				foreach ($alldata as $number) {
1859
-					$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
1859
+					$this->addStatOwner($number['owner_name'], $number['owner_count'], '', $filter_name, $reset);
1860 1860
 				}
1861
-				$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
1861
+				$alldata = $Spotter->countAllPilots(false, 0, $last_update_day, $filter);
1862 1862
 				foreach ($alldata as $number) {
1863
-					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
1863
+					$this->addStatPilot($number['pilot_id'], $number['pilot_count'], $number['pilot_name'], '', $filter_name, $number['format_source'], $reset);
1864 1864
 				}
1865
-				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1866
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1865
+				$pall = $Spotter->countAllDepartureAirports(false, 0, $last_update_day, $filter);
1866
+	       			$dall = $Spotter->countAllDetectedDepartureAirports(false, 0, $last_update_day, $filter);
1867 1867
 		        	$alldata = array();
1868 1868
 	    			foreach ($pall as $value) {
1869 1869
 		        		$icao = $value['airport_departure_icao'];
@@ -1879,12 +1879,12 @@  discard block
 block discarded – undo
1879 1879
     				foreach ($alldata as $key => $row) {
1880 1880
     					$count[$key] = $row['airport_departure_icao_count'];
1881 1881
     				}
1882
-				array_multisort($count,SORT_DESC,$alldata);
1882
+				array_multisort($count, SORT_DESC, $alldata);
1883 1883
 				foreach ($alldata as $number) {
1884
-    					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);
1884
+    					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);
1885 1885
 				}
1886
-				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
1887
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1886
+				$pall = $Spotter->countAllArrivalAirports(false, 0, $last_update_day, false, $filter);
1887
+    				$dall = $Spotter->countAllDetectedArrivalAirports(false, 0, $last_update_day, false, $filter);
1888 1888
 				$alldata = array();
1889 1889
     				foreach ($pall as $value) {
1890 1890
 		        		$icao = $value['airport_arrival_icao'];
@@ -1900,40 +1900,40 @@  discard block
 block discarded – undo
1900 1900
         			foreach ($alldata as $key => $row) {
1901 1901
     					$count[$key] = $row['airport_arrival_icao_count'];
1902 1902
 		        	}
1903
-        			array_multisort($count,SORT_DESC,$alldata);
1903
+        			array_multisort($count, SORT_DESC, $alldata);
1904 1904
 				foreach ($alldata as $number) {
1905
-					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);
1905
+					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);
1906 1906
 				}
1907 1907
 				$Spotter = new Spotter($this->db);
1908 1908
 				$alldata = $Spotter->countAllMonths($filter);
1909 1909
 				$lastyear = false;
1910 1910
 				foreach ($alldata as $number) {
1911 1911
 					if ($number['year_name'] != date('Y')) $lastyear = true;
1912
-					$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1912
+					$this->addStat('flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1913 1913
 				}
1914 1914
 				$alldata = $Spotter->countAllMonthsOwners($filter);
1915 1915
 				foreach ($alldata as $number) {
1916
-					$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1916
+					$this->addStat('owners_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1917 1917
 				}
1918 1918
 				$alldata = $Spotter->countAllMonthsPilots($filter);
1919 1919
 				foreach ($alldata as $number) {
1920
-					$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1920
+					$this->addStat('pilots_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1921 1921
 				}
1922 1922
 				$alldata = $Spotter->countAllMilitaryMonths($filter);
1923 1923
 				foreach ($alldata as $number) {
1924
-					$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1924
+					$this->addStat('military_flights_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1925 1925
 				}
1926 1926
 				$alldata = $Spotter->countAllMonthsAircrafts($filter);
1927 1927
 				foreach ($alldata as $number) {
1928
-					$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1928
+					$this->addStat('aircrafts_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1929 1929
 				}
1930 1930
 				$alldata = $Spotter->countAllMonthsRealArrivals($filter);
1931 1931
 				foreach ($alldata as $number) {
1932
-					$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1932
+					$this->addStat('realarrivals_bymonth', $number['date_count'], date('Y-m-d H:i:s', mktime(0, 0, 0, $number['month_name'], 1, $number['year_name'])), '', $filter_name);
1933 1933
 				}
1934 1934
 				echo '...Departure'."\n";
1935
-				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1936
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1935
+				$pall = $Spotter->getLast7DaysAirportsDeparture('', $filter);
1936
+        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('', $filter);
1937 1937
 				foreach ($dall as $value) {
1938 1938
     					$icao = $value['departure_airport_icao'];
1939 1939
     					$ddate = $value['date'];
@@ -1951,11 +1951,11 @@  discard block
 block discarded – undo
1951 1951
     				}
1952 1952
 	    			$alldata = $pall;
1953 1953
 				foreach ($alldata as $number) {
1954
-					$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);
1954
+					$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);
1955 1955
 				}
1956 1956
 				echo '...Arrival'."\n";
1957
-				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
1958
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
1957
+				$pall = $Spotter->getLast7DaysAirportsArrival('', $filter);
1958
+    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('', $filter);
1959 1959
 				foreach ($dall as $value) {
1960 1960
 					$icao = $value['arrival_airport_icao'];
1961 1961
 					$ddate = $value['date'];
@@ -1973,40 +1973,40 @@  discard block
 block discarded – undo
1973 1973
     				}
1974 1974
     				$alldata = $pall;
1975 1975
 				foreach ($alldata as $number) {
1976
-					$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);
1976
+					$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);
1977 1977
 				}
1978 1978
     
1979 1979
 				echo 'Flights data...'."\n";
1980 1980
 				echo '-> countAllDatesLastMonth...'."\n";
1981 1981
 				$alldata = $Spotter->countAllDatesLastMonth($filter);
1982 1982
 				foreach ($alldata as $number) {
1983
-					$this->addStatFlight('month',$number['date_name'],$number['date_count'], '',$filter_name);
1983
+					$this->addStatFlight('month', $number['date_name'], $number['date_count'], '', $filter_name);
1984 1984
 				}
1985 1985
 				echo '-> countAllDates...'."\n";
1986
-				$previousdata = $this->countAllDates('',$filter_name);
1987
-				$alldata = $Common->array_merge_noappend($previousdata,$Spotter->countAllDates($filter));
1986
+				$previousdata = $this->countAllDates('', $filter_name);
1987
+				$alldata = $Common->array_merge_noappend($previousdata, $Spotter->countAllDates($filter));
1988 1988
 				$values = array();
1989 1989
 				foreach ($alldata as $cnt) {
1990 1990
 					$values[] = $cnt['date_count'];
1991 1991
 				}
1992
-				array_multisort($values,SORT_DESC,$alldata);
1993
-				array_splice($alldata,11);
1992
+				array_multisort($values, SORT_DESC, $alldata);
1993
+				array_splice($alldata, 11);
1994 1994
 				foreach ($alldata as $number) {
1995
-					$this->addStatFlight('date',$number['date_name'],$number['date_count'],'',$filter_name);
1995
+					$this->addStatFlight('date', $number['date_name'], $number['date_count'], '', $filter_name);
1996 1996
 				}
1997 1997
 				
1998 1998
 				echo '-> countAllHours...'."\n";
1999
-				$alldata = $Spotter->countAllHours('hour',$filter);
1999
+				$alldata = $Spotter->countAllHours('hour', $filter);
2000 2000
 				foreach ($alldata as $number) {
2001
-					$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],'',$filter_name);
2001
+					$this->addStatFlight('hour', $number['hour_name'], $number['hour_count'], '', $filter_name);
2002 2002
 				}
2003 2003
 				echo 'Insert last stats update date...'."\n";
2004 2004
 				date_default_timezone_set('UTC');
2005
-				$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y-m-d G:i:s'));
2005
+				$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y-m-d G:i:s'));
2006 2006
 				if (isset($filter['DeleteLastYearStats']) && $filter['DeleteLastYearStats'] == true) {
2007
-					if (date('Y',strtotime($last_update_day)) != date('Y')) {
2007
+					if (date('Y', strtotime($last_update_day)) != date('Y')) {
2008 2008
 						$this->deleteOldStats($filter_name);
2009
-						$this->addLastStatsUpdate('last_update_stats_'.$filter_name,date('Y').'-01-01 00:00:00');
2009
+						$this->addLastStatsUpdate('last_update_stats_'.$filter_name, date('Y').'-01-01 00:00:00');
2010 2010
 					}
2011 2011
 				}
2012 2012
 
@@ -2019,16 +2019,16 @@  discard block
 block discarded – undo
2019 2019
 				// SUM all previous month to put as year
2020 2020
 				$previous_year = date('Y');
2021 2021
 				$previous_year--;
2022
-				$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2023
-				$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2024
-				$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2025
-				$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year),$previous_year.'-01-01 00:00:00');
2022
+				$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2023
+				$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2024
+				$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2025
+				$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year), $previous_year.'-01-01 00:00:00');
2026 2026
 				$allairlines = $this->getAllAirlineNames();
2027 2027
 				foreach ($allairlines as $data) {
2028
-					$this->addStat('aircrafts_byyear',$this->getSumStats('aircrafts_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2029
-					$this->addStat('airlines_byyear',$this->getSumStats('airlines_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2030
-					$this->addStat('owner_byyear',$this->getSumStats('owner_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2031
-					$this->addStat('pilot_byyear',$this->getSumStats('pilot_bymonth',$previous_year,$data['airline_icao']),$previous_year.'-01-01 00:00:00',$data['airline_icao']);
2028
+					$this->addStat('aircrafts_byyear', $this->getSumStats('aircrafts_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2029
+					$this->addStat('airlines_byyear', $this->getSumStats('airlines_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2030
+					$this->addStat('owner_byyear', $this->getSumStats('owner_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2031
+					$this->addStat('pilot_byyear', $this->getSumStats('pilot_bymonth', $previous_year, $data['airline_icao']), $previous_year.'-01-01 00:00:00', $data['airline_icao']);
2032 2032
 				}
2033 2033
 				
2034 2034
 				if (isset($globalArchiveYear) && $globalArchiveYear) {
@@ -2037,7 +2037,7 @@  discard block
 block discarded – undo
2037 2037
 						try {
2038 2038
 							$sth = $this->db->prepare($query);
2039 2039
 							$sth->execute();
2040
-						} catch(PDOException $e) {
2040
+						} catch (PDOException $e) {
2041 2041
 							return "error : ".$e->getMessage().' - query : '.$query."\n";
2042 2042
 						}
2043 2043
 					}
@@ -2046,15 +2046,15 @@  discard block
 block discarded – undo
2046 2046
 					try {
2047 2047
 						$sth = $this->db->prepare($query);
2048 2048
 						$sth->execute();
2049
-					} catch(PDOException $e) {
2049
+					} catch (PDOException $e) {
2050 2050
 						return "error : ".$e->getMessage().' - query : '.$query."\n";
2051 2051
 					}
2052 2052
 				}
2053 2053
 				if (isset($globalDeleteLastYearStats) && $globalDeleteLastYearStats) {
2054 2054
 					$last_update = $this->getLastStatsUpdate('last_update_stats');
2055
-					if (date('Y',strtotime($last_update[0]['value'])) != date('Y')) {
2055
+					if (date('Y', strtotime($last_update[0]['value'])) != date('Y')) {
2056 2056
 						$this->deleteOldStats();
2057
-						$this->addLastStatsUpdate('last_update_stats',date('Y').'-01-01 00:00:00');
2057
+						$this->addLastStatsUpdate('last_update_stats', date('Y').'-01-01 00:00:00');
2058 2058
 						$lastyearupdate = true;
2059 2059
 					}
2060 2060
 				}
@@ -2076,7 +2076,7 @@  discard block
 block discarded – undo
2076 2076
 					try {
2077 2077
 						$sth = $this->db->prepare($query);
2078 2078
 						$sth->execute();
2079
-					} catch(PDOException $e) {
2079
+					} catch (PDOException $e) {
2080 2080
 						return "error : ".$e->getMessage();
2081 2081
 					}
2082 2082
 				}
@@ -2090,14 +2090,14 @@  discard block
 block discarded – undo
2090 2090
 				try {
2091 2091
 					$sth = $this->db->prepare($query);
2092 2092
 					$sth->execute();
2093
-				} catch(PDOException $e) {
2093
+				} catch (PDOException $e) {
2094 2094
 					return "error : ".$e->getMessage();
2095 2095
 				}
2096 2096
 			}
2097 2097
 			if (!isset($lastyearupdate)) {
2098 2098
 				echo 'Insert last stats update date...'."\n";
2099 2099
 				date_default_timezone_set('UTC');
2100
-				$this->addLastStatsUpdate('last_update_stats',date('Y-m-d G:i:s'));
2100
+				$this->addLastStatsUpdate('last_update_stats', date('Y-m-d G:i:s'));
2101 2101
 			}
2102 2102
 			if ($globalStatsResetYear) {
2103 2103
 				require_once(dirname(__FILE__).'/../install/class.settings.php');
Please login to merge, or discard this patch.
Braces   +455 added lines, -157 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 	
13 13
 	public function __construct($dbc = null) {
14 14
 		global $globalFilterName;
15
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
15
+		if (isset($globalFilterName)) {
16
+			$this->filter_name = $globalFilterName;
17
+		}
16 18
 		$Connection = new Connection($dbc);
17 19
 		$this->db = $Connection->db();
18 20
         }
@@ -77,7 +79,9 @@  discard block
 block discarded – undo
77 79
                 }
78 80
         }
79 81
 	public function getAllAirlineNames($filter_name = '') {
80
-		if ($filter_name == '') $filter_name = $this->filter_name;
82
+		if ($filter_name == '') {
83
+			$filter_name = $this->filter_name;
84
+		}
81 85
                 $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82 86
                  try {
83 87
                         $sth = $this->db->prepare($query);
@@ -89,7 +93,9 @@  discard block
 block discarded – undo
89 93
                 return $all;
90 94
         }
91 95
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
92
-		if ($filter_name == '') $filter_name = $this->filter_name;
96
+		if ($filter_name == '') {
97
+			$filter_name = $this->filter_name;
98
+		}
93 99
                 $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94 100
                  try {
95 101
                         $sth = $this->db->prepare($query);
@@ -101,7 +107,9 @@  discard block
 block discarded – undo
101 107
                 return $all;
102 108
         }
103 109
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
104
-		if ($filter_name == '') $filter_name = $this->filter_name;
110
+		if ($filter_name == '') {
111
+			$filter_name = $this->filter_name;
112
+		}
105 113
                 $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
106 114
                  try {
107 115
                         $sth = $this->db->prepare($query);
@@ -113,7 +121,9 @@  discard block
 block discarded – undo
113 121
                 return $all;
114 122
         }
115 123
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
116
-		if ($filter_name == '') $filter_name = $this->filter_name;
124
+		if ($filter_name == '') {
125
+			$filter_name = $this->filter_name;
126
+		}
117 127
                 $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
118 128
                  try {
119 129
                         $sth = $this->db->prepare($query);
@@ -126,7 +136,9 @@  discard block
 block discarded – undo
126 136
         }
127 137
 
128 138
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
129
-		if ($filter_name == '') $filter_name = $this->filter_name;
139
+		if ($filter_name == '') {
140
+			$filter_name = $this->filter_name;
141
+		}
130 142
                 $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131 143
                  try {
132 144
                         $sth = $this->db->prepare($query);
@@ -139,7 +151,9 @@  discard block
 block discarded – undo
139 151
         }
140 152
 
141 153
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
142
-		if ($filter_name == '') $filter_name = $this->filter_name;
154
+		if ($filter_name == '') {
155
+			$filter_name = $this->filter_name;
156
+		}
143 157
                 $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144 158
                  try {
145 159
                         $sth = $this->db->prepare($query);
@@ -154,10 +168,15 @@  discard block
 block discarded – undo
154 168
 
155 169
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
156 170
 		global $globalStatsFilters;
157
-		if ($filter_name == '') $filter_name = $this->filter_name;
171
+		if ($filter_name == '') {
172
+			$filter_name = $this->filter_name;
173
+		}
158 174
 		if ($year == '' && $month == '') {
159
-			if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
160
-			else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
175
+			if ($limit) {
176
+				$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
177
+			} else {
178
+				$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
179
+			}
161 180
 			try {
162 181
 				$sth = $this->db->prepare($query);
163 182
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -165,7 +184,9 @@  discard block
 block discarded – undo
165 184
 				echo "error : ".$e->getMessage();
166 185
 			}
167 186
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
168
-		} else $all = array();
187
+		} else {
188
+			$all = array();
189
+		}
169 190
                 if (empty($all)) {
170 191
             	    $filters = array('airlines' => array($stats_airline));
171 192
             	    if ($filter_name != '') {
@@ -178,10 +199,15 @@  discard block
 block discarded – undo
178 199
 	}
179 200
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
180 201
 		global $globalStatsFilters;
181
-		if ($filter_name == '') $filter_name = $this->filter_name;
202
+		if ($filter_name == '') {
203
+			$filter_name = $this->filter_name;
204
+		}
182 205
 		if ($year == '' && $month == '') {
183
-			if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
184
-			else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
206
+			if ($limit) {
207
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
208
+			} else {
209
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC";
210
+			}
185 211
 			try {
186 212
 				$sth = $this->db->prepare($query);
187 213
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -189,7 +215,9 @@  discard block
 block discarded – undo
189 215
 				echo "error : ".$e->getMessage();
190 216
 			}
191 217
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
192
-		} else $all = array();
218
+		} else {
219
+			$all = array();
220
+		}
193 221
                 if (empty($all)) {
194 222
             		$Spotter = new Spotter($this->db);
195 223
             		$filters = array();
@@ -202,10 +230,15 @@  discard block
 block discarded – undo
202 230
 	}
203 231
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
204 232
 		global $globalStatsFilters;
205
-		if ($filter_name == '') $filter_name = $this->filter_name;
233
+		if ($filter_name == '') {
234
+			$filter_name = $this->filter_name;
235
+		}
206 236
 		if ($year == '' && $month == '') {
207
-			if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
208
-			else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
237
+			if ($limit) {
238
+				$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
239
+			} else {
240
+				$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
241
+			}
209 242
 			try {
210 243
 				$sth = $this->db->prepare($query);
211 244
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -213,7 +246,9 @@  discard block
 block discarded – undo
213 246
 				echo "error : ".$e->getMessage();
214 247
 			}
215 248
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
216
-		} else $all = array();
249
+		} else {
250
+			$all = array();
251
+		}
217 252
 		if (empty($all)) {
218 253
 			$filters = array('airlines' => array($stats_airline));
219 254
 			if ($filter_name != '') {
@@ -227,10 +262,15 @@  discard block
 block discarded – undo
227 262
 
228 263
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
229 264
 		global $globalStatsFilters;
230
-		if ($filter_name == '') $filter_name = $this->filter_name;
265
+		if ($filter_name == '') {
266
+			$filter_name = $this->filter_name;
267
+		}
231 268
 		if ($year == '' && $month == '') {
232
-			if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
233
-			else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
269
+			if ($limit) {
270
+				$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
271
+			} else {
272
+				$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC";
273
+			}
234 274
 			try {
235 275
 				$sth = $this->db->prepare($query);
236 276
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -238,7 +278,9 @@  discard block
 block discarded – undo
238 278
 				echo "error : ".$e->getMessage();
239 279
 			}
240 280
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
241
-		} else $all = array();
281
+		} else {
282
+			$all = array();
283
+		}
242 284
                 if (empty($all)) {
243 285
 			$filters = array('airlines' => array($stats_airline));
244 286
 			if ($filter_name != '') {
@@ -251,9 +293,14 @@  discard block
 block discarded – undo
251 293
 	}
252 294
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
253 295
 		global $globalStatsFilters;
254
-		if ($filter_name == '') $filter_name = $this->filter_name;
255
-		if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
256
-		else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
296
+		if ($filter_name == '') {
297
+			$filter_name = $this->filter_name;
298
+		}
299
+		if ($limit) {
300
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
301
+		} else {
302
+			$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC";
303
+		}
257 304
                  try {
258 305
                         $sth = $this->db->prepare($query);
259 306
                         $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -274,10 +321,15 @@  discard block
 block discarded – undo
274 321
 
275 322
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
276 323
 		global $globalStatsFilters;
277
-		if ($filter_name == '') $filter_name = $this->filter_name;
324
+		if ($filter_name == '') {
325
+			$filter_name = $this->filter_name;
326
+		}
278 327
 		if ($year == '' && $month == '') {
279
-			if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
280
-			else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC";
328
+			if ($limit) {
329
+				$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
330
+			} else {
331
+				$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC";
332
+			}
281 333
 			try {
282 334
 				$sth = $this->db->prepare($query);
283 335
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -285,7 +337,9 @@  discard block
 block discarded – undo
285 337
 				echo "error : ".$e->getMessage();
286 338
 			}
287 339
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
288
-		} else $all = array();
340
+		} else {
341
+			$all = array();
342
+		}
289 343
                 if (empty($all)) {
290 344
 	                $Spotter = new Spotter($this->db);
291 345
             		$filters = array();
@@ -299,10 +353,15 @@  discard block
 block discarded – undo
299 353
 	}
300 354
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
301 355
 		global $globalStatsFilters;
302
-		if ($filter_name == '') $filter_name = $this->filter_name;
356
+		if ($filter_name == '') {
357
+			$filter_name = $this->filter_name;
358
+		}
303 359
 		if ($year == '' && $month == '') {
304
-			if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
305
-			else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
360
+			if ($limit) {
361
+				$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
362
+			} else {
363
+				$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
364
+			}
306 365
 			try {
307 366
 				$sth = $this->db->prepare($query);
308 367
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -310,7 +369,9 @@  discard block
 block discarded – undo
310 369
 				echo "error : ".$e->getMessage();
311 370
 			}
312 371
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
313
-		} else $all = array();
372
+		} else {
373
+			$all = array();
374
+		}
314 375
                 if (empty($all)) {
315 376
 			$filters = array('airlines' => array($stats_airline));
316 377
 			if ($filter_name != '') {
@@ -323,10 +384,15 @@  discard block
 block discarded – undo
323 384
 	}
324 385
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
325 386
 		global $globalStatsFilters;
326
-		if ($filter_name == '') $filter_name = $this->filter_name;
387
+		if ($filter_name == '') {
388
+			$filter_name = $this->filter_name;
389
+		}
327 390
 		if ($year == '' && $month == '') {
328
-			if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
329
-			else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
391
+			if ($limit) {
392
+				$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
393
+			} else {
394
+				$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
395
+			}
330 396
 			 try {
331 397
 				$sth = $this->db->prepare($query);
332 398
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -334,7 +400,9 @@  discard block
 block discarded – undo
334 400
 				echo "error : ".$e->getMessage();
335 401
 			}
336 402
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
337
-		} else $all = array();
403
+		} else {
404
+			$all = array();
405
+		}
338 406
 		if (empty($all)) {
339 407
 			$filters = array('airlines' => array($stats_airline));
340 408
 			if ($filter_name != '') {
@@ -347,11 +415,16 @@  discard block
 block discarded – undo
347 415
 	}
348 416
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
349 417
 		$Connection = new Connection();
350
-		if ($filter_name == '') $filter_name = $this->filter_name;
418
+		if ($filter_name == '') {
419
+			$filter_name = $this->filter_name;
420
+		}
351 421
 		if ($Connection->tableExists('countries')) {
352 422
 			if ($year == '' && $month == '') {
353
-				if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
354
-				else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
423
+				if ($limit) {
424
+					$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
425
+				} else {
426
+					$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
427
+				}
355 428
 				 try {
356 429
 					$sth = $this->db->prepare($query);
357 430
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -366,17 +439,24 @@  discard block
 block discarded – undo
366 439
                 }
367 440
                 */
368 441
 				return $all;
369
-			} else return array();
442
+			} else {
443
+				return array();
444
+			}
370 445
 		} else {
371 446
 			return array();
372 447
 		}
373 448
 	}
374 449
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
375 450
 		global $globalStatsFilters;
376
-		if ($filter_name == '') $filter_name = $this->filter_name;
451
+		if ($filter_name == '') {
452
+			$filter_name = $this->filter_name;
453
+		}
377 454
 		if ($year == '' && $month == '') {
378
-			if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
379
-			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
455
+			if ($limit) {
456
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
457
+			} else {
458
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
459
+			}
380 460
 			try {
381 461
 				$sth = $this->db->prepare($query);
382 462
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -384,7 +464,9 @@  discard block
 block discarded – undo
384 464
 				echo "error : ".$e->getMessage();
385 465
 			}
386 466
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
387
-		} else $all = array();
467
+		} else {
468
+			$all = array();
469
+		}
388 470
 		if (empty($all)) {
389 471
 			$filters = array('airlines' => array($stats_airline));
390 472
 			if ($filter_name != '') {
@@ -398,10 +480,15 @@  discard block
 block discarded – undo
398 480
 
399 481
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
400 482
 		global $globalStatsFilters;
401
-		if ($filter_name == '') $filter_name = $this->filter_name;
483
+		if ($filter_name == '') {
484
+			$filter_name = $this->filter_name;
485
+		}
402 486
 		if ($year == '' && $month == '') {
403
-			if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
404
-			else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
487
+			if ($limit) {
488
+				$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
489
+			} else {
490
+				$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
491
+			}
405 492
 			try {
406 493
 				$sth = $this->db->prepare($query);
407 494
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -409,7 +496,9 @@  discard block
 block discarded – undo
409 496
 				echo "error : ".$e->getMessage();
410 497
 			}
411 498
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
412
-		} else $all = array();
499
+		} else {
500
+			$all = array();
501
+		}
413 502
                 if (empty($all)) {
414 503
 			$filters = array('airlines' => array($stats_airline));
415 504
 			if ($filter_name != '') {
@@ -422,10 +511,15 @@  discard block
 block discarded – undo
422 511
 	}
423 512
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
424 513
 		global $globalStatsFilters;
425
-		if ($filter_name == '') $filter_name = $this->filter_name;
514
+		if ($filter_name == '') {
515
+			$filter_name = $this->filter_name;
516
+		}
426 517
 		if ($year == '' && $month == '') {
427
-			if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
428
-			else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
518
+			if ($limit) {
519
+				$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
520
+			} else {
521
+				$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
522
+			}
429 523
 			try {
430 524
 				$sth = $this->db->prepare($query);
431 525
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -433,7 +527,9 @@  discard block
 block discarded – undo
433 527
 				echo "error : ".$e->getMessage();
434 528
 			}
435 529
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
436
-		} else $all = array();
530
+		} else {
531
+			$all = array();
532
+		}
437 533
                 if (empty($all)) {
438 534
 			$filters = array('airlines' => array($stats_airline));
439 535
             		if ($filter_name != '') {
@@ -452,7 +548,9 @@  discard block
 block discarded – undo
452 548
         			$icao = $value['airport_departure_icao'];
453 549
         			if (isset($all[$icao])) {
454 550
         				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
455
-        			} else $all[$icao] = $value;
551
+        			} else {
552
+        				$all[$icao] = $value;
553
+        			}
456 554
         		}
457 555
         		$count = array();
458 556
         		foreach ($all as $key => $row) {
@@ -464,10 +562,15 @@  discard block
 block discarded – undo
464 562
 	}
465 563
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
466 564
 		global $globalStatsFilters;
467
-		if ($filter_name == '') $filter_name = $this->filter_name;
565
+		if ($filter_name == '') {
566
+			$filter_name = $this->filter_name;
567
+		}
468 568
 		if ($year == '' && $month == '') {
469
-			if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
470
-			else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
569
+			if ($limit) {
570
+				$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
571
+			} else {
572
+				$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
573
+			}
471 574
 			try {
472 575
 				$sth = $this->db->prepare($query);
473 576
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -475,7 +578,9 @@  discard block
 block discarded – undo
475 578
 				echo "error : ".$e->getMessage();
476 579
 			}
477 580
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
478
-		} else $all = array();
581
+		} else {
582
+			$all = array();
583
+		}
479 584
 		if (empty($all)) {
480 585
 			$filters = array('airlines' => array($stats_airline));
481 586
 			if ($filter_name != '') {
@@ -494,7 +599,9 @@  discard block
 block discarded – undo
494 599
         			$icao = $value['airport_arrival_icao'];
495 600
         			if (isset($all[$icao])) {
496 601
         				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
497
-        			} else $all[$icao] = $value;
602
+        			} else {
603
+        				$all[$icao] = $value;
604
+        			}
498 605
         		}
499 606
         		$count = array();
500 607
         		foreach ($all as $key => $row) {
@@ -507,13 +614,21 @@  discard block
 block discarded – undo
507 614
 	}
508 615
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
509 616
 		global $globalDBdriver, $globalStatsFilters;
510
-		if ($filter_name == '') $filter_name = $this->filter_name;
617
+		if ($filter_name == '') {
618
+			$filter_name = $this->filter_name;
619
+		}
511 620
 		if ($globalDBdriver == 'mysql') {
512
-			if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
513
-			else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
621
+			if ($limit) {
622
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
623
+			} else {
624
+				$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
625
+			}
514 626
 		} else {
515
-			if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
516
-			else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
627
+			if ($limit) {
628
+				$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
629
+			} else {
630
+				$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";
631
+			}
517 632
 		}
518 633
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
519 634
                  try {
@@ -537,7 +652,9 @@  discard block
 block discarded – undo
537 652
 	
538 653
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
539 654
 		global $globalStatsFilters;
540
-		if ($filter_name == '') $filter_name = $this->filter_name;
655
+		if ($filter_name == '') {
656
+			$filter_name = $this->filter_name;
657
+		}
541 658
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name";
542 659
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
543 660
                  try {
@@ -559,7 +676,9 @@  discard block
 block discarded – undo
559 676
 	}
560 677
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
561 678
 		global $globalDBdriver, $globalStatsFilters;
562
-		if ($filter_name == '') $filter_name = $this->filter_name;
679
+		if ($filter_name == '') {
680
+			$filter_name = $this->filter_name;
681
+		}
563 682
 		if ($globalDBdriver == 'mysql') {
564 683
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name";
565 684
 		} else {
@@ -585,7 +704,9 @@  discard block
 block discarded – undo
585 704
 	}
586 705
 	public function countAllDates($stats_airline = '',$filter_name = '') {
587 706
 		global $globalStatsFilters;
588
-		if ($filter_name == '') $filter_name = $this->filter_name;
707
+		if ($filter_name == '') {
708
+			$filter_name = $this->filter_name;
709
+		}
589 710
 		$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name";
590 711
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
591 712
                  try {
@@ -607,7 +728,9 @@  discard block
 block discarded – undo
607 728
 	}
608 729
 	public function countAllDatesByAirlines($filter_name = '') {
609 730
 		global $globalStatsFilters;
610
-		if ($filter_name == '') $filter_name = $this->filter_name;
731
+		if ($filter_name == '') {
732
+			$filter_name = $this->filter_name;
733
+		}
611 734
 		$query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name";
612 735
 		$query_data = array('filter_name' => $filter_name);
613 736
                  try {
@@ -629,7 +752,9 @@  discard block
 block discarded – undo
629 752
 	}
630 753
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
631 754
 		global $globalStatsFilters;
632
-		if ($filter_name == '') $filter_name = $this->filter_name;
755
+		if ($filter_name == '') {
756
+			$filter_name = $this->filter_name;
757
+		}
633 758
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
634 759
                  try {
635 760
                         $sth = $this->db->prepare($query);
@@ -652,7 +777,9 @@  discard block
 block discarded – undo
652 777
 	}
653 778
 	public function countAllMilitaryMonths($filter_name = '') {
654 779
 		global $globalStatsFilters;
655
-		if ($filter_name == '') $filter_name = $this->filter_name;
780
+		if ($filter_name == '') {
781
+			$filter_name = $this->filter_name;
782
+		}
656 783
 	    	$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
657 784
                  try {
658 785
                         $sth = $this->db->prepare($query);
@@ -673,9 +800,14 @@  discard block
 block discarded – undo
673 800
 	}
674 801
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
675 802
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
676
-		if ($filter_name == '') $filter_name = $this->filter_name;
677
-		if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
678
-		else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
803
+		if ($filter_name == '') {
804
+			$filter_name = $this->filter_name;
805
+		}
806
+		if ($limit) {
807
+			$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
808
+		} else {
809
+			$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
810
+		}
679 811
 		if ($orderby == 'hour') {
680 812
 			/*
681 813
 			if ($globalDBdriver == 'mysql') {
@@ -684,7 +816,9 @@  discard block
 block discarded – undo
684 816
 			*/
685 817
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
686 818
 		}
687
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
819
+		if ($orderby == 'count') {
820
+			$query .= " ORDER BY hour_count DESC";
821
+		}
688 822
                  try {
689 823
                         $sth = $this->db->prepare($query);
690 824
                         $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
@@ -705,8 +839,12 @@  discard block
 block discarded – undo
705 839
 	
706 840
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
707 841
 		global $globalStatsFilters;
708
-		if ($filter_name == '') $filter_name = $this->filter_name;
709
-		if ($year == '') $year = date('Y');
842
+		if ($filter_name == '') {
843
+			$filter_name = $this->filter_name;
844
+		}
845
+		if ($year == '') {
846
+			$year = date('Y');
847
+		}
710 848
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
711 849
 		if (empty($all)) {
712 850
 			$filters = array('airlines' => array($stats_airline));
@@ -720,8 +858,12 @@  discard block
 block discarded – undo
720 858
 	}
721 859
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
722 860
 		global $globalStatsFilters;
723
-		if ($filter_name == '') $filter_name = $this->filter_name;
724
-		if ($year == '') $year = date('Y');
861
+		if ($filter_name == '') {
862
+			$filter_name = $this->filter_name;
863
+		}
864
+		if ($year == '') {
865
+			$year = date('Y');
866
+		}
725 867
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
726 868
 		if (empty($all)) {
727 869
 		        $filters = array();
@@ -735,8 +877,12 @@  discard block
 block discarded – undo
735 877
 	}
736 878
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
737 879
 		global $globalStatsFilters;
738
-		if ($filter_name == '') $filter_name = $this->filter_name;
739
-		if ($year == '') $year = date('Y');
880
+		if ($filter_name == '') {
881
+			$filter_name = $this->filter_name;
882
+		}
883
+		if ($year == '') {
884
+			$year = date('Y');
885
+		}
740 886
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
741 887
 		if (empty($all)) {
742 888
 			$filters = array('airlines' => array($stats_airline));
@@ -750,8 +896,12 @@  discard block
 block discarded – undo
750 896
 	}
751 897
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
752 898
 		global $globalStatsFilters;
753
-		if ($filter_name == '') $filter_name = $this->filter_name;
754
-		if ($year == '') $year = date('Y');
899
+		if ($filter_name == '') {
900
+			$filter_name = $this->filter_name;
901
+		}
902
+		if ($year == '') {
903
+			$year = date('Y');
904
+		}
755 905
 		$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
756 906
 		if (empty($all)) {
757 907
 			$filters = array('airlines' => array($stats_airline));
@@ -765,7 +915,9 @@  discard block
 block discarded – undo
765 915
 	}
766 916
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
767 917
 		global $globalStatsFilters;
768
-		if ($filter_name == '') $filter_name = $this->filter_name;
918
+		if ($filter_name == '') {
919
+			$filter_name = $this->filter_name;
920
+		}
769 921
 		if ($year == '' && $month == '') {
770 922
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
771 923
 			try {
@@ -776,7 +928,9 @@  discard block
 block discarded – undo
776 928
 			}
777 929
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
778 930
 			$all = $result[0]['nb_airline'];
779
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
931
+		} else {
932
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
933
+		}
780 934
 		if (empty($all)) {
781 935
             		$filters = array();
782 936
             		if ($filter_name != '') {
@@ -789,8 +943,12 @@  discard block
 block discarded – undo
789 943
 	}
790 944
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
791 945
 		global $globalStatsFilters;
792
-		if ($filter_name == '') $filter_name = $this->filter_name;
793
-		if ($year == '') $year = date('Y');
946
+		if ($filter_name == '') {
947
+			$filter_name = $this->filter_name;
948
+		}
949
+		if ($year == '') {
950
+			$year = date('Y');
951
+		}
794 952
 		/*
795 953
 		$query = "SELECT COUNT(*) AS nb_owner FROM stats_owner";
796 954
                  try {
@@ -815,8 +973,12 @@  discard block
 block discarded – undo
815 973
 	}
816 974
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
817 975
 		global $globalStatsFilters;
818
-		if ($filter_name == '') $filter_name = $this->filter_name;
819
-		if ($year == '') $year = date('Y');
976
+		if ($filter_name == '') {
977
+			$filter_name = $this->filter_name;
978
+		}
979
+		if ($year == '') {
980
+			$year = date('Y');
981
+		}
820 982
 		$all = $this->getSumStats('pilots_bymonth',$year,$stats_airline,$filter_name,$month);
821 983
 		if (empty($all)) {
822 984
 			$filters = array('airlines' => array($stats_airline));
@@ -830,7 +992,9 @@  discard block
 block discarded – undo
830 992
 	}
831 993
 
832 994
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
833
-		if ($filter_name == '') $filter_name = $this->filter_name;
995
+		if ($filter_name == '') {
996
+			$filter_name = $this->filter_name;
997
+		}
834 998
 		$query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date";
835 999
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
836 1000
                  try {
@@ -843,7 +1007,9 @@  discard block
 block discarded – undo
843 1007
                 return $all;
844 1008
 	}
845 1009
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
846
-		if ($filter_name == '') $filter_name = $this->filter_name;
1010
+		if ($filter_name == '') {
1011
+			$filter_name = $this->filter_name;
1012
+		}
847 1013
                 $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
848 1014
                 $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
849 1015
                  try {
@@ -856,7 +1022,9 @@  discard block
 block discarded – undo
856 1022
                 return $all;
857 1023
         }
858 1024
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
859
-		if ($filter_name == '') $filter_name = $this->filter_name;
1025
+		if ($filter_name == '') {
1026
+			$filter_name = $this->filter_name;
1027
+		}
860 1028
     		global $globalArchiveMonths, $globalDBdriver;
861 1029
     		if ($globalDBdriver == 'mysql') {
862 1030
     			if ($month == '') {
@@ -886,7 +1054,9 @@  discard block
 block discarded – undo
886 1054
         }
887 1055
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
888 1056
     		global $globalArchiveMonths, $globalDBdriver;
889
-		if ($filter_name == '') $filter_name = $this->filter_name;
1057
+		if ($filter_name == '') {
1058
+			$filter_name = $this->filter_name;
1059
+		}
890 1060
     		if ($globalDBdriver == 'mysql') {
891 1061
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
892 1062
 		} else {
@@ -904,7 +1074,9 @@  discard block
 block discarded – undo
904 1074
         }
905 1075
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
906 1076
     		global $globalArchiveMonths, $globalDBdriver;
907
-		if ($filter_name == '') $filter_name = $this->filter_name;
1077
+		if ($filter_name == '') {
1078
+			$filter_name = $this->filter_name;
1079
+		}
908 1080
     		if ($globalDBdriver == 'mysql') {
909 1081
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
910 1082
                 } else {
@@ -921,7 +1093,9 @@  discard block
 block discarded – undo
921 1093
         }
922 1094
 	public function getStatsAirlineTotal($filter_name = '') {
923 1095
     		global $globalArchiveMonths, $globalDBdriver;
924
-		if ($filter_name == '') $filter_name = $this->filter_name;
1096
+		if ($filter_name == '') {
1097
+			$filter_name = $this->filter_name;
1098
+		}
925 1099
     		if ($globalDBdriver == 'mysql') {
926 1100
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
927 1101
                 } else {
@@ -938,7 +1112,9 @@  discard block
 block discarded – undo
938 1112
         }
939 1113
 	public function getStatsOwnerTotal($filter_name = '') {
940 1114
     		global $globalArchiveMonths, $globalDBdriver;
941
-		if ($filter_name == '') $filter_name = $this->filter_name;
1115
+		if ($filter_name == '') {
1116
+			$filter_name = $this->filter_name;
1117
+		}
942 1118
     		if ($globalDBdriver == 'mysql') {
943 1119
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
944 1120
 		} else {
@@ -955,7 +1131,9 @@  discard block
 block discarded – undo
955 1131
         }
956 1132
 	public function getStatsPilotTotal($filter_name = '') {
957 1133
     		global $globalArchiveMonths, $globalDBdriver;
958
-		if ($filter_name == '') $filter_name = $this->filter_name;
1134
+		if ($filter_name == '') {
1135
+			$filter_name = $this->filter_name;
1136
+		}
959 1137
     		if ($globalDBdriver == 'mysql') {
960 1138
             		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
961 1139
             	} else {
@@ -973,7 +1151,9 @@  discard block
 block discarded – undo
973 1151
 
974 1152
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
975 1153
 		global $globalDBdriver;
976
-		if ($filter_name == '') $filter_name = $this->filter_name;
1154
+		if ($filter_name == '') {
1155
+			$filter_name = $this->filter_name;
1156
+		}
977 1157
 		if ($globalDBdriver == 'mysql') {
978 1158
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt";
979 1159
                 } else {
@@ -989,7 +1169,9 @@  discard block
 block discarded – undo
989 1169
         }
990 1170
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
991 1171
 		global $globalDBdriver;
992
-		if ($filter_name == '') $filter_name = $this->filter_name;
1172
+		if ($filter_name == '') {
1173
+			$filter_name = $this->filter_name;
1174
+		}
993 1175
 		if ($globalDBdriver == 'mysql') {
994 1176
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
995 1177
 		} else {
@@ -1375,10 +1557,14 @@  discard block
 block discarded – undo
1375 1557
     		$Connection = new Connection();
1376 1558
     		date_default_timezone_set('UTC');
1377 1559
     		$last_update = $this->getLastStatsUpdate('last_update_stats');
1378
-			if ($globalDebug) echo 'Update stats !'."\n";
1560
+			if ($globalDebug) {
1561
+				echo 'Update stats !'."\n";
1562
+			}
1379 1563
 			if (isset($last_update[0]['value'])) {
1380 1564
 				$last_update_day = $last_update[0]['value'];
1381
-			} else $last_update_day = '2012-12-12 12:12:12';
1565
+			} else {
1566
+				$last_update_day = '2012-12-12 12:12:12';
1567
+			}
1382 1568
 			$reset = false;
1383 1569
 			if ($globalStatsResetYear) {
1384 1570
 				$reset = true;
@@ -1386,42 +1572,60 @@  discard block
 block discarded – undo
1386 1572
 			}
1387 1573
 			$Spotter = new Spotter($this->db);
1388 1574
 
1389
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
1575
+			if ($globalDebug) {
1576
+				echo 'Count all aircraft types...'."\n";
1577
+			}
1390 1578
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
1391 1579
 			foreach ($alldata as $number) {
1392 1580
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
1393 1581
 			}
1394
-			if ($globalDebug) echo 'Count all airlines...'."\n";
1582
+			if ($globalDebug) {
1583
+				echo 'Count all airlines...'."\n";
1584
+			}
1395 1585
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
1396 1586
 			foreach ($alldata as $number) {
1397 1587
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
1398 1588
 			}
1399
-			if ($globalDebug) echo 'Count all registrations...'."\n";
1589
+			if ($globalDebug) {
1590
+				echo 'Count all registrations...'."\n";
1591
+			}
1400 1592
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
1401 1593
 			foreach ($alldata as $number) {
1402 1594
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
1403 1595
 			}
1404
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
1596
+			if ($globalDebug) {
1597
+				echo 'Count all callsigns...'."\n";
1598
+			}
1405 1599
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
1406 1600
 			foreach ($alldata as $number) {
1407 1601
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1408 1602
 			}
1409
-			if ($globalDebug) echo 'Count all owners...'."\n";
1603
+			if ($globalDebug) {
1604
+				echo 'Count all owners...'."\n";
1605
+			}
1410 1606
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
1411 1607
 			foreach ($alldata as $number) {
1412 1608
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
1413 1609
 			}
1414
-			if ($globalDebug) echo 'Count all pilots...'."\n";
1610
+			if ($globalDebug) {
1611
+				echo 'Count all pilots...'."\n";
1612
+			}
1415 1613
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
1416 1614
 			foreach ($alldata as $number) {
1417 1615
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
1418 1616
 			}
1419 1617
 			
1420
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
1618
+			if ($globalDebug) {
1619
+				echo 'Count all departure airports...'."\n";
1620
+			}
1421 1621
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1422
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1622
+			if ($globalDebug) {
1623
+				echo 'Count all detected departure airports...'."\n";
1624
+			}
1423 1625
         		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1424
-			if ($globalDebug) echo 'Order departure airports...'."\n";
1626
+			if ($globalDebug) {
1627
+				echo 'Order departure airports...'."\n";
1628
+			}
1425 1629
 	        	$alldata = array();
1426 1630
 	        	
1427 1631
     			foreach ($pall as $value) {
@@ -1432,7 +1636,9 @@  discard block
 block discarded – undo
1432 1636
     				$icao = $value['airport_departure_icao'];
1433 1637
         			if (isset($alldata[$icao])) {
1434 1638
     					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1435
-        			} else $alldata[$icao] = $value;
1639
+        			} else {
1640
+        				$alldata[$icao] = $value;
1641
+        			}
1436 1642
 			}
1437 1643
     			$count = array();
1438 1644
     			foreach ($alldata as $key => $row) {
@@ -1442,11 +1648,17 @@  discard block
 block discarded – undo
1442 1648
 			foreach ($alldata as $number) {
1443 1649
 				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);
1444 1650
 			}
1445
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1651
+			if ($globalDebug) {
1652
+				echo 'Count all arrival airports...'."\n";
1653
+			}
1446 1654
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1447
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1655
+			if ($globalDebug) {
1656
+				echo 'Count all detected arrival airports...'."\n";
1657
+			}
1448 1658
         		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1449
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
1659
+			if ($globalDebug) {
1660
+				echo 'Order arrival airports...'."\n";
1661
+			}
1450 1662
 	        	$alldata = array();
1451 1663
     			foreach ($pall as $value) {
1452 1664
 	        		$icao = $value['airport_arrival_icao'];
@@ -1456,7 +1668,9 @@  discard block
 block discarded – undo
1456 1668
     				$icao = $value['airport_arrival_icao'];
1457 1669
         			if (isset($alldata[$icao])) {
1458 1670
         				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1459
-	        		} else $alldata[$icao] = $value;
1671
+	        		} else {
1672
+	        			$alldata[$icao] = $value;
1673
+	        		}
1460 1674
     			}
1461 1675
         		$count = array();
1462 1676
         		foreach ($alldata as $key => $row) {
@@ -1467,7 +1681,9 @@  discard block
 block discarded – undo
1467 1681
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
1468 1682
 			}
1469 1683
 			if ($Connection->tableExists('countries')) {
1470
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
1684
+				if ($globalDebug) {
1685
+					echo 'Count all flights by countries...'."\n";
1686
+				}
1471 1687
 				$SpotterArchive = new SpotterArchive();
1472 1688
 				$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
1473 1689
 				foreach ($alldata as $number) {
@@ -1479,46 +1695,66 @@  discard block
 block discarded – undo
1479 1695
 			// Add by month using getstat if month finish...
1480 1696
 
1481 1697
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
1482
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
1698
+			if ($globalDebug) {
1699
+				echo 'Count all flights by months...'."\n";
1700
+			}
1483 1701
 			$Spotter = new Spotter($this->db);
1484 1702
 			$alldata = $Spotter->countAllMonths();
1485 1703
 			$lastyear = false;
1486 1704
 			foreach ($alldata as $number) {
1487
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1705
+				if ($number['year_name'] != date('Y')) {
1706
+					$lastyear = true;
1707
+				}
1488 1708
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1489 1709
 			}
1490
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
1710
+			if ($globalDebug) {
1711
+				echo 'Count all military flights by months...'."\n";
1712
+			}
1491 1713
 			$alldata = $Spotter->countAllMilitaryMonths();
1492 1714
 			foreach ($alldata as $number) {
1493 1715
 				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1494 1716
 			}
1495
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
1717
+			if ($globalDebug) {
1718
+				echo 'Count all owners by months...'."\n";
1719
+			}
1496 1720
 			$alldata = $Spotter->countAllMonthsOwners();
1497 1721
 			foreach ($alldata as $number) {
1498 1722
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1499 1723
 			}
1500
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
1724
+			if ($globalDebug) {
1725
+				echo 'Count all pilots by months...'."\n";
1726
+			}
1501 1727
 			$alldata = $Spotter->countAllMonthsPilots();
1502 1728
 			foreach ($alldata as $number) {
1503 1729
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1504 1730
 			}
1505
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
1731
+			if ($globalDebug) {
1732
+				echo 'Count all airlines by months...'."\n";
1733
+			}
1506 1734
 			$alldata = $Spotter->countAllMonthsAirlines();
1507 1735
 			foreach ($alldata as $number) {
1508 1736
 				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1509 1737
 			}
1510
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
1738
+			if ($globalDebug) {
1739
+				echo 'Count all aircrafts by months...'."\n";
1740
+			}
1511 1741
 			$alldata = $Spotter->countAllMonthsAircrafts();
1512 1742
 			foreach ($alldata as $number) {
1513 1743
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1514 1744
 			}
1515
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
1745
+			if ($globalDebug) {
1746
+				echo 'Count all real arrivals by months...'."\n";
1747
+			}
1516 1748
 			$alldata = $Spotter->countAllMonthsRealArrivals();
1517 1749
 			foreach ($alldata as $number) {
1518 1750
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
1519 1751
 			}
1520
-			if ($globalDebug) echo 'Airports data...'."\n";
1521
-			if ($globalDebug) echo '...Departure'."\n";
1752
+			if ($globalDebug) {
1753
+				echo 'Airports data...'."\n";
1754
+			}
1755
+			if ($globalDebug) {
1756
+				echo '...Departure'."\n";
1757
+			}
1522 1758
 			$this->deleteStatAirport('daily');
1523 1759
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1524 1760
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -1639,44 +1875,62 @@  discard block
 block discarded – undo
1639 1875
 			// Count by airlines
1640 1876
 			echo '--- Stats by airlines ---'."\n";
1641 1877
 			if ($Connection->tableExists('countries')) {
1642
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
1878
+				if ($globalDebug) {
1879
+					echo 'Count all flights by countries by airlines...'."\n";
1880
+				}
1643 1881
 				$SpotterArchive = new SpotterArchive();
1644 1882
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
1645 1883
 				foreach ($alldata as $number) {
1646 1884
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
1647 1885
 				}
1648 1886
 			}
1649
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
1887
+			if ($globalDebug) {
1888
+				echo 'Count all aircraft types by airlines...'."\n";
1889
+			}
1650 1890
 			$Spotter = new Spotter($this->db);
1651 1891
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
1652 1892
 			foreach ($alldata as $number) {
1653 1893
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
1654 1894
 			}
1655
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
1895
+			if ($globalDebug) {
1896
+				echo 'Count all aircraft registrations by airlines...'."\n";
1897
+			}
1656 1898
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
1657 1899
 			foreach ($alldata as $number) {
1658 1900
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
1659 1901
 			}
1660
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
1902
+			if ($globalDebug) {
1903
+				echo 'Count all callsigns by airlines...'."\n";
1904
+			}
1661 1905
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
1662 1906
 			foreach ($alldata as $number) {
1663 1907
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
1664 1908
 			}
1665
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
1909
+			if ($globalDebug) {
1910
+				echo 'Count all owners by airlines...'."\n";
1911
+			}
1666 1912
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
1667 1913
 			foreach ($alldata as $number) {
1668 1914
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
1669 1915
 			}
1670
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
1916
+			if ($globalDebug) {
1917
+				echo 'Count all pilots by airlines...'."\n";
1918
+			}
1671 1919
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
1672 1920
 			foreach ($alldata as $number) {
1673 1921
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
1674 1922
 			}
1675
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1923
+			if ($globalDebug) {
1924
+				echo 'Count all departure airports by airlines...'."\n";
1925
+			}
1676 1926
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1677
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1927
+			if ($globalDebug) {
1928
+				echo 'Count all detected departure airports by airlines...'."\n";
1929
+			}
1678 1930
        			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1679
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1931
+			if ($globalDebug) {
1932
+				echo 'Order detected departure airports by airlines...'."\n";
1933
+			}
1680 1934
 	        	//$alldata = array();
1681 1935
     			foreach ($dall as $value) {
1682 1936
     				$icao = $value['airport_departure_icao'];
@@ -1697,11 +1951,17 @@  discard block
 block discarded – undo
1697 1951
 			foreach ($alldata as $number) {
1698 1952
 				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);
1699 1953
 			}
1700
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1954
+			if ($globalDebug) {
1955
+				echo 'Count all arrival airports by airlines...'."\n";
1956
+			}
1701 1957
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1702
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1958
+			if ($globalDebug) {
1959
+				echo 'Count all detected arrival airports by airlines...'."\n";
1960
+			}
1703 1961
         		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1704
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1962
+			if ($globalDebug) {
1963
+				echo 'Order arrival airports by airlines...'."\n";
1964
+			}
1705 1965
 	        	//$alldata = array();
1706 1966
     			foreach ($dall as $value) {
1707 1967
     				$icao = $value['airport_arrival_icao'];
@@ -1720,37 +1980,53 @@  discard block
 block discarded – undo
1720 1980
     			}
1721 1981
     			$alldata = $pall;
1722 1982
                         foreach ($alldata as $number) {
1723
-				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);
1983
+				if ($number['airline_icao'] != '') {
1984
+					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);
1985
+				}
1986
+			}
1987
+			if ($globalDebug) {
1988
+				echo 'Count all flights by months by airlines...'."\n";
1724 1989
 			}
1725
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
1726 1990
 			$Spotter = new Spotter($this->db);
1727 1991
 			$alldata = $Spotter->countAllMonthsByAirlines();
1728 1992
 			$lastyear = false;
1729 1993
 			foreach ($alldata as $number) {
1730
-				if ($number['year_name'] != date('Y')) $lastyear = true;
1994
+				if ($number['year_name'] != date('Y')) {
1995
+					$lastyear = true;
1996
+				}
1731 1997
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1732 1998
 			}
1733
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
1999
+			if ($globalDebug) {
2000
+				echo 'Count all owners by months by airlines...'."\n";
2001
+			}
1734 2002
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines();
1735 2003
 			foreach ($alldata as $number) {
1736 2004
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1737 2005
 			}
1738
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
2006
+			if ($globalDebug) {
2007
+				echo 'Count all pilots by months by airlines...'."\n";
2008
+			}
1739 2009
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines();
1740 2010
 			foreach ($alldata as $number) {
1741 2011
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1742 2012
 			}
1743
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2013
+			if ($globalDebug) {
2014
+				echo 'Count all aircrafts by months by airlines...'."\n";
2015
+			}
1744 2016
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines();
1745 2017
 			foreach ($alldata as $number) {
1746 2018
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1747 2019
 			}
1748
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2020
+			if ($globalDebug) {
2021
+				echo 'Count all real arrivals by months by airlines...'."\n";
2022
+			}
1749 2023
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines();
1750 2024
 			foreach ($alldata as $number) {
1751 2025
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
1752 2026
 			}
1753
-			if ($globalDebug) echo '...Departure'."\n";
2027
+			if ($globalDebug) {
2028
+				echo '...Departure'."\n";
2029
+			}
1754 2030
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1755 2031
         		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1756 2032
     			foreach ($dall as $value) {
@@ -1773,7 +2049,9 @@  discard block
 block discarded – undo
1773 2049
 			foreach ($alldata as $number) {
1774 2050
 				$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']);
1775 2051
 			}
1776
-			if ($globalDebug) echo '...Arrival'."\n";
2052
+			if ($globalDebug) {
2053
+				echo '...Arrival'."\n";
2054
+			}
1777 2055
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1778 2056
         		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1779 2057
     			foreach ($dall as $value) {
@@ -1797,13 +2075,19 @@  discard block
 block discarded – undo
1797 2075
 				$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']);
1798 2076
 			}
1799 2077
 
1800
-			if ($globalDebug) echo 'Flights data...'."\n";
1801
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
2078
+			if ($globalDebug) {
2079
+				echo 'Flights data...'."\n";
2080
+			}
2081
+			if ($globalDebug) {
2082
+				echo '-> countAllDatesLastMonth...'."\n";
2083
+			}
1802 2084
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines();
1803 2085
 			foreach ($alldata as $number) {
1804 2086
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
1805 2087
 			}
1806
-			if ($globalDebug) echo '-> countAllDates...'."\n";
2088
+			if ($globalDebug) {
2089
+				echo '-> countAllDates...'."\n";
2090
+			}
1807 2091
 			//$previousdata = $this->countAllDatesByAirlines();
1808 2092
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines());
1809 2093
 			$values = array();
@@ -1816,7 +2100,9 @@  discard block
 block discarded – undo
1816 2100
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
1817 2101
 			}
1818 2102
 			
1819
-			if ($globalDebug) echo '-> countAllHours...'."\n";
2103
+			if ($globalDebug) {
2104
+				echo '-> countAllHours...'."\n";
2105
+			}
1820 2106
 			$alldata = $Spotter->countAllHoursByAirlines('hour');
1821 2107
 			foreach ($alldata as $number) {
1822 2108
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
@@ -1824,7 +2110,9 @@  discard block
 block discarded – undo
1824 2110
 			
1825 2111
 
1826 2112
 			// Stats by filters
1827
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
2113
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
2114
+				$globalStatsFilters = array();
2115
+			}
1828 2116
 			foreach ($globalStatsFilters as $name => $filter) {
1829 2117
 				//$filter_name = $filter['name'];
1830 2118
 				$filter_name = $name;
@@ -1832,11 +2120,15 @@  discard block
 block discarded – undo
1832 2120
 				$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
1833 2121
 				if (isset($last_update[0]['value'])) {
1834 2122
 					$last_update_day = $last_update[0]['value'];
1835
-				} else $last_update_day = '2012-12-12 12:12:12';
2123
+				} else {
2124
+					$last_update_day = '2012-12-12 12:12:12';
2125
+				}
1836 2126
 				$reset = false;
1837 2127
 
1838 2128
 				// Count by filter
1839
-				if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
2129
+				if ($globalDebug) {
2130
+					echo '--- Stats for filter '.$filter_name.' ---'."\n";
2131
+				}
1840 2132
 				$Spotter = new Spotter($this->db);
1841 2133
 				$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
1842 2134
 				foreach ($alldata as $number) {
@@ -1873,7 +2165,9 @@  discard block
 block discarded – undo
1873 2165
 	    				$icao = $value['airport_departure_icao'];
1874 2166
         				if (isset($alldata[$icao])) {
1875 2167
     						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1876
-        				} else $alldata[$icao] = $value;
2168
+        				} else {
2169
+        					$alldata[$icao] = $value;
2170
+        				}
1877 2171
 				}
1878 2172
 	    			$count = array();
1879 2173
     				foreach ($alldata as $key => $row) {
@@ -1894,7 +2188,9 @@  discard block
 block discarded – undo
1894 2188
 	    				$icao = $value['airport_arrival_icao'];
1895 2189
         				if (isset($alldata[$icao])) {
1896 2190
         					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1897
-		        		} else $alldata[$icao] = $value;
2191
+		        		} else {
2192
+		        			$alldata[$icao] = $value;
2193
+		        		}
1898 2194
 	    			}
1899 2195
         			$count = array();
1900 2196
         			foreach ($alldata as $key => $row) {
@@ -1908,7 +2204,9 @@  discard block
 block discarded – undo
1908 2204
 				$alldata = $Spotter->countAllMonths($filter);
1909 2205
 				$lastyear = false;
1910 2206
 				foreach ($alldata as $number) {
1911
-					if ($number['year_name'] != date('Y')) $lastyear = true;
2207
+					if ($number['year_name'] != date('Y')) {
2208
+						$lastyear = true;
2209
+					}
1912 2210
 					$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
1913 2211
 				}
1914 2212
 				$alldata = $Spotter->countAllMonthsOwners($filter);
Please login to merge, or discard this patch.