Completed
Push — master ( 83bb91...7edaba )
by Yannick
36:33
created
install/class.update_db.php 3 patches
Doc Comments   +48 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
 		global $globalProxy, $globalForceIPv4;
15 18
 		$fp = fopen($file, 'w');
@@ -34,6 +37,9 @@  discard block
 block discarded – undo
34 37
 		fclose($fp);
35 38
 	}
36 39
 
40
+	/**
41
+	 * @param string $in_file
42
+	 */
37 43
 	public static function gunzip($in_file,$out_file_name = '') {
38 44
 		//echo $in_file.' -> '.$out_file_name."\n";
39 45
 		$buffer_size = 4096; // read 4kb at a time
@@ -55,6 +61,9 @@  discard block
 block discarded – undo
55 61
 		}
56 62
 	}
57 63
 
64
+	/**
65
+	 * @param string $in_file
66
+	 */
58 67
 	public static function unzip($in_file) {
59 68
 		if ($in_file != '' && file_exists($in_file)) {
60 69
 			$path = pathinfo(realpath($in_file), PATHINFO_DIRNAME);
@@ -76,6 +85,9 @@  discard block
 block discarded – undo
76 85
 		}
77 86
 	}
78 87
 	
88
+	/**
89
+	 * @param string $database_file
90
+	 */
79 91
 	public static function retrieve_route_sqlite_to_dest($database_file) {
80 92
 		global $globalDebug, $globalTransaction;
81 93
 		//$query = 'TRUNCATE TABLE routes';
@@ -118,6 +130,10 @@  discard block
 block discarded – undo
118 130
 		}
119 131
                 return '';
120 132
 	}
133
+
134
+	/**
135
+	 * @param string $database_file
136
+	 */
121 137
 	public static function retrieve_route_oneworld($database_file) {
122 138
 		global $globalDebug, $globalTransaction;
123 139
 		//$query = 'TRUNCATE TABLE routes';
@@ -159,6 +175,9 @@  discard block
 block discarded – undo
159 175
                 return '';
160 176
 	}
161 177
 	
178
+	/**
179
+	 * @param string $database_file
180
+	 */
162 181
 	public static function retrieve_route_skyteam($database_file) {
163 182
 		global $globalDebug, $globalTransaction;
164 183
 		//$query = 'TRUNCATE TABLE routes';
@@ -201,6 +220,10 @@  discard block
 block discarded – undo
201 220
 		}
202 221
                 return '';
203 222
 	}
223
+
224
+	/**
225
+	 * @param string $database_file
226
+	 */
204 227
 	public static function retrieve_modes_sqlite_to_dest($database_file) {
205 228
 		global $globalTransaction;
206 229
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -267,6 +290,9 @@  discard block
 block discarded – undo
267 290
 		return '';
268 291
 	}
269 292
 
293
+	/**
294
+	 * @param string $database_file
295
+	 */
270 296
 	public static function retrieve_modes_flarmnet($database_file) {
271 297
 		global $globalTransaction;
272 298
 		$Common = new Common();
@@ -337,6 +363,9 @@  discard block
 block discarded – undo
337 363
 		return '';
338 364
 	}
339 365
 
366
+	/**
367
+	 * @param string $database_file
368
+	 */
340 369
 	public static function retrieve_modes_ogn($database_file) {
341 370
 		global $globalTransaction;
342 371
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -406,6 +435,9 @@  discard block
 block discarded – undo
406 435
 		return '';
407 436
 	}
408 437
 
438
+	/**
439
+	 * @param string $database_file
440
+	 */
409 441
 	public static function retrieve_owner($database_file,$country = 'F') {
410 442
 		global $globalTransaction, $globalMasterSource;
411 443
 		//$query = 'TRUNCATE TABLE aircraft_modes';
@@ -1438,6 +1470,10 @@  discard block
 block discarded – undo
1438 1470
 		return '';
1439 1471
         }
1440 1472
 
1473
+	/**
1474
+	 * @param string $filename
1475
+	 * @param string $tletype
1476
+	 */
1441 1477
 	public static function tle($filename,$tletype) {
1442 1478
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1443 1479
 		global $tmp_dir, $globalTransaction;
@@ -1487,6 +1523,9 @@  discard block
 block discarded – undo
1487 1523
 		return '';
1488 1524
         }
1489 1525
 
1526
+	/**
1527
+	 * @param string $filename
1528
+	 */
1490 1529
 	public static function satellite_ucsdb($filename) {
1491 1530
 		global $tmp_dir, $globalTransaction;
1492 1531
 		
@@ -1535,6 +1574,9 @@  discard block
 block discarded – undo
1535 1574
 		return '';
1536 1575
 	}
1537 1576
 
1577
+	/**
1578
+	 * @param string $filename
1579
+	 */
1538 1580
 	public static function satellite_celestrak($filename) {
1539 1581
 		global $tmp_dir, $globalTransaction;
1540 1582
 		$satcat_sources = array(
@@ -1862,6 +1904,9 @@  discard block
 block discarded – undo
1862 1904
 
1863 1905
 	}
1864 1906
 */
1907
+	/**
1908
+	 * @param string $filename
1909
+	 */
1865 1910
 	public static function waypoints($filename) {
1866 1911
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1867 1912
 		global $tmp_dir, $globalTransaction;
@@ -1930,6 +1975,9 @@  discard block
 block discarded – undo
1930 1975
 		}
1931 1976
 	}
1932 1977
 
1978
+	/**
1979
+	 * @param string $filename
1980
+	 */
1933 1981
 	public static function ivao_airlines($filename) {
1934 1982
 		//require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1935 1983
 		global $tmp_dir, $globalTransaction;
Please login to merge, or discard this patch.
Spacing   +417 added lines, -417 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 		$ch = curl_init();
17 17
 		curl_setopt($ch, CURLOPT_URL, $url);
18 18
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
19
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
19
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
20 20
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
21 21
 			}
22 22
 		}
@@ -34,20 +34,20 @@  discard block
 block discarded – undo
34 34
 		fclose($fp);
35 35
 	}
36 36
 
37
-	public static function gunzip($in_file,$out_file_name = '') {
37
+	public static function gunzip($in_file, $out_file_name = '') {
38 38
 		//echo $in_file.' -> '.$out_file_name."\n";
39 39
 		$buffer_size = 4096; // read 4kb at a time
40 40
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
41 41
 		if ($in_file != '' && file_exists($in_file)) {
42 42
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
43
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
44
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
43
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
44
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
45 45
 			else {
46 46
 				echo 'gzopen not available';
47 47
 				die;
48 48
 			}
49 49
 			$out_file = fopen($out_file_name, 'wb'); 
50
-			while(!gzeof($file)) {
50
+			while (!gzeof($file)) {
51 51
 				fwrite($out_file, gzread($file, $buffer_size));
52 52
 			}  
53 53
 			fclose($out_file);
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		try {
72 72
 			self::$db_sqlite = new PDO('sqlite:'.$database);
73 73
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
74
-		} catch(PDOException $e) {
74
+		} catch (PDOException $e) {
75 75
 			return "error : ".$e->getMessage();
76 76
 		}
77 77
 	}
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			//$Connection = new Connection();
87 87
 			$sth = $Connection->db->prepare($query);
88 88
                         $sth->execute(array(':source' => $database_file));
89
-                } catch(PDOException $e) {
89
+                } catch (PDOException $e) {
90 90
                         return "error : ".$e->getMessage();
91 91
                 }
92 92
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		try {
98 98
                         $sth = update_db::$db_sqlite->prepare($query);
99 99
                         $sth->execute();
100
-                } catch(PDOException $e) {
100
+                } catch (PDOException $e) {
101 101
                         return "error : ".$e->getMessage();
102 102
                 }
103 103
 		//$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)';
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 			if ($globalTransaction) $Connection->db->beginTransaction();
109 109
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
110 110
 				//$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);
111
-				$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);
111
+				$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);
112 112
 				$sth_dest->execute($query_dest_values);
113 113
             		}
114 114
 			if ($globalTransaction) $Connection->db->commit();
115
-		} catch(PDOException $e) {
115
+		} catch (PDOException $e) {
116 116
 			if ($globalTransaction) $Connection->db->rollBack(); 
117 117
 			return "error : ".$e->getMessage();
118 118
 		}
@@ -128,26 +128,26 @@  discard block
 block discarded – undo
128 128
 			//$Connection = new Connection();
129 129
 			$sth = $Connection->db->prepare($query);
130 130
                         $sth->execute(array(':source' => 'oneworld'));
131
-                } catch(PDOException $e) {
131
+                } catch (PDOException $e) {
132 132
                         return "error : ".$e->getMessage();
133 133
                 }
134 134
 
135 135
     		if ($globalDebug) echo " - Add routes to DB -";
136 136
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
137 137
 		$Spotter = new Spotter();
138
-		if ($fh = fopen($database_file,"r")) {
138
+		if ($fh = fopen($database_file, "r")) {
139 139
 			$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)';
140 140
 			$Connection = new Connection();
141 141
 			$sth_dest = $Connection->db->prepare($query_dest);
142 142
 			if ($globalTransaction) $Connection->db->beginTransaction();
143 143
 			while (!feof($fh)) {
144
-				$line = fgetcsv($fh,9999,',');
144
+				$line = fgetcsv($fh, 9999, ',');
145 145
 				if ($line[0] != '') {
146 146
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
147 147
 						try {
148
-							$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');
148
+							$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');
149 149
 							$sth_dest->execute($query_dest_values);
150
-						} catch(PDOException $e) {
150
+						} catch (PDOException $e) {
151 151
 							if ($globalTransaction) $Connection->db->rollBack(); 
152 152
 							return "error : ".$e->getMessage();
153 153
 						}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 			//$Connection = new Connection();
170 170
 			$sth = $Connection->db->prepare($query);
171 171
                         $sth->execute(array(':source' => 'skyteam'));
172
-                } catch(PDOException $e) {
172
+                } catch (PDOException $e) {
173 173
                         return "error : ".$e->getMessage();
174 174
                 }
175 175
 
@@ -177,24 +177,24 @@  discard block
 block discarded – undo
177 177
 
178 178
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
179 179
 		$Spotter = new Spotter();
180
-		if ($fh = fopen($database_file,"r")) {
180
+		if ($fh = fopen($database_file, "r")) {
181 181
 			$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)';
182 182
 			$Connection = new Connection();
183 183
 			$sth_dest = $Connection->db->prepare($query_dest);
184 184
 			try {
185 185
 				if ($globalTransaction) $Connection->db->beginTransaction();
186 186
 				while (!feof($fh)) {
187
-					$line = fgetcsv($fh,9999,',');
187
+					$line = fgetcsv($fh, 9999, ',');
188 188
 					if ($line[0] != '') {
189
-						$datebe = explode('  -  ',$line[2]);
189
+						$datebe = explode('  -  ', $line[2]);
190 190
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
191
-							$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');
191
+							$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');
192 192
 							$sth_dest->execute($query_dest_values);
193 193
 						}
194 194
 					}
195 195
 				}
196 196
 				if ($globalTransaction) $Connection->db->commit();
197
-			} catch(PDOException $e) {
197
+			} catch (PDOException $e) {
198 198
 				if ($globalTransaction) $Connection->db->rollBack(); 
199 199
 				return "error : ".$e->getMessage();
200 200
 			}
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 			$Connection = new Connection();
210 210
 			$sth = $Connection->db->prepare($query);
211 211
                         $sth->execute(array(':source' => $database_file));
212
-                } catch(PDOException $e) {
212
+                } catch (PDOException $e) {
213 213
                         return "error : ".$e->getMessage();
214 214
                 }
215 215
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 			$Connection = new Connection();
218 218
 			$sth = $Connection->db->prepare($query);
219 219
                         $sth->execute(array(':source' => $database_file));
220
-                } catch(PDOException $e) {
220
+                } catch (PDOException $e) {
221 221
                         return "error : ".$e->getMessage();
222 222
                 }
223 223
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		try {
227 227
                         $sth = update_db::$db_sqlite->prepare($query);
228 228
                         $sth->execute();
229
-                } catch(PDOException $e) {
229
+                } catch (PDOException $e) {
230 230
                         return "error : ".$e->getMessage();
231 231
                 }
232 232
 		//$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)';
@@ -243,15 +243,15 @@  discard block
 block discarded – undo
243 243
 			//$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']);
244 244
 				if ($values['UserString4'] == 'M') $type = 'military';
245 245
 				else $type = null;
246
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
246
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
247 247
 				$sth_dest->execute($query_dest_values);
248 248
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
249
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
249
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
250 250
 				    $sth_dest_owner->execute($query_dest_owner_values);
251 251
 				}
252 252
             		}
253 253
 			if ($globalTransaction) $Connection->db->commit();
254
-		} catch(PDOException $e) {
254
+		} catch (PDOException $e) {
255 255
 			return "error : ".$e->getMessage();
256 256
 		}
257 257
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 			$Connection = new Connection();
262 262
 			$sth = $Connection->db->prepare($query);
263 263
                         $sth->execute(array(':source' => $database_file));
264
-                } catch(PDOException $e) {
264
+                } catch (PDOException $e) {
265 265
                         return "error : ".$e->getMessage();
266 266
                 }
267 267
 		return '';
@@ -276,11 +276,11 @@  discard block
 block discarded – undo
276 276
 			$Connection = new Connection();
277 277
 			$sth = $Connection->db->prepare($query);
278 278
                         $sth->execute(array(':source' => $database_file));
279
-                } catch(PDOException $e) {
279
+                } catch (PDOException $e) {
280 280
                         return "error : ".$e->getMessage();
281 281
                 }
282 282
 		
283
-		if ($fh = fopen($database_file,"r")) {
283
+		if ($fh = fopen($database_file, "r")) {
284 284
 			//$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)';
285 285
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
286 286
 		
@@ -290,13 +290,13 @@  discard block
 block discarded – undo
290 290
 				if ($globalTransaction) $Connection->db->beginTransaction();
291 291
             			while (!feof($fh)) {
292 292
             				$values = array();
293
-            				$line = $Common->hex2str(fgets($fh,9999));
293
+            				$line = $Common->hex2str(fgets($fh, 9999));
294 294
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
295
-            				$values['ModeS'] = substr($line,0,6);
296
-            				$values['Registration'] = trim(substr($line,69,6));
297
-            				$aircraft_name = trim(substr($line,48,6));
295
+            				$values['ModeS'] = substr($line, 0, 6);
296
+            				$values['Registration'] = trim(substr($line, 69, 6));
297
+            				$aircraft_name = trim(substr($line, 48, 6));
298 298
             				// Check if we can find ICAO, else set it to GLID
299
-            				$aircraft_name_split = explode(' ',$aircraft_name);
299
+            				$aircraft_name_split = explode(' ', $aircraft_name);
300 300
             				$search_more = '';
301 301
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
302 302
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -308,20 +308,20 @@  discard block
 block discarded – undo
308 308
 	            				if (isset($result['icao']) && $result['icao'] != '') {
309 309
 	            				    $values['ICAOTypeCode'] = $result['icao'];
310 310
 	            				} 
311
-					} catch(PDOException $e) {
311
+					} catch (PDOException $e) {
312 312
 						return "error : ".$e->getMessage();
313 313
 					}
314 314
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
315 315
 					// Add data to db
316 316
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
317 317
 						//$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']);
318
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
318
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
319 319
 						//print_r($query_dest_values);
320 320
 						$sth_dest->execute($query_dest_values);
321 321
 					}
322 322
 				}
323 323
 				if ($globalTransaction) $Connection->db->commit();
324
-			} catch(PDOException $e) {
324
+			} catch (PDOException $e) {
325 325
 				return "error : ".$e->getMessage();
326 326
 			}
327 327
 		}
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 			$Connection = new Connection();
332 332
 			$sth = $Connection->db->prepare($query);
333 333
                         $sth->execute(array(':source' => $database_file));
334
-                } catch(PDOException $e) {
334
+                } catch (PDOException $e) {
335 335
                         return "error : ".$e->getMessage();
336 336
                 }
337 337
 		return '';
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
 			$Connection = new Connection();
346 346
 			$sth = $Connection->db->prepare($query);
347 347
                         $sth->execute(array(':source' => $database_file));
348
-                } catch(PDOException $e) {
348
+                } catch (PDOException $e) {
349 349
                         return "error : ".$e->getMessage();
350 350
                 }
351 351
 		
352
-		if ($fh = fopen($database_file,"r")) {
352
+		if ($fh = fopen($database_file, "r")) {
353 353
 			//$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)';
354 354
 			$query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
355 355
 		
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 			$sth_dest = $Connection->db->prepare($query_dest);
358 358
 			try {
359 359
 				if ($globalTransaction) $Connection->db->beginTransaction();
360
-				$tmp = fgetcsv($fh,9999,',',"'");
360
+				$tmp = fgetcsv($fh, 9999, ',', "'");
361 361
             			while (!feof($fh)) {
362
-            				$line = fgetcsv($fh,9999,',',"'");
362
+            				$line = fgetcsv($fh, 9999, ',', "'");
363 363
             				
364 364
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
365 365
 					//print_r($line);
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
             				$values['ICAOTypeCode'] = '';
369 369
             				$aircraft_name = $line[2];
370 370
             				// Check if we can find ICAO, else set it to GLID
371
-            				$aircraft_name_split = explode(' ',$aircraft_name);
371
+            				$aircraft_name_split = explode(' ', $aircraft_name);
372 372
             				$search_more = '';
373 373
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
374 374
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -377,20 +377,20 @@  discard block
 block discarded – undo
377 377
                                     		$sth_search->execute();
378 378
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379 379
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
380
-					} catch(PDOException $e) {
380
+					} catch (PDOException $e) {
381 381
 						return "error : ".$e->getMessage();
382 382
 					}
383 383
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
384 384
 					// Add data to db
385 385
 					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
386 386
 						//$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']);
387
-						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
387
+						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
388 388
 						//print_r($query_dest_values);
389 389
 						$sth_dest->execute($query_dest_values);
390 390
 					}
391 391
 				}
392 392
 				if ($globalTransaction) $Connection->db->commit();
393
-			} catch(PDOException $e) {
393
+			} catch (PDOException $e) {
394 394
 				return "error : ".$e->getMessage();
395 395
 			}
396 396
 		}
@@ -400,13 +400,13 @@  discard block
 block discarded – undo
400 400
 			$Connection = new Connection();
401 401
 			$sth = $Connection->db->prepare($query);
402 402
                         $sth->execute(array(':source' => $database_file));
403
-                } catch(PDOException $e) {
403
+                } catch (PDOException $e) {
404 404
                         return "error : ".$e->getMessage();
405 405
                 }
406 406
 		return '';
407 407
 	}
408 408
 
409
-	public static function retrieve_owner($database_file,$country = 'F') {
409
+	public static function retrieve_owner($database_file, $country = 'F') {
410 410
 		global $globalTransaction, $globalMasterSource;
411 411
 		//$query = 'TRUNCATE TABLE aircraft_modes';
412 412
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;";
@@ -414,12 +414,12 @@  discard block
 block discarded – undo
414 414
 			$Connection = new Connection();
415 415
 			$sth = $Connection->db->prepare($query);
416 416
                         $sth->execute(array(':source' => $database_file));
417
-                } catch(PDOException $e) {
417
+                } catch (PDOException $e) {
418 418
                         return "error : ".$e->getMessage();
419 419
                 }
420 420
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
421 421
 		$Spotter = new Spotter();
422
-		if ($fh = fopen($database_file,"r")) {
422
+		if ($fh = fopen($database_file, "r")) {
423 423
 			//$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)';
424 424
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
425 425
 		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
@@ -429,9 +429,9 @@  discard block
 block discarded – undo
429 429
 			$sth_modes = $Connection->db->prepare($query_modes);
430 430
 			try {
431 431
 				if ($globalTransaction) $Connection->db->beginTransaction();
432
-				$tmp = fgetcsv($fh,9999,',','"');
432
+				$tmp = fgetcsv($fh, 9999, ',', '"');
433 433
             			while (!feof($fh)) {
434
-            				$line = fgetcsv($fh,9999,',','"');
434
+            				$line = fgetcsv($fh, 9999, ',', '"');
435 435
             				$values = array();
436 436
             				//print_r($line);
437 437
             				if ($country == 'F') {
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
             				    $values['base'] = $line[4];
440 440
             				    $values['owner'] = $line[5];
441 441
             				    if ($line[6] == '') $values['date_first_reg'] = null;
442
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
442
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
443 443
 					    $values['cancel'] = $line[7];
444 444
 					} elseif ($country == 'EI') {
445 445
 					    // TODO : add modeS & reg to aircraft_modes
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
             				    $values['base'] = $line[3];
448 448
             				    $values['owner'] = $line[2];
449 449
             				    if ($line[1] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
450
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
451 451
 					    $values['cancel'] = '';
452 452
 					    $values['modes'] = $line[7];
453 453
 					    $values['icao'] = $line[8];
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
             				    $values['base'] = null;
468 468
             				    $values['owner'] = $line[5];
469 469
             				    if ($line[18] == '') $values['date_first_reg'] = null;
470
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
470
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
471 471
 					    $values['cancel'] = '';
472 472
 					} elseif ($country == 'VH') {
473 473
 					    // TODO : add modeS & reg to aircraft_modes
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
             				    $values['base'] = null;
476 476
             				    $values['owner'] = $line[12];
477 477
             				    if ($line[28] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
478
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
479 479
 
480 480
 					    $values['cancel'] = $line[39];
481 481
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -495,28 +495,28 @@  discard block
 block discarded – undo
495 495
             				    $values['base'] = null;
496 496
             				    $values['owner'] = $line[8];
497 497
             				    if ($line[7] == '') $values['date_first_reg'] = null;
498
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
498
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
499 499
 					    $values['cancel'] = '';
500 500
 					} elseif ($country == 'PP') {
501 501
             				    $values['registration'] = $line[0];
502 502
             				    $values['base'] = null;
503 503
             				    $values['owner'] = $line[4];
504 504
             				    if ($line[6] == '') $values['date_first_reg'] = null;
505
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
505
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
506 506
 					    $values['cancel'] = $line[7];
507 507
 					} elseif ($country == 'E7') {
508 508
             				    $values['registration'] = $line[0];
509 509
             				    $values['base'] = null;
510 510
             				    $values['owner'] = $line[4];
511 511
             				    if ($line[5] == '') $values['date_first_reg'] = null;
512
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
512
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
513 513
 					    $values['cancel'] = '';
514 514
 					} elseif ($country == '8Q') {
515 515
             				    $values['registration'] = $line[0];
516 516
             				    $values['base'] = null;
517 517
             				    $values['owner'] = $line[3];
518 518
             				    if ($line[7] == '') $values['date_first_reg'] = null;
519
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
519
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
520 520
 					    $values['cancel'] = '';
521 521
 					} elseif ($country == 'ZK') {
522 522
             				    $values['registration'] = $line[0];
@@ -530,18 +530,18 @@  discard block
 block discarded – undo
530 530
             				    $values['registration'] = $line[0];
531 531
             				    $values['base'] = null;
532 532
             				    $values['owner'] = $line[6];
533
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
534
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
533
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
534
+					    $values['cancel'] = date("Y-m-d", strtotime($line[8]));
535 535
 					    $values['modes'] = $line[4];
536 536
 					    $values['icao'] = $line[10];
537 537
 					} elseif ($country == 'OY') {
538 538
             				    $values['registration'] = $line[0];
539
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
539
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[4]));
540 540
 					    $values['modes'] = $line[5];
541 541
 					    $values['icao'] = $line[6];
542 542
 					} elseif ($country == 'PH') {
543 543
             				    $values['registration'] = $line[0];
544
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
544
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[3]));
545 545
 					    $values['modes'] = $line[4];
546 546
 					    $values['icao'] = $line[5];
547 547
 					} elseif ($country == 'OM' || $country == 'TF') {
@@ -552,17 +552,17 @@  discard block
 block discarded – undo
552 552
 					    $values['cancel'] = '';
553 553
 					}
554 554
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
555
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
555
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
556 556
 						$sth_dest->execute($query_dest_values);
557 557
 					}
558 558
 					if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') {
559 559
 						$modescountry = $Spotter->countryFromAircraftRegistration($values['registration']);
560
-						$query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file);
560
+						$query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file);
561 561
 						$sth_modes->execute($query_modes_values);
562 562
 					}
563 563
 				}
564 564
 				if ($globalTransaction) $Connection->db->commit();
565
-			} catch(PDOException $e) {
565
+			} catch (PDOException $e) {
566 566
 				return "error : ".$e->getMessage();
567 567
 			}
568 568
 		}
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 		if ($globalTransaction) $Connection->db->beginTransaction();
701 701
   
702 702
 		$i = 0;
703
-		while($row = sparql_fetch_array($result))
703
+		while ($row = sparql_fetch_array($result))
704 704
 		{
705 705
 			if ($i >= 1) {
706 706
 			//print_r($row);
@@ -720,33 +720,33 @@  discard block
 block discarded – undo
720 720
 				$row['image'] = '';
721 721
 				$row['image_thumb'] = '';
722 722
 			} else {
723
-				$image = str_replace(' ','_',$row['image']);
723
+				$image = str_replace(' ', '_', $row['image']);
724 724
 				$digest = md5($image);
725
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
726
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
727
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
728
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
725
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
726
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
727
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
728
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
729 729
 			}
730 730
 			
731
-			$country = explode('-',$row['country']);
731
+			$country = explode('-', $row['country']);
732 732
 			$row['country'] = $country[0];
733 733
 			
734 734
 			$row['type'] = trim($row['type']);
735
-			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'])) {
735
+			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'])) {
736 736
 				$row['type'] = 'military';
737 737
 			} 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') {
738 738
 				$row['type'] = 'small_airport';
739 739
 			}
740 740
 			
741
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
742
-			$query_dest_values = array(':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => round($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']);
741
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
742
+			$query_dest_values = array(':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => round($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']);
743 743
 			//print_r($query_dest_values);
744 744
 			
745 745
 			if ($row['icao'] != '') {
746 746
 				try {
747 747
 					$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
748 748
 					$sth->execute(array(':icao' => $row['icao']));
749
-				} catch(PDOException $e) {
749
+				} catch (PDOException $e) {
750 750
 					return "error : ".$e->getMessage();
751 751
 				}
752 752
 					if ($sth->fetchColumn() > 0) {
@@ -754,15 +754,15 @@  discard block
 block discarded – undo
754 754
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
755 755
 						try {
756 756
 							$sth = $Connection->db->prepare($query);
757
-							$sth->execute(array(':icao' => $row['icao'],':type' => $row['type']));
758
-						} catch(PDOException $e) {
757
+							$sth->execute(array(':icao' => $row['icao'], ':type' => $row['type']));
758
+						} catch (PDOException $e) {
759 759
 							return "error : ".$e->getMessage();
760 760
 						}
761 761
 						echo $row['icao'].' : '.$row['type']."\n";
762 762
 					} else {
763 763
 						try {
764 764
 							$sth_dest->execute($query_dest_values);
765
-						} catch(PDOException $e) {
765
+						} catch (PDOException $e) {
766 766
 							return "error : ".$e->getMessage();
767 767
 						}
768 768
 					}
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 		echo "Download data from ourairports.com...\n";
814 814
 		$delimiter = ',';
815 815
 		$out_file = $tmp_dir.'airports.csv';
816
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
816
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
817 817
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
818 818
 		echo "Add data from ourairports.com...\n";
819 819
 
@@ -824,33 +824,33 @@  discard block
 block discarded – undo
824 824
 			//$Connection->db->beginTransaction();
825 825
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
826 826
 			{
827
-				if(!$header) $header = $row;
827
+				if (!$header) $header = $row;
828 828
 				else {
829 829
 					$data = array();
830 830
 					$data = array_combine($header, $row);
831 831
 					try {
832 832
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE icao = :icao');
833 833
 						$sth->execute(array(':icao' => $data['ident']));
834
-					} catch(PDOException $e) {
834
+					} catch (PDOException $e) {
835 835
 						return "error : ".$e->getMessage();
836 836
 					}
837 837
 					if ($sth->fetchColumn() > 0) {
838 838
 						$query = 'UPDATE airport SET type = :type WHERE icao = :icao';
839 839
 						try {
840 840
 							$sth = $Connection->db->prepare($query);
841
-							$sth->execute(array(':icao' => $data['ident'],':type' => $data['type']));
842
-						} catch(PDOException $e) {
841
+							$sth->execute(array(':icao' => $data['ident'], ':type' => $data['type']));
842
+						} catch (PDOException $e) {
843 843
 							return "error : ".$e->getMessage();
844 844
 						}
845 845
 					} else {
846 846
 						if ($data['gps_code'] == $data['ident']) {
847 847
 						$query = "INSERT INTO airport (name,city,country,iata,icao,latitude,longitude,altitude,type,home_link,wikipedia_link)
848 848
 						    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
849
-						$query_values = array(':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => round($data['elevation_ft']),':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
849
+						$query_values = array(':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => round($data['elevation_ft']), ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
850 850
 						try {
851 851
 							$sth = $Connection->db->prepare($query);
852 852
 							$sth->execute($query_values);
853
-						} catch(PDOException $e) {
853
+						} catch (PDOException $e) {
854 854
 							return "error : ".$e->getMessage();
855 855
 						}
856 856
 						$i++;
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 		
866 866
 		echo "Download data from another free database...\n";
867 867
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
868
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
868
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
869 869
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
870 870
 		update_db::unzip($out_file);
871 871
 		$header = NULL;
@@ -877,15 +877,15 @@  discard block
 block discarded – undo
877 877
 			//$Connection->db->beginTransaction();
878 878
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
879 879
 			{
880
-				if(!$header) $header = $row;
880
+				if (!$header) $header = $row;
881 881
 				else {
882 882
 					$data = $row;
883 883
 
884 884
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
885 885
 					try {
886 886
 						$sth = $Connection->db->prepare($query);
887
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
888
-					} catch(PDOException $e) {
887
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
888
+					} catch (PDOException $e) {
889 889
 						return "error : ".$e->getMessage();
890 890
 					}
891 891
 				}
@@ -899,15 +899,15 @@  discard block
 block discarded – undo
899 899
 		try {
900 900
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE name LIKE '%Air Base%'");
901 901
 			$sth->execute();
902
-		} catch(PDOException $e) {
902
+		} catch (PDOException $e) {
903 903
 			return "error : ".$e->getMessage();
904 904
 		}
905 905
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
906 906
 			$query2 = 'UPDATE airport SET type = :type WHERE icao = :icao';
907 907
 			try {
908 908
 				$sth2 = $Connection->db->prepare($query2);
909
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
910
-			} catch(PDOException $e) {
909
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
910
+			} catch (PDOException $e) {
911 911
 				return "error : ".$e->getMessage();
912 912
 			}
913 913
 		}
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 			$Connection = new Connection();
929 929
 			$sth = $Connection->db->prepare($query);
930 930
                         $sth->execute(array(':source' => 'translation.csv'));
931
-                } catch(PDOException $e) {
931
+                } catch (PDOException $e) {
932 932
                         return "error : ".$e->getMessage();
933 933
                 }
934 934
 
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
946 946
 			{
947 947
 				$i++;
948
-				if($i > 12) {
948
+				if ($i > 12) {
949 949
 					$data = $row;
950 950
 					$operator = $data[2];
951 951
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
                                                 //echo substr($operator, 0, 2)."\n";;
954 954
                                                 if (count($airline_array) > 0) {
955 955
 							//print_r($airline_array);
956
-							$operator = $airline_array[0]['icao'].substr($operator,2);
956
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
957 957
                                                 }
958 958
                                         }
959 959
 					
@@ -961,14 +961,14 @@  discard block
 block discarded – undo
961 961
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
962 962
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
963 963
                                                 if (count($airline_array) > 0) {
964
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
964
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
965 965
                                             	}
966 966
                                         }
967 967
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
968 968
 					try {
969 969
 						$sth = $Connection->db->prepare($query);
970
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
971
-					} catch(PDOException $e) {
970
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
971
+					} catch (PDOException $e) {
972 972
 						return "error : ".$e->getMessage();
973 973
 					}
974 974
 				}
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
 			$Connection = new Connection();
987 987
 			$sth = $Connection->db->prepare($query);
988 988
 			$sth->execute(array(':source' => 'website_fam'));
989
-		} catch(PDOException $e) {
989
+		} catch (PDOException $e) {
990 990
 			return "error : ".$e->getMessage();
991 991
 		}
992 992
 		//update_db::unzip($out_file);
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
1005 1005
 					try {
1006 1006
 						$sth = $Connection->db->prepare($query);
1007
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
1008
-					} catch(PDOException $e) {
1007
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
1008
+					} catch (PDOException $e) {
1009 1009
 						return "error : ".$e->getMessage();
1010 1010
 					}
1011 1011
 				}
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
 			$Connection = new Connection();
1029 1029
 			$sth = $Connection->db->prepare($query);
1030 1030
                         $sth->execute(array(':source' => 'website_faa'));
1031
-                } catch(PDOException $e) {
1031
+                } catch (PDOException $e) {
1032 1032
                         return "error : ".$e->getMessage();
1033 1033
                 }
1034 1034
 
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 			$Connection = new Connection();
1038 1038
 			$sth = $Connection->db->prepare($query);
1039 1039
                         $sth->execute(array(':source' => 'website_faa'));
1040
-                } catch(PDOException $e) {
1040
+                } catch (PDOException $e) {
1041 1041
                         return "error : ".$e->getMessage();
1042 1042
                 }
1043 1043
 
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';
1055 1055
 					try {
1056 1056
 						$sths = $Connection->db->prepare($query_search);
1057
-						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa'));
1058
-					} catch(PDOException $e) {
1057
+						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa'));
1058
+					} catch (PDOException $e) {
1059 1059
 						return "error s : ".$e->getMessage();
1060 1060
 					}
1061 1061
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
@@ -1068,8 +1068,8 @@  discard block
 block discarded – undo
1068 1068
 							//}
1069 1069
 						try {
1070 1070
 							$sthi = $Connection->db->prepare($queryi);
1071
-							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode']));
1072
-						} catch(PDOException $e) {
1071
+							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode']));
1072
+						} catch (PDOException $e) {
1073 1073
 							return "error u : ".$e->getMessage();
1074 1074
 						}
1075 1075
 					} else {
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
 						try {
1078 1078
 							$sthsm = $Connection->db->prepare($query_search_mfr);
1079 1079
 							$sthsm->execute(array(':mfr' => $data[2]));
1080
-						} catch(PDOException $e) {
1080
+						} catch (PDOException $e) {
1081 1081
 							return "error mfr : ".$e->getMessage();
1082 1082
 						}
1083 1083
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
@@ -1087,8 +1087,8 @@  discard block
 block discarded – undo
1087 1087
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1088 1088
 							try {
1089 1089
 								$sthf = $Connection->db->prepare($queryf);
1090
-								$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'));
1091
-							} catch(PDOException $e) {
1090
+								$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'));
1091
+							} catch (PDOException $e) {
1092 1092
 								return "error f : ".$e->getMessage();
1093 1093
 							}
1094 1094
 						}
@@ -1098,13 +1098,13 @@  discard block
 block discarded – undo
1098 1098
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1099 1099
 						try {
1100 1100
 							$sth = $Connection->db->prepare($query);
1101
-							$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'));
1102
-						} catch(PDOException $e) {
1101
+							$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'));
1102
+						} catch (PDOException $e) {
1103 1103
 							return "error i : ".$e->getMessage();
1104 1104
 						}
1105 1105
 					}
1106 1106
 				}
1107
-				if ($i % 90 == 0) {
1107
+				if ($i%90 == 0) {
1108 1108
 					if ($globalTransaction) $Connection->db->commit();
1109 1109
 					if ($globalTransaction) $Connection->db->beginTransaction();
1110 1110
 				}
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 			$Connection = new Connection();
1124 1124
 			$sth = $Connection->db->prepare($query);
1125 1125
 			$sth->execute(array(':source' => 'website_fam'));
1126
-		} catch(PDOException $e) {
1126
+		} catch (PDOException $e) {
1127 1127
 			return "error : ".$e->getMessage();
1128 1128
 		}
1129 1129
 		$delimiter = "\t";
@@ -1139,8 +1139,8 @@  discard block
 block discarded – undo
1139 1139
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1140 1140
 					try {
1141 1141
 						$sth = $Connection->db->prepare($query);
1142
-						$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'));
1143
-					} catch(PDOException $e) {
1142
+						$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'));
1143
+					} catch (PDOException $e) {
1144 1144
 						return "error : ".$e->getMessage();
1145 1145
 					}
1146 1146
 				}
@@ -1172,7 +1172,7 @@  discard block
 block discarded – undo
1172 1172
 		try {
1173 1173
 			$sth = $Connection->db->prepare($query);
1174 1174
 			$sth->execute();
1175
-		} catch(PDOException $e) {
1175
+		} catch (PDOException $e) {
1176 1176
 			return "error : ".$e->getMessage();
1177 1177
 		}
1178 1178
 		$delimiter = "\t";
@@ -1187,8 +1187,8 @@  discard block
 block discarded – undo
1187 1187
 					$query = 'INSERT INTO airlines (airline_id,name,alias,iata,icao,callsign,country,active,type,home_link,wikipedia_link,alliance,ban_eu) VALUES (0,:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)';
1188 1188
 					try {
1189 1189
 						$sth = $Connection->db->prepare($query);
1190
-						$sth->execute(array(':name' => $data[0],':alias' => $data[1],':iata' => $data[2],':icao' => $data[3], ':callsign' => $data[4],':country' => $data[5],':active' => $data[6],':type' => $data[7],':home' => $data[8],':wikipedia_link' => $data[9],':alliance' => $data[10],':ban_eu' => $data[11]));
1191
-					} catch(PDOException $e) {
1190
+						$sth->execute(array(':name' => $data[0], ':alias' => $data[1], ':iata' => $data[2], ':icao' => $data[3], ':callsign' => $data[4], ':country' => $data[5], ':active' => $data[6], ':type' => $data[7], ':home' => $data[8], ':wikipedia_link' => $data[9], ':alliance' => $data[10], ':ban_eu' => $data[11]));
1191
+					} catch (PDOException $e) {
1192 1192
 						return "error : ".$e->getMessage();
1193 1193
 					}
1194 1194
 				}
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
 			$Connection = new Connection();
1217 1217
 			$sth = $Connection->db->prepare($query);
1218 1218
                         $sth->execute(array(':source' => 'website_fam'));
1219
-                } catch(PDOException $e) {
1219
+                } catch (PDOException $e) {
1220 1220
                         return "error : ".$e->getMessage();
1221 1221
                 }
1222 1222
 
@@ -1232,8 +1232,8 @@  discard block
 block discarded – undo
1232 1232
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1233 1233
 					try {
1234 1234
 						$sth = $Connection->db->prepare($query);
1235
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1236
-					} catch(PDOException $e) {
1235
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1236
+					} catch (PDOException $e) {
1237 1237
 						//print_r($data);
1238 1238
 						return "error : ".$e->getMessage();
1239 1239
 					}
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
 			$Connection = new Connection();
1254 1254
 			$sth = $Connection->db->prepare($query);
1255 1255
 			$sth->execute(array(':source' => 'website_fam'));
1256
-		} catch(PDOException $e) {
1256
+		} catch (PDOException $e) {
1257 1257
 			return "error : ".$e->getMessage();
1258 1258
 		}
1259 1259
 		$delimiter = "\t";
@@ -1269,13 +1269,13 @@  discard block
 block discarded – undo
1269 1269
 					$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)';
1270 1270
 					try {
1271 1271
 						$sth = $Connection->db->prepare($query);
1272
-						$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'));
1273
-					} catch(PDOException $e) {
1274
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1272
+						$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'));
1273
+					} catch (PDOException $e) {
1274
+						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',', $data);
1275 1275
 						die();
1276 1276
 					}
1277 1277
 				}
1278
-				if ($globalTransaction && $i % 2000 == 0) {
1278
+				if ($globalTransaction && $i%2000 == 0) {
1279 1279
 					$Connection->db->commit();
1280 1280
 					if ($globalDebug) echo '.';
1281 1281
 					$Connection->db->beginTransaction();
@@ -1295,7 +1295,7 @@  discard block
 block discarded – undo
1295 1295
 			$Connection = new Connection();
1296 1296
 			$sth = $Connection->db->prepare($query);
1297 1297
 			$sth->execute(array(':source' => 'website_fam'));
1298
-		} catch(PDOException $e) {
1298
+		} catch (PDOException $e) {
1299 1299
 			return "error : ".$e->getMessage();
1300 1300
 		}
1301 1301
 		$Connection = new Connection();
@@ -1308,12 +1308,12 @@  discard block
 block discarded – undo
1308 1308
 				$query = 'INSERT INTO aircraft_block (callSign,Source) VALUES (:callSign,:source)';
1309 1309
 				try {
1310 1310
 					$sth = $Connection->db->prepare($query);
1311
-					$sth->execute(array(':callSign' => trim($data),':source' => 'website_fam'));
1312
-				} catch(PDOException $e) {
1311
+					$sth->execute(array(':callSign' => trim($data), ':source' => 'website_fam'));
1312
+				} catch (PDOException $e) {
1313 1313
 					if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".$data;
1314 1314
 					die();
1315 1315
 				}
1316
-				if ($globalTransaction && $i % 2000 == 0) {
1316
+				if ($globalTransaction && $i%2000 == 0) {
1317 1317
 					$Connection->db->commit();
1318 1318
 					if ($globalDebug) echo '.';
1319 1319
 					$Connection->db->beginTransaction();
@@ -1333,7 +1333,7 @@  discard block
 block discarded – undo
1333 1333
 			$Connection = new Connection();
1334 1334
 			$sth = $Connection->db->prepare($query);
1335 1335
                         $sth->execute();
1336
-                } catch(PDOException $e) {
1336
+                } catch (PDOException $e) {
1337 1337
                         return "error : ".$e->getMessage();
1338 1338
                 }
1339 1339
 
@@ -1354,8 +1354,8 @@  discard block
 block discarded – undo
1354 1354
 					$query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)';
1355 1355
 					try {
1356 1356
 						$sth = $Connection->db->prepare($query);
1357
-						$sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10]));
1358
-					} catch(PDOException $e) {
1357
+						$sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10]));
1358
+					} catch (PDOException $e) {
1359 1359
 						return "error : ".$e->getMessage();
1360 1360
 					}
1361 1361
 				}
@@ -1374,7 +1374,7 @@  discard block
 block discarded – undo
1374 1374
 			$Connection = new Connection();
1375 1375
 			$sth = $Connection->db->prepare($query);
1376 1376
 			$sth->execute();
1377
-		} catch(PDOException $e) {
1377
+		} catch (PDOException $e) {
1378 1378
 			return "error : ".$e->getMessage();
1379 1379
 		}
1380 1380
 		$delimiter = "\t";
@@ -1391,8 +1391,8 @@  discard block
 block discarded – undo
1391 1391
 					    VALUES (:name, :name_alternate, :country_un, :country_owner, :owner, :users, :purpose, :purpose_detailed, :orbit, :type, :longitude_geo, :perigee, :apogee, :eccentricity, :inclination, :period, :launch_mass, :dry_mass, :power, :launch_date, :lifetime, :contractor, :country_contractor, :launch_site, :launch_vehicule, :cospar, :norad, :comments, :source_orbital, :sources)';
1392 1392
 					try {
1393 1393
 						$sth = $Connection->db->prepare($query);
1394
-						$sth->execute(array(':name' => $data[0], ':name_alternate' => $data[1], ':country_un' => $data[2], ':country_owner' => $data[3], ':owner' => $data[4], ':users' => $data[5], ':purpose' => $data[6], ':purpose_detailed' => $data[7], ':orbit' => $data[8], ':type' => $data[9], ':longitude_geo' => $data[10], ':perigee' => !empty($data[11]) ? $data[11] : NULL, ':apogee' => !empty($data[12]) ? $data[12] : NULL, ':eccentricity' => $data[13], ':inclination' => $data[14], ':period' => !empty($data[15]) ? $data[15] : NULL, ':launch_mass' => !empty($data[16]) ? $data[16] : NULL, ':dry_mass' => !empty($data[17]) ? $data[17] : NULL, ':power' => !empty($data[18]) ? $data[18] : NULL, ':launch_date' => $data[19], ':lifetime' => $data[20], ':contractor' => $data[21],':country_contractor' => $data[22], ':launch_site' => $data[23], ':launch_vehicule' => $data[24], ':cospar' => $data[25], ':norad' => $data[26], ':comments' => $data[27], ':source_orbital' => $data[28], ':sources' => $data[29]));
1395
-					} catch(PDOException $e) {
1394
+						$sth->execute(array(':name' => $data[0], ':name_alternate' => $data[1], ':country_un' => $data[2], ':country_owner' => $data[3], ':owner' => $data[4], ':users' => $data[5], ':purpose' => $data[6], ':purpose_detailed' => $data[7], ':orbit' => $data[8], ':type' => $data[9], ':longitude_geo' => $data[10], ':perigee' => !empty($data[11]) ? $data[11] : NULL, ':apogee' => !empty($data[12]) ? $data[12] : NULL, ':eccentricity' => $data[13], ':inclination' => $data[14], ':period' => !empty($data[15]) ? $data[15] : NULL, ':launch_mass' => !empty($data[16]) ? $data[16] : NULL, ':dry_mass' => !empty($data[17]) ? $data[17] : NULL, ':power' => !empty($data[18]) ? $data[18] : NULL, ':launch_date' => $data[19], ':lifetime' => $data[20], ':contractor' => $data[21], ':country_contractor' => $data[22], ':launch_site' => $data[23], ':launch_vehicule' => $data[24], ':cospar' => $data[25], ':norad' => $data[26], ':comments' => $data[27], ':source_orbital' => $data[28], ':sources' => $data[29]));
1395
+					} catch (PDOException $e) {
1396 1396
 						return "error : ".$e->getMessage();
1397 1397
 					}
1398 1398
 				}
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
 			$Connection = new Connection();
1412 1412
 			$sth = $Connection->db->prepare($query);
1413 1413
 			$sth->execute();
1414
-		} catch(PDOException $e) {
1414
+		} catch (PDOException $e) {
1415 1415
 			return "error : ".$e->getMessage();
1416 1416
 		}
1417 1417
 
@@ -1427,7 +1427,7 @@  discard block
 block discarded – undo
1427 1427
 					try {
1428 1428
 						$sth = $Connection->db->prepare($query);
1429 1429
 						$sth->execute(array(':icao' => $icao));
1430
-					} catch(PDOException $e) {
1430
+					} catch (PDOException $e) {
1431 1431
 						return "error : ".$e->getMessage();
1432 1432
 					}
1433 1433
 				}
@@ -1438,7 +1438,7 @@  discard block
 block discarded – undo
1438 1438
 		return '';
1439 1439
         }
1440 1440
 
1441
-	public static function tle($filename,$tletype) {
1441
+	public static function tle($filename, $tletype) {
1442 1442
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1443 1443
 		global $tmp_dir, $globalTransaction;
1444 1444
 		//$Spotter = new Spotter();
@@ -1448,7 +1448,7 @@  discard block
 block discarded – undo
1448 1448
 			$Connection = new Connection();
1449 1449
 			$sth = $Connection->db->prepare($query);
1450 1450
                         $sth->execute(array(':source' => $filename));
1451
-                } catch(PDOException $e) {
1451
+                } catch (PDOException $e) {
1452 1452
                         return "error : ".$e->getMessage();
1453 1453
                 }
1454 1454
 		
@@ -1473,8 +1473,8 @@  discard block
 block discarded – undo
1473 1473
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1474 1474
 					try {
1475 1475
 						$sth = $Connection->db->prepare($query);
1476
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1477
-					} catch(PDOException $e) {
1476
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1477
+					} catch (PDOException $e) {
1478 1478
 						return "error : ".$e->getMessage();
1479 1479
 					}
1480 1480
 
@@ -1495,7 +1495,7 @@  discard block
 block discarded – undo
1495 1495
 			$Connection = new Connection();
1496 1496
 			$sth = $Connection->db->prepare($query);
1497 1497
 			$sth->execute(array(':source' => $filename));
1498
-		} catch(PDOException $e) {
1498
+		} catch (PDOException $e) {
1499 1499
 			return "error : ".$e->getMessage();
1500 1500
 		}
1501 1501
 		
@@ -1506,13 +1506,13 @@  discard block
 block discarded – undo
1506 1506
 			$i = 0;
1507 1507
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1508 1508
 			//$Connection->db->beginTransaction();
1509
-			while (($data = fgetcsv($handle, 1000,"\t")) !== FALSE)
1509
+			while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE)
1510 1510
 			{
1511 1511
 				if ($i > 0 && $data[0] != '') {
1512 1512
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1513
-					$period = str_replace(',','',$data[14]);
1514
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1515
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1513
+					$period = str_replace(',', '', $data[14]);
1514
+					if (!empty($period) && strpos($period, 'days')) $period = str_replace(' days', '', $period)*24*60;
1515
+					if ($data[18] != '') $launch_date = date('Y-m-d', strtotime($data[18]));
1516 1516
 					else $launch_date = NULL;
1517 1517
 					$data = array_map(function($value) {
1518 1518
 						return trim($value) === '' ? null : $value;
@@ -1522,8 +1522,8 @@  discard block
 block discarded – undo
1522 1522
 					    VALUES (:name, :name_alternate, :country_un, :country_owner, :owner, :users, :purpose, :purpose_detailed, :orbit, :type, :longitude_geo, :perigee, :apogee, :eccentricity, :inclination, :period, :launch_mass, :dry_mass, :power, :launch_date, :lifetime, :contractor, :country_contractor, :launch_site, :launch_vehicule, :cospar, :norad, :comments, :source_orbital, :sources)';
1523 1523
 					try {
1524 1524
 						$sth = $Connection->db->prepare($query);
1525
-						$sth->execute(array(':name' => $data[0], ':name_alternate' => '', ':country_un' => $data[1], ':country_owner' => $data[2], ':owner' => $data[3], ':users' => $data[4], ':purpose' => $data[5], ':purpose_detailed' => $data[6], ':orbit' => $data[7], ':type' => $data[8], ':longitude_geo' => $data[9], ':perigee' => !empty($data[10]) ? str_replace(',','',$data[10]) : NULL, ':apogee' => !empty($data[11]) ? str_replace(',','',$data[11]) : NULL, ':eccentricity' => $data[12], ':inclination' => $data[13], ':period' => !empty($period) ? $period : NULL, ':launch_mass' => !empty($data[15]) ? str_replace(array('+',','),'',$data[15]) : NULL, ':dry_mass' => !empty($data[16]) ? str_replace(array(',','-1900',' (BOL)',' (EOL)'),'',$data[16]) : NULL, ':power' => !empty($data[17]) ? str_replace(array(',',' (BOL)',' (EOL)'),'',$data[17]) : NULL, ':launch_date' => $launch_date, ':lifetime' => $data[19], ':contractor' => $data[20],':country_contractor' => $data[21], ':launch_site' => $data[22], ':launch_vehicule' => $data[23], ':cospar' => $data[24], ':norad' => $data[25], ':comments' => $data[26], ':source_orbital' => $data[27], ':sources' => $sources));
1526
-					} catch(PDOException $e) {
1525
+						$sth->execute(array(':name' => $data[0], ':name_alternate' => '', ':country_un' => $data[1], ':country_owner' => $data[2], ':owner' => $data[3], ':users' => $data[4], ':purpose' => $data[5], ':purpose_detailed' => $data[6], ':orbit' => $data[7], ':type' => $data[8], ':longitude_geo' => $data[9], ':perigee' => !empty($data[10]) ? str_replace(',', '', $data[10]) : NULL, ':apogee' => !empty($data[11]) ? str_replace(',', '', $data[11]) : NULL, ':eccentricity' => $data[12], ':inclination' => $data[13], ':period' => !empty($period) ? $period : NULL, ':launch_mass' => !empty($data[15]) ? str_replace(array('+', ','), '', $data[15]) : NULL, ':dry_mass' => !empty($data[16]) ? str_replace(array(',', '-1900', ' (BOL)', ' (EOL)'), '', $data[16]) : NULL, ':power' => !empty($data[17]) ? str_replace(array(',', ' (BOL)', ' (EOL)'), '', $data[17]) : NULL, ':launch_date' => $launch_date, ':lifetime' => $data[19], ':contractor' => $data[20], ':country_contractor' => $data[21], ':launch_site' => $data[22], ':launch_vehicule' => $data[23], ':cospar' => $data[24], ':norad' => $data[25], ':comments' => $data[26], ':source_orbital' => $data[27], ':sources' => $sources));
1526
+					} catch (PDOException $e) {
1527 1527
 						return "error : ".$e->getMessage();
1528 1528
 					}
1529 1529
 				}
@@ -1563,7 +1563,7 @@  discard block
 block discarded – undo
1563 1563
 			'EGYP' => array('country' => 'Egypt', 'owner' => ''),
1564 1564
 			'ESA' => array('country' => 'Multinational', 'owner' => 'European Space Agency'),
1565 1565
 			'ESRO' => array('country' => 'Multinational', 'owner' => 'European Space Research Organization'),
1566
-			'EST' => array('country' => 'Estonia','owner' => ''),
1566
+			'EST' => array('country' => 'Estonia', 'owner' => ''),
1567 1567
 			'EUME' => array('country' => 'Multinational', 'owner' => 'EUMETSAT (European Organization for the Exploitation of Meteorological Satellites)'),
1568 1568
 			'EUTE' => array('country' => 'Multinational', 'owner' => 'European Telecommunications Satellite Consortium (EUTELSAT)'),
1569 1569
 			'FGER' => array('country' => 'France/Germany', 'owner' => ''),
@@ -1687,10 +1687,10 @@  discard block
 block discarded – undo
1687 1687
 			{
1688 1688
 				if ($data != '') {
1689 1689
 				$result = array();
1690
-				$result['cospar'] = trim(substr($data,0,11));
1691
-				$result['norad'] = trim(substr($data,13,6));
1692
-				$result['operational'] = trim(substr($data,21,1));
1693
-				$result['name'] = trim(substr($data,23,24));
1690
+				$result['cospar'] = trim(substr($data, 0, 11));
1691
+				$result['norad'] = trim(substr($data, 13, 6));
1692
+				$result['operational'] = trim(substr($data, 21, 1));
1693
+				$result['name'] = trim(substr($data, 23, 24));
1694 1694
 				/*
1695 1695
 				    * R/B(1) = Rocket body, first stage
1696 1696
 				    * R/B(2) = Rocket body, second stage
@@ -1702,29 +1702,29 @@  discard block
 block discarded – undo
1702 1702
 				    * An ampersand (&) indicates two or more objects are attached
1703 1703
 				*/
1704 1704
 				
1705
-				$owner_code = trim(substr($data,49,5));
1705
+				$owner_code = trim(substr($data, 49, 5));
1706 1706
 				
1707 1707
 				if (!isset($satcat_sources[$owner_code])) {
1708 1708
 					echo $data;
1709 1709
 					echo 'owner_code: '.$owner_code."\n";
1710 1710
 				}
1711
-				if (!isset($satcat_launch_site[trim(substr($data,68,5))])) {
1712
-					echo 'launch_site_code: '.trim(substr($data,68,5))."\n";
1711
+				if (!isset($satcat_launch_site[trim(substr($data, 68, 5))])) {
1712
+					echo 'launch_site_code: '.trim(substr($data, 68, 5))."\n";
1713 1713
 				}
1714 1714
 				
1715
-				if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data,68,5))])) {
1715
+				if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data, 68, 5))])) {
1716 1716
 					$result['country_owner'] = $satcat_sources[$owner_code]['country'];
1717 1717
 					$result['owner'] = $satcat_sources[$owner_code]['owner'];
1718
-					$result['launch_date'] = trim(substr($data,56,10));
1719
-					$launch_site_code = trim(substr($data,68,5));
1718
+					$result['launch_date'] = trim(substr($data, 56, 10));
1719
+					$launch_site_code = trim(substr($data, 68, 5));
1720 1720
 					$result['launch_site'] = $satcat_launch_site[$launch_site_code];
1721
-					$result['lifetime'] = trim(substr($data,75,10));
1722
-					$result['period'] = trim(substr($data,87,7));
1723
-					$result['inclination'] = trim(substr($data,96,5));
1724
-					$result['apogee'] = trim(substr($data,103,6));
1725
-					$result['perigee'] = trim(substr($data,111,6));
1721
+					$result['lifetime'] = trim(substr($data, 75, 10));
1722
+					$result['period'] = trim(substr($data, 87, 7));
1723
+					$result['inclination'] = trim(substr($data, 96, 5));
1724
+					$result['apogee'] = trim(substr($data, 103, 6));
1725
+					$result['perigee'] = trim(substr($data, 111, 6));
1726 1726
 					//$result['radarcross'] = trim(substr($data,119,8));
1727
-					$result['status'] = trim(substr($data,129,3));
1727
+					$result['status'] = trim(substr($data, 129, 3));
1728 1728
 					//print_r($result);
1729 1729
 					$result = array_map(function($value) {
1730 1730
 						return trim($value) === '' ? null : $value;
@@ -1737,7 +1737,7 @@  discard block
 block discarded – undo
1737 1737
 							$sth = $Connection->db->prepare($query);
1738 1738
 							$sth->execute(array(':cospar' => $result['cospar']));
1739 1739
 							$exist = $sth->fetchAll(PDO::FETCH_ASSOC);
1740
-						} catch(PDOException $e) {
1740
+						} catch (PDOException $e) {
1741 1741
 							return "error : ".$e->getMessage();
1742 1742
 						}
1743 1743
 						if (empty($exist)) {
@@ -1749,10 +1749,10 @@  discard block
 block discarded – undo
1749 1749
 								    ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1750 1750
 								    ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1751 1751
 								    ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1752
-								    ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1752
+								    ':contractor' => '', ':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1753 1753
 								    )
1754 1754
 								);
1755
-							} catch(PDOException $e) {
1755
+							} catch (PDOException $e) {
1756 1756
 								return "error : ".$e->getMessage();
1757 1757
 							}
1758 1758
 						} elseif ($exist[0]['name'] != $result['name'] && $exist[0]['name_alternate'] != $result['name']) {
@@ -1760,8 +1760,8 @@  discard block
 block discarded – undo
1760 1760
 							try {
1761 1761
 								$Connection = new Connection();
1762 1762
 								$sth = $Connection->db->prepare($query);
1763
-								$sth->execute(array(':name_alternate' => $result['name'],':cospar' => $result['cospar']));
1764
-							} catch(PDOException $e) {
1763
+								$sth->execute(array(':name_alternate' => $result['name'], ':cospar' => $result['cospar']));
1764
+							} catch (PDOException $e) {
1765 1765
 								return "error : ".$e->getMessage();
1766 1766
 							}
1767 1767
 						}
@@ -1880,13 +1880,13 @@  discard block
 block discarded – undo
1880 1880
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1881 1881
 			{
1882 1882
 				$i++;
1883
-				if($i > 3 && count($row) > 2) {
1883
+				if ($i > 3 && count($row) > 2) {
1884 1884
 					$data = array_values(array_filter($row));
1885 1885
 					$cntdata = count($data);
1886 1886
 					if ($cntdata > 10) {
1887 1887
 						$value = $data[9];
1888 1888
 						
1889
-						for ($i =10;$i < $cntdata;$i++) {
1889
+						for ($i = 10; $i < $cntdata; $i++) {
1890 1890
 							$value .= ' '.$data[$i];
1891 1891
 						}
1892 1892
 						$data[9] = $value;
@@ -1896,8 +1896,8 @@  discard block
 block discarded – undo
1896 1896
 						$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)';
1897 1897
 						try {
1898 1898
 							$sth = $Connection->db->prepare($query);
1899
-							$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]));
1900
-						} catch(PDOException $e) {
1899
+							$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]));
1900
+						} catch (PDOException $e) {
1901 1901
 							return "error : ".$e->getMessage();
1902 1902
 						}
1903 1903
 					}
@@ -1914,16 +1914,16 @@  discard block
 block discarded – undo
1914 1914
 		require_once(dirname(__FILE__).'/../require/class.Source.php');
1915 1915
 		$delimiter = ',';
1916 1916
 		$Common = new Common();
1917
-		$Common->download('http://firms.modaps.eosdis.nasa.gov/active_fire/viirs/text/VNP14IMGTDL_NRT_Global_24h.csv',$tmp_dir.'fires.csv');
1917
+		$Common->download('http://firms.modaps.eosdis.nasa.gov/active_fire/viirs/text/VNP14IMGTDL_NRT_Global_24h.csv', $tmp_dir.'fires.csv');
1918 1918
 		$Connection = new Connection();
1919 1919
 		$Source = new Source();
1920 1920
 		$Source->deleteLocationByType('fires');
1921 1921
 		$i = 0;
1922
-		if (($handle = fopen($tmp_dir.'fires.csv','r')) !== false) {
1923
-			while (($row = fgetcsv($handle,1000)) !== false) {
1922
+		if (($handle = fopen($tmp_dir.'fires.csv', 'r')) !== false) {
1923
+			while (($row = fgetcsv($handle, 1000)) !== false) {
1924 1924
 				if ($i > 0 && $row[0] != '' && $row[8] != 'low') {
1925
-					$description = array('bright_t14' => $row[2],'scan' => $row[3],'track' => $row[4],'sat' => $row[7],'confidence' => $row[8],'version' => $row[9],'bright_t15' => $row[10],'frp' => $row[11],'daynight' => $row[12]);
1926
-					$Source->addLocation('',$row[0],$row[1],null,'','','fires','fire.png','fires',0,0,$row[5].' '.substr($row[6],0,2).':'.substr($row[6],2,2),json_encode($description));
1925
+					$description = array('bright_t14' => $row[2], 'scan' => $row[3], 'track' => $row[4], 'sat' => $row[7], 'confidence' => $row[8], 'version' => $row[9], 'bright_t15' => $row[10], 'frp' => $row[11], 'daynight' => $row[12]);
1926
+					$Source->addLocation('', $row[0], $row[1], null, '', '', 'fires', 'fire.png', 'fires', 0, 0, $row[5].' '.substr($row[6], 0, 2).':'.substr($row[6], 2, 2), json_encode($description));
1927 1927
 				}
1928 1928
 				$i++;
1929 1929
 			}
@@ -1939,7 +1939,7 @@  discard block
 block discarded – undo
1939 1939
 			$Connection = new Connection();
1940 1940
 			$sth = $Connection->db->prepare($query);
1941 1941
 			$sth->execute();
1942
-		} catch(PDOException $e) {
1942
+		} catch (PDOException $e) {
1943 1943
 			return "error : ".$e->getMessage();
1944 1944
 		}
1945 1945
 		$header = NULL;
@@ -1950,12 +1950,12 @@  discard block
 block discarded – undo
1950 1950
 			if ($globalTransaction) $Connection->db->beginTransaction();
1951 1951
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1952 1952
 			{
1953
-				if(count($row) > 1) {
1953
+				if (count($row) > 1) {
1954 1954
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1955 1955
 					try {
1956 1956
 						$sth = $Connection->db->prepare($query);
1957
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1958
-					} catch(PDOException $e) {
1957
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1958
+					} catch (PDOException $e) {
1959 1959
 						return "error : ".$e->getMessage();
1960 1960
 					}
1961 1961
 				}
@@ -1975,21 +1975,21 @@  discard block
 block discarded – undo
1975 1975
 			try {
1976 1976
 				$sth = $Connection->db->prepare($query);
1977 1977
                     		$sth->execute();
1978
-	                } catch(PDOException $e) {
1978
+	                } catch (PDOException $e) {
1979 1979
 				return "error : ".$e->getMessage();
1980 1980
 	                }
1981 1981
 	        }
1982 1982
 
1983 1983
 
1984
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1984
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1985 1985
 		else {
1986
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1986
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1987 1987
 			$query = "CREATE EXTENSION postgis";
1988
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1988
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1989 1989
 			try {
1990 1990
 				$sth = $Connection->db->prepare($query);
1991 1991
 				$sth->execute();
1992
-			} catch(PDOException $e) {
1992
+			} catch (PDOException $e) {
1993 1993
 				return "error : ".$e->getMessage();
1994 1994
 			}
1995 1995
 		}
@@ -2002,13 +2002,13 @@  discard block
 block discarded – undo
2002 2002
 		include_once('class.create_db.php');
2003 2003
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
2004 2004
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
2005
-		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5');
2005
+		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5', $tmp_dir.'notam.txt.gz.md5');
2006 2006
 		$error = '';
2007 2007
 		if (file_exists($tmp_dir.'notam.txt.gz.md5')) {
2008
-			$notam_md5_file = explode(' ',file_get_contents($tmp_dir.'notam.txt.gz.md5'));
2008
+			$notam_md5_file = explode(' ', file_get_contents($tmp_dir.'notam.txt.gz.md5'));
2009 2009
 			$notam_md5 = $notam_md5_file[0];
2010 2010
 			if (!update_db::check_notam_version($notam_md5)) {
2011
-				update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
2011
+				update_db::download('http://data.flightairmap.com/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
2012 2012
 				if (file_exists($tmp_dir.'notam.txt.gz')) {
2013 2013
 					if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) {
2014 2014
 						if ($globalDebug) echo "Gunzip...";
@@ -2044,14 +2044,14 @@  discard block
 block discarded – undo
2044 2044
 			try {
2045 2045
 				$sth = $Connection->db->prepare($query);
2046 2046
             	        	$sth->execute();
2047
-	                } catch(PDOException $e) {
2047
+	                } catch (PDOException $e) {
2048 2048
     	                	echo "error : ".$e->getMessage();
2049 2049
 	                }
2050 2050
 		}
2051 2051
 		if ($globalDBdriver == 'mysql') {
2052
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
2052
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
2053 2053
 		} else {
2054
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
2054
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
2055 2055
 		}
2056 2056
 		$error = create_db::import_file($tmp_dir.'countries.sql');
2057 2057
 		return $error;
@@ -2064,7 +2064,7 @@  discard block
 block discarded – undo
2064 2064
 //		update_db::unzip($tmp_dir.'AptNav.zip');
2065 2065
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
2066 2066
 //		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');
2067
-		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');
2067
+		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');
2068 2068
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
2069 2069
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
2070 2070
 		return $error;
@@ -2085,7 +2085,7 @@  discard block
 block discarded – undo
2085 2085
 				update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
2086 2086
 				if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2087 2087
 				if (is_writable(dirname(__FILE__).'/../images/airlines')) {
2088
-					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2088
+					if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2089 2089
 				} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2090 2090
 			} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2091 2091
 		} else $error = "ZIP module not loaded but required for IVAO.";
@@ -2099,7 +2099,7 @@  discard block
 block discarded – undo
2099 2099
 		global $tmp_dir, $globalDebug;
2100 2100
 		$error = '';
2101 2101
 		if ($globalDebug) echo "Routes : Download...";
2102
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
2102
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
2103 2103
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
2104 2104
 			if ($globalDebug) echo "Gunzip...";
2105 2105
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -2115,7 +2115,7 @@  discard block
 block discarded – undo
2115 2115
 		global $tmp_dir, $globalDebug;
2116 2116
 		$error = '';
2117 2117
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
2118
-		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
2118
+		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
2119 2119
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
2120 2120
 			if ($globalDebug) echo "Gunzip...";
2121 2121
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -2131,7 +2131,7 @@  discard block
 block discarded – undo
2131 2131
 		global $tmp_dir, $globalDebug;
2132 2132
 		$error = '';
2133 2133
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
2134
-		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
2134
+		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
2135 2135
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
2136 2136
 			if ($globalDebug) echo "Gunzip...";
2137 2137
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -2159,7 +2159,7 @@  discard block
 block discarded – undo
2159 2159
 */
2160 2160
 		if ($globalDebug) echo "Modes : Download...";
2161 2161
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2162
-		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2162
+		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
2163 2163
 
2164 2164
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2165 2165
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -2179,7 +2179,7 @@  discard block
 block discarded – undo
2179 2179
 	public static function update_ModeS_faa() {
2180 2180
 		global $tmp_dir, $globalDebug;
2181 2181
 		if ($globalDebug) echo "Modes FAA: Download...";
2182
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2182
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
2183 2183
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2184 2184
 			if ($globalDebug) echo "Unzip...";
2185 2185
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -2195,7 +2195,7 @@  discard block
 block discarded – undo
2195 2195
 	public static function update_ModeS_flarm() {
2196 2196
 		global $tmp_dir, $globalDebug;
2197 2197
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
2198
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2198
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
2199 2199
 		if (file_exists($tmp_dir.'data.fln')) {
2200 2200
 			if ($globalDebug) echo "Add to DB...";
2201 2201
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -2209,7 +2209,7 @@  discard block
 block discarded – undo
2209 2209
 	public static function update_ModeS_ogn() {
2210 2210
 		global $tmp_dir, $globalDebug;
2211 2211
 		if ($globalDebug) echo "Modes OGN: Download...";
2212
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2212
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
2213 2213
 		if (file_exists($tmp_dir.'ogn.csv')) {
2214 2214
 			if ($globalDebug) echo "Add to DB...";
2215 2215
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -2224,201 +2224,201 @@  discard block
 block discarded – undo
2224 2224
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2225 2225
 		
2226 2226
 		if ($globalDebug) echo "Owner France: Download...";
2227
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2227
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
2228 2228
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2229 2229
 			if ($globalDebug) echo "Add to DB...";
2230
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2230
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
2231 2231
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2232 2232
 		if ($error != '') {
2233 2233
 			return $error;
2234 2234
 		} elseif ($globalDebug) echo "Done\n";
2235 2235
 		
2236 2236
 		if ($globalDebug) echo "Owner Ireland: Download...";
2237
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2237
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
2238 2238
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2239 2239
 			if ($globalDebug) echo "Add to DB...";
2240
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2240
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
2241 2241
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2242 2242
 		if ($error != '') {
2243 2243
 			return $error;
2244 2244
 		} elseif ($globalDebug) echo "Done\n";
2245 2245
 		if ($globalDebug) echo "Owner Switzerland: Download...";
2246
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2246
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
2247 2247
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2248 2248
 			if ($globalDebug) echo "Add to DB...";
2249
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2249
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
2250 2250
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2251 2251
 		if ($error != '') {
2252 2252
 			return $error;
2253 2253
 		} elseif ($globalDebug) echo "Done\n";
2254 2254
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
2255
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2255
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
2256 2256
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2257 2257
 			if ($globalDebug) echo "Add to DB...";
2258
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2258
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
2259 2259
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2260 2260
 		if ($error != '') {
2261 2261
 			return $error;
2262 2262
 		} elseif ($globalDebug) echo "Done\n";
2263 2263
 		if ($globalDebug) echo "Owner Australia: Download...";
2264
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2264
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
2265 2265
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2266 2266
 			if ($globalDebug) echo "Add to DB...";
2267
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2267
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
2268 2268
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2269 2269
 		if ($error != '') {
2270 2270
 			return $error;
2271 2271
 		} elseif ($globalDebug) echo "Done\n";
2272 2272
 		if ($globalDebug) echo "Owner Austria: Download...";
2273
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2273
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
2274 2274
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2275 2275
 			if ($globalDebug) echo "Add to DB...";
2276
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2276
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
2277 2277
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2278 2278
 		if ($error != '') {
2279 2279
 			return $error;
2280 2280
 		} elseif ($globalDebug) echo "Done\n";
2281 2281
 		if ($globalDebug) echo "Owner Chile: Download...";
2282
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2282
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
2283 2283
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2284 2284
 			if ($globalDebug) echo "Add to DB...";
2285
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2285
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
2286 2286
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2287 2287
 		if ($error != '') {
2288 2288
 			return $error;
2289 2289
 		} elseif ($globalDebug) echo "Done\n";
2290 2290
 		if ($globalDebug) echo "Owner Colombia: Download...";
2291
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2291
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
2292 2292
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2293 2293
 			if ($globalDebug) echo "Add to DB...";
2294
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2294
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
2295 2295
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2296 2296
 		if ($error != '') {
2297 2297
 			return $error;
2298 2298
 		} elseif ($globalDebug) echo "Done\n";
2299 2299
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2300
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2300
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
2301 2301
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2302 2302
 			if ($globalDebug) echo "Add to DB...";
2303
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2303
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
2304 2304
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2305 2305
 		if ($error != '') {
2306 2306
 			return $error;
2307 2307
 		} elseif ($globalDebug) echo "Done\n";
2308 2308
 		if ($globalDebug) echo "Owner Brazil: Download...";
2309
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2309
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
2310 2310
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2311 2311
 			if ($globalDebug) echo "Add to DB...";
2312
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2312
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
2313 2313
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2314 2314
 		if ($error != '') {
2315 2315
 			return $error;
2316 2316
 		} elseif ($globalDebug) echo "Done\n";
2317 2317
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2318
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2318
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
2319 2319
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2320 2320
 			if ($globalDebug) echo "Add to DB...";
2321
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2321
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
2322 2322
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2323 2323
 		if ($error != '') {
2324 2324
 			return $error;
2325 2325
 		} elseif ($globalDebug) echo "Done\n";
2326 2326
 		if ($globalDebug) echo "Owner Croatia: Download...";
2327
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2327
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
2328 2328
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2329 2329
 			if ($globalDebug) echo "Add to DB...";
2330
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2330
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
2331 2331
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2332 2332
 		if ($error != '') {
2333 2333
 			return $error;
2334 2334
 		} elseif ($globalDebug) echo "Done\n";
2335 2335
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
2336
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2336
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
2337 2337
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2338 2338
 			if ($globalDebug) echo "Add to DB...";
2339
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2339
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
2340 2340
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2341 2341
 		if ($error != '') {
2342 2342
 			return $error;
2343 2343
 		} elseif ($globalDebug) echo "Done\n";
2344 2344
 		if ($globalDebug) echo "Owner Maldives: Download...";
2345
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2345
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
2346 2346
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2347 2347
 			if ($globalDebug) echo "Add to DB...";
2348
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2348
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
2349 2349
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2350 2350
 		if ($error != '') {
2351 2351
 			return $error;
2352 2352
 		} elseif ($globalDebug) echo "Done\n";
2353 2353
 		if ($globalDebug) echo "Owner New Zealand: Download...";
2354
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2354
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
2355 2355
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2356 2356
 			if ($globalDebug) echo "Add to DB...";
2357
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2357
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
2358 2358
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2359 2359
 		if ($error != '') {
2360 2360
 			return $error;
2361 2361
 		} elseif ($globalDebug) echo "Done\n";
2362 2362
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2363
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2363
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
2364 2364
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2365 2365
 			if ($globalDebug) echo "Add to DB...";
2366
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2366
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
2367 2367
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2368 2368
 		if ($error != '') {
2369 2369
 			return $error;
2370 2370
 		} elseif ($globalDebug) echo "Done\n";
2371 2371
 		if ($globalDebug) echo "Owner Slovakia: Download...";
2372
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2372
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
2373 2373
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2374 2374
 			if ($globalDebug) echo "Add to DB...";
2375
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2375
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
2376 2376
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2377 2377
 		if ($error != '') {
2378 2378
 			return $error;
2379 2379
 		} elseif ($globalDebug) echo "Done\n";
2380 2380
 		if ($globalDebug) echo "Owner Ecuador: Download...";
2381
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2381
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
2382 2382
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2383 2383
 			if ($globalDebug) echo "Add to DB...";
2384
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2384
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
2385 2385
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2386 2386
 		if ($error != '') {
2387 2387
 			return $error;
2388 2388
 		} elseif ($globalDebug) echo "Done\n";
2389 2389
 		if ($globalDebug) echo "Owner Iceland: Download...";
2390
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2390
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
2391 2391
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2392 2392
 			if ($globalDebug) echo "Add to DB...";
2393
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2393
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
2394 2394
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2395 2395
 		if ($error != '') {
2396 2396
 			return $error;
2397 2397
 		} elseif ($globalDebug) echo "Done\n";
2398 2398
 		if ($globalDebug) echo "Owner Isle of Man: Download...";
2399
-		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2399
+		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv');
2400 2400
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2401 2401
 			if ($globalDebug) echo "Add to DB...";
2402
-			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2402
+			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M');
2403 2403
 		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2404 2404
 		if ($error != '') {
2405 2405
 			return $error;
2406 2406
 		} elseif ($globalDebug) echo "Done\n";
2407 2407
 		if ($globalMasterSource) {
2408 2408
 			if ($globalDebug) echo "ModeS Netherlands: Download...";
2409
-			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2409
+			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv');
2410 2410
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2411 2411
 				if ($globalDebug) echo "Add to DB...";
2412
-				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2412
+				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH');
2413 2413
 			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2414 2414
 			if ($error != '') {
2415 2415
 				return $error;
2416 2416
 			} elseif ($globalDebug) echo "Done\n";
2417 2417
 			if ($globalDebug) echo "ModeS Denmark: Download...";
2418
-			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2418
+			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv');
2419 2419
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2420 2420
 				if ($globalDebug) echo "Add to DB...";
2421
-				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2421
+				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY');
2422 2422
 			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2423 2423
 			if ($error != '') {
2424 2424
 				return $error;
@@ -2431,7 +2431,7 @@  discard block
 block discarded – undo
2431 2431
 		global $tmp_dir, $globalDebug;
2432 2432
 		$error = '';
2433 2433
 		if ($globalDebug) echo "Translation : Download...";
2434
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2434
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
2435 2435
 		if (file_exists($tmp_dir.'translation.zip')) {
2436 2436
 			if ($globalDebug) echo "Unzip...";
2437 2437
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -2448,10 +2448,10 @@  discard block
 block discarded – undo
2448 2448
 		global $tmp_dir, $globalDebug;
2449 2449
 		$error = '';
2450 2450
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2451
-		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2452
-		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5');
2451
+		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
2452
+		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5', $tmp_dir.'translation.tsv.gz.md5');
2453 2453
 		if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) {
2454
-			$translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2454
+			$translation_md5_file = explode(' ', file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2455 2455
 			$translation_md5 = $translation_md5_file[0];
2456 2456
 			if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) {
2457 2457
 				if ($globalDebug) echo "Gunzip...";
@@ -2469,10 +2469,10 @@  discard block
 block discarded – undo
2469 2469
 		global $tmp_dir, $globalDebug;
2470 2470
 		$error = '';
2471 2471
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2472
-		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2473
-		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5');
2472
+		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
2473
+		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5', $tmp_dir.'modes.tsv.gz.md5');
2474 2474
 		if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) {
2475
-			$modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2475
+			$modes_md5_file = explode(' ', file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2476 2476
 			$modes_md5 = $modes_md5_file[0];
2477 2477
 			if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) {
2478 2478
 				if ($globalDebug) echo "Gunzip...";
@@ -2491,12 +2491,12 @@  discard block
 block discarded – undo
2491 2491
 		global $tmp_dir, $globalDebug;
2492 2492
 		$error = '';
2493 2493
 		if ($globalDebug) echo "Airlines from FlightAirMap website : Download...";
2494
-		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5');
2494
+		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5', $tmp_dir.'airlines.tsv.gz.md5');
2495 2495
 		if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) {
2496
-			$airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
2496
+			$airlines_md5_file = explode(' ', file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
2497 2497
 			$airlines_md5 = $airlines_md5_file[0];
2498 2498
 			if (!update_db::check_airlines_version($airlines_md5)) {
2499
-				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz');
2499
+				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz', $tmp_dir.'airlines.tsv.gz');
2500 2500
 				if (file_exists($tmp_dir.'airlines.tsv.gz')) {
2501 2501
 					if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) {
2502 2502
 						if ($globalDebug) echo "Gunzip...";
@@ -2521,14 +2521,14 @@  discard block
 block discarded – undo
2521 2521
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2522 2522
 		$error = '';
2523 2523
 		if ($globalOwner === TRUE) {
2524
-			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2525
-			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5');
2524
+			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
2525
+			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5');
2526 2526
 		} else {
2527
-			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2528
-			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5');
2527
+			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
2528
+			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5');
2529 2529
 		}
2530 2530
 		if (file_exists($tmp_dir.'owners.tsv.gz') && file_exists($tmp_dir.'owners.tsv.gz.md5')) {
2531
-			$owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2531
+			$owners_md5_file = explode(' ', file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2532 2532
 			$owners_md5 = $owners_md5_file[0];
2533 2533
 			if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) {
2534 2534
 				if ($globalDebug) echo "Gunzip...";
@@ -2545,10 +2545,10 @@  discard block
 block discarded – undo
2545 2545
 	public static function update_routes_fam() {
2546 2546
 		global $tmp_dir, $globalDebug;
2547 2547
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2548
-		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2549
-		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5');
2548
+		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
2549
+		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5', $tmp_dir.'routes.tsv.gz.md5');
2550 2550
 		if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) {
2551
-			$routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2551
+			$routes_md5_file = explode(' ', file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2552 2552
 			$routes_md5 = $routes_md5_file[0];
2553 2553
 			if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) {
2554 2554
 				if ($globalDebug) echo "Gunzip...";
@@ -2565,10 +2565,10 @@  discard block
 block discarded – undo
2565 2565
 	public static function update_block_fam() {
2566 2566
 		global $tmp_dir, $globalDebug;
2567 2567
 		if ($globalDebug) echo "Blocked aircraft from FlightAirMap website : Download...";
2568
-		update_db::download('http://data.flightairmap.com/data/block.tsv.gz',$tmp_dir.'block.tsv.gz');
2569
-		update_db::download('http://data.flightairmap.com/data/block.tsv.gz.md5',$tmp_dir.'block.tsv.gz.md5');
2568
+		update_db::download('http://data.flightairmap.com/data/block.tsv.gz', $tmp_dir.'block.tsv.gz');
2569
+		update_db::download('http://data.flightairmap.com/data/block.tsv.gz.md5', $tmp_dir.'block.tsv.gz.md5');
2570 2570
 		if (file_exists($tmp_dir.'block.tsv.gz') && file_exists($tmp_dir.'block.tsv.gz.md5')) {
2571
-			$block_md5_file = explode(' ',file_get_contents($tmp_dir.'block.tsv.gz.md5'));
2571
+			$block_md5_file = explode(' ', file_get_contents($tmp_dir.'block.tsv.gz.md5'));
2572 2572
 			$block_md5 = $block_md5_file[0];
2573 2573
 			if (md5_file($tmp_dir.'block.tsv.gz') == $block_md5) {
2574 2574
 				if ($globalDebug) echo "Gunzip...";
@@ -2584,13 +2584,13 @@  discard block
 block discarded – undo
2584 2584
 	}
2585 2585
 	public static function update_marine_identity_fam() {
2586 2586
 		global $tmp_dir, $globalDebug;
2587
-		update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5');
2587
+		update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5');
2588 2588
 		if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) {
2589
-			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2589
+			$marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2590 2590
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2591 2591
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2592 2592
 				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2593
-				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2593
+				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz');
2594 2594
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2595 2595
 					if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) {
2596 2596
 						if ($globalDebug) echo "Gunzip...";
@@ -2612,13 +2612,13 @@  discard block
 block discarded – undo
2612 2612
 
2613 2613
 	public static function update_satellite_fam() {
2614 2614
 		global $tmp_dir, $globalDebug;
2615
-		update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5',$tmp_dir.'satellite.tsv.gz.md5');
2615
+		update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5', $tmp_dir.'satellite.tsv.gz.md5');
2616 2616
 		if (file_exists($tmp_dir.'satellite.tsv.gz.md5')) {
2617
-			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2617
+			$satellite_md5_file = explode(' ', file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2618 2618
 			$satellite_md5 = $satellite_md5_file[0];
2619 2619
 			if (!update_db::check_satellite_version($satellite_md5)) {
2620 2620
 				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
2621
-				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2621
+				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz', $tmp_dir.'satellite.tsv.gz');
2622 2622
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2623 2623
 					if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) {
2624 2624
 						if ($globalDebug) echo "Gunzip...";
@@ -2640,7 +2640,7 @@  discard block
 block discarded – undo
2640 2640
 	public static function update_banned_fam() {
2641 2641
 		global $tmp_dir, $globalDebug;
2642 2642
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2643
-		update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2643
+		update_db::download('http://data.flightairmap.com/data/ban-eu.csv', $tmp_dir.'ban_eu.csv');
2644 2644
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2645 2645
 			//if ($globalDebug) echo "Gunzip...";
2646 2646
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -2659,18 +2659,18 @@  discard block
 block discarded – undo
2659 2659
 		$error = '';
2660 2660
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2661 2661
 		if ($globalDBdriver == 'mysql') {
2662
-			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2662
+			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2663 2663
 		} else {
2664
-			update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2664
+			update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2665 2665
 		}
2666 2666
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
2667
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2667
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2668 2668
 			$airspace_md5 = $airspace_md5_file[0];
2669 2669
 			if (!update_db::check_airspace_version($airspace_md5)) {
2670 2670
 				if ($globalDBdriver == 'mysql') {
2671
-					update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
2671
+					update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
2672 2672
 				} else {
2673
-					update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2673
+					update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
2674 2674
 				}
2675 2675
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2676 2676
 					if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) {
@@ -2683,7 +2683,7 @@  discard block
 block discarded – undo
2683 2683
 							try {
2684 2684
 								$sth = $Connection->db->prepare($query);
2685 2685
 								$sth->execute();
2686
-							} catch(PDOException $e) {
2686
+							} catch (PDOException $e) {
2687 2687
 								return "error : ".$e->getMessage();
2688 2688
 							}
2689 2689
 						}
@@ -2703,16 +2703,16 @@  discard block
 block discarded – undo
2703 2703
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2704 2704
 		$error = '';
2705 2705
 		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
2706
-		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2706
+		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2707 2707
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2708
-			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2708
+			$geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2709 2709
 			$geoid_md5 = $geoid_md5_file[0];
2710 2710
 			if (!update_db::check_geoid_version($geoid_md5)) {
2711
-				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2711
+				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz');
2712 2712
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2713 2713
 					if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) {
2714 2714
 						if ($globalDebug) echo "Gunzip...";
2715
-						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2715
+						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2716 2716
 						if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2717 2717
 							update_db::insert_geoid_version($geoid_md5);
2718 2718
 						} else $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
@@ -2729,15 +2729,15 @@  discard block
 block discarded – undo
2729 2729
 	public static function update_tle() {
2730 2730
 		global $tmp_dir, $globalDebug;
2731 2731
 		if ($globalDebug) echo "Download TLE : Download...";
2732
-		$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',
2733
-		'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',
2734
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt');
2732
+		$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',
2733
+		'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',
2734
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt', 'visual.txt', 'sarsat.txt', 'argos.txt', 'ses.txt', 'iridium-NEXT.txt', 'beidou.txt');
2735 2735
 		foreach ($alltle as $filename) {
2736 2736
 			if ($globalDebug) echo "downloading ".$filename.'...';
2737
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2737
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
2738 2738
 			if (file_exists($tmp_dir.$filename)) {
2739 2739
 				if ($globalDebug) echo "Add to DB ".$filename."...";
2740
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2740
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
2741 2741
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2742 2742
 			if ($error != '') {
2743 2743
 				echo $error."\n";
@@ -2749,7 +2749,7 @@  discard block
 block discarded – undo
2749 2749
 	public static function update_ucsdb() {
2750 2750
 		global $tmp_dir, $globalDebug;
2751 2751
 		if ($globalDebug) echo "Download UCS DB : Download...";
2752
-		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/9-1-17-update/UCS_Satellite_Database_officialname_9-1-2017.txt',$tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt');
2752
+		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/9-1-17-update/UCS_Satellite_Database_officialname_9-1-2017.txt', $tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt');
2753 2753
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2754 2754
 			if ($globalDebug) echo "Add to DB...";
2755 2755
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt');
@@ -2763,7 +2763,7 @@  discard block
 block discarded – undo
2763 2763
 	public static function update_celestrak() {
2764 2764
 		global $tmp_dir, $globalDebug;
2765 2765
 		if ($globalDebug) echo "Download Celestrak DB : Download...";
2766
-		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2766
+		update_db::download('http://celestrak.com/pub/satcat.txt', $tmp_dir.'satcat.txt');
2767 2767
 		if (file_exists($tmp_dir.'satcat.txt')) {
2768 2768
 			if ($globalDebug) echo "Add to DB...";
2769 2769
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
@@ -2778,94 +2778,94 @@  discard block
 block discarded – undo
2778 2778
 		global $tmp_dir, $globalDebug;
2779 2779
 		$error = '';
2780 2780
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2781
-		update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2781
+		update_db::download('http://data.flightairmap.com/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2782 2782
 		if (file_exists($tmp_dir.'models.md5sum')) {
2783 2783
 			if ($globalDebug) echo "Check files...\n";
2784 2784
 			$newmodelsdb = array();
2785
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2786
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2785
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2786
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2787 2787
 					$model = trim($row[2]);
2788 2788
 					$newmodelsdb[$model] = trim($row[0]);
2789 2789
 				}
2790 2790
 			}
2791 2791
 			$modelsdb = array();
2792 2792
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2793
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2794
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2793
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2794
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2795 2795
 						$model = trim($row[2]);
2796 2796
 						$modelsdb[$model] = trim($row[0]);
2797 2797
 					}
2798 2798
 				}
2799 2799
 			}
2800
-			$diff = array_diff($newmodelsdb,$modelsdb);
2800
+			$diff = array_diff($newmodelsdb, $modelsdb);
2801 2801
 			foreach ($diff as $key => $value) {
2802 2802
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2803
-				update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2803
+				update_db::download('http://data.flightairmap.com/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2804 2804
 				
2805 2805
 			}
2806
-			update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2806
+			update_db::download('http://data.flightairmap.com/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2807 2807
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2808 2808
 		if ($error != '') {
2809 2809
 			return $error;
2810 2810
 		} elseif ($globalDebug) echo "Done\n";
2811 2811
 		if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download...";
2812
-		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum');
2812
+		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum', $tmp_dir.'modelsgltf2.md5sum');
2813 2813
 		if (file_exists($tmp_dir.'modelsgltf2.md5sum')) {
2814 2814
 			if ($globalDebug) echo "Check files...\n";
2815 2815
 			$newmodelsdb = array();
2816
-			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) {
2817
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2816
+			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum', 'r')) !== FALSE) {
2817
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2818 2818
 					$model = trim($row[2]);
2819 2819
 					$newmodelsdb[$model] = trim($row[0]);
2820 2820
 				}
2821 2821
 			}
2822 2822
 			$modelsdb = array();
2823 2823
 			if (file_exists(dirname(__FILE__).'/../models/gltf2/models.md5sum')) {
2824
-				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/models.md5sum','r')) !== FALSE) {
2825
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2824
+				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/models.md5sum', 'r')) !== FALSE) {
2825
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2826 2826
 						$model = trim($row[2]);
2827 2827
 						$modelsdb[$model] = trim($row[0]);
2828 2828
 					}
2829 2829
 				}
2830 2830
 			}
2831
-			$diff = array_diff($newmodelsdb,$modelsdb);
2831
+			$diff = array_diff($newmodelsdb, $modelsdb);
2832 2832
 			foreach ($diff as $key => $value) {
2833 2833
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2834
-				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key);
2834
+				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key, dirname(__FILE__).'/../models/gltf2/'.$key);
2835 2835
 				
2836 2836
 			}
2837
-			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum');
2837
+			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum', dirname(__FILE__).'/../models/gltf2/models.md5sum');
2838 2838
 		} else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
2839 2839
 		if ($error != '') {
2840 2840
 			return $error;
2841 2841
 		} elseif ($globalDebug) echo "Done\n";
2842 2842
 		if ($globalDebug) echo "Weather Models from FlightAirMap website : Download...";
2843
-		update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',$tmp_dir.'modelsweather.md5sum');
2843
+		update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum', $tmp_dir.'modelsweather.md5sum');
2844 2844
 		if (file_exists($tmp_dir.'modelsweather.md5sum')) {
2845 2845
 			if ($globalDebug) echo "Check files...\n";
2846 2846
 			$newmodelsdb = array();
2847
-			if (($handle = fopen($tmp_dir.'modelsweather.md5sum','r')) !== FALSE) {
2848
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2847
+			if (($handle = fopen($tmp_dir.'modelsweather.md5sum', 'r')) !== FALSE) {
2848
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2849 2849
 					$model = trim($row[2]);
2850 2850
 					$newmodelsdb[$model] = trim($row[0]);
2851 2851
 				}
2852 2852
 			}
2853 2853
 			$modelsdb = array();
2854 2854
 			if (file_exists(dirname(__FILE__).'/../models/gltf2/weather/models.md5sum')) {
2855
-				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/weather/models.md5sum','r')) !== FALSE) {
2856
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2855
+				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/weather/models.md5sum', 'r')) !== FALSE) {
2856
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2857 2857
 						$model = trim($row[2]);
2858 2858
 						$modelsdb[$model] = trim($row[0]);
2859 2859
 					}
2860 2860
 				}
2861 2861
 			}
2862
-			$diff = array_diff($newmodelsdb,$modelsdb);
2862
+			$diff = array_diff($newmodelsdb, $modelsdb);
2863 2863
 			foreach ($diff as $key => $value) {
2864 2864
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2865
-				update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/'.$key,dirname(__FILE__).'/../models/gltf2/weather/'.$key);
2865
+				update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/'.$key, dirname(__FILE__).'/../models/gltf2/weather/'.$key);
2866 2866
 				
2867 2867
 			}
2868
-			update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',dirname(__FILE__).'/../models/gltf2/weather/models.md5sum');
2868
+			update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum', dirname(__FILE__).'/../models/gltf2/weather/models.md5sum');
2869 2869
 		} else $error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed.";
2870 2870
 		if ($error != '') {
2871 2871
 			return $error;
@@ -2877,32 +2877,32 @@  discard block
 block discarded – undo
2877 2877
 		global $tmp_dir, $globalDebug;
2878 2878
 		$error = '';
2879 2879
 		if ($globalDebug) echo "Liveries from FlightAirMap website : Download...";
2880
-		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum');
2880
+		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum', $tmp_dir.'liveries.md5sum');
2881 2881
 		if (file_exists($tmp_dir.'liveries.md5sum')) {
2882 2882
 			if ($globalDebug) echo "Check files...\n";
2883 2883
 			$newmodelsdb = array();
2884
-			if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) {
2885
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2884
+			if (($handle = fopen($tmp_dir.'liveries.md5sum', 'r')) !== FALSE) {
2885
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2886 2886
 					$model = trim($row[2]);
2887 2887
 					$newmodelsdb[$model] = trim($row[0]);
2888 2888
 				}
2889 2889
 			}
2890 2890
 			$modelsdb = array();
2891 2891
 			if (file_exists(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum')) {
2892
-				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum','r')) !== FALSE) {
2893
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2892
+				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum', 'r')) !== FALSE) {
2893
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2894 2894
 						$model = trim($row[2]);
2895 2895
 						$modelsdb[$model] = trim($row[0]);
2896 2896
 					}
2897 2897
 				}
2898 2898
 			}
2899
-			$diff = array_diff($newmodelsdb,$modelsdb);
2899
+			$diff = array_diff($newmodelsdb, $modelsdb);
2900 2900
 			foreach ($diff as $key => $value) {
2901 2901
 				if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n";
2902
-				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2902
+				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key, dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2903 2903
 				
2904 2904
 			}
2905
-			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2905
+			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum', dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2906 2906
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2907 2907
 		if ($error != '') {
2908 2908
 			return $error;
@@ -2914,32 +2914,32 @@  discard block
 block discarded – undo
2914 2914
 		global $tmp_dir, $globalDebug;
2915 2915
 		$error = '';
2916 2916
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2917
-		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2917
+		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
2918 2918
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2919 2919
 			if ($globalDebug) echo "Check files...\n";
2920 2920
 			$newmodelsdb = array();
2921
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2922
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2921
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
2922
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2923 2923
 					$model = trim($row[2]);
2924 2924
 					$newmodelsdb[$model] = trim($row[0]);
2925 2925
 				}
2926 2926
 			}
2927 2927
 			$modelsdb = array();
2928 2928
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
2929
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
2930
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2929
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
2930
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2931 2931
 						$model = trim($row[2]);
2932 2932
 						$modelsdb[$model] = trim($row[0]);
2933 2933
 					}
2934 2934
 				}
2935 2935
 			}
2936
-			$diff = array_diff($newmodelsdb,$modelsdb);
2936
+			$diff = array_diff($newmodelsdb, $modelsdb);
2937 2937
 			foreach ($diff as $key => $value) {
2938 2938
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2939
-				update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2939
+				update_db::download('http://data.flightairmap.com/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2940 2940
 				
2941 2941
 			}
2942
-			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2942
+			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2943 2943
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2944 2944
 		if ($error != '') {
2945 2945
 			return $error;
@@ -2951,32 +2951,32 @@  discard block
 block discarded – undo
2951 2951
 		global $tmp_dir, $globalDebug;
2952 2952
 		$error = '';
2953 2953
 		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2954
-		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2954
+		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum');
2955 2955
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2956 2956
 			if ($globalDebug) echo "Check files...\n";
2957 2957
 			$newmodelsdb = array();
2958
-			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2959
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2958
+			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) {
2959
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2960 2960
 					$model = trim($row[2]);
2961 2961
 					$newmodelsdb[$model] = trim($row[0]);
2962 2962
 				}
2963 2963
 			}
2964 2964
 			$modelsdb = array();
2965 2965
 			if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) {
2966
-				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) {
2967
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2966
+				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) {
2967
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2968 2968
 						$model = trim($row[2]);
2969 2969
 						$modelsdb[$model] = trim($row[0]);
2970 2970
 					}
2971 2971
 				}
2972 2972
 			}
2973
-			$diff = array_diff($newmodelsdb,$modelsdb);
2973
+			$diff = array_diff($newmodelsdb, $modelsdb);
2974 2974
 			foreach ($diff as $key => $value) {
2975 2975
 				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2976
-				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2976
+				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key);
2977 2977
 				
2978 2978
 			}
2979
-			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2979
+			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2980 2980
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2981 2981
 		if ($error != '') {
2982 2982
 			return $error;
@@ -2988,8 +2988,8 @@  discard block
 block discarded – undo
2988 2988
 		global $tmp_dir, $globalDebug;
2989 2989
 		date_default_timezone_set('UTC');
2990 2990
 		$Common = new Common();
2991
-		$data = $Common->getData('https://www4.icao.int/doc8643/External/AircraftTypes','post',array('X-Requested-With: XMLHttpRequest','Accept: application/json, text/javascript, */*; q=0.01','Host: www4.icao.int','Origin: https://www.icao.int','Content-Length: 0'),'','','https://www.icao.int/publications/DOC8643/Pages/Search.aspx',60);
2992
-		$all = json_decode($data,true);
2991
+		$data = $Common->getData('https://www4.icao.int/doc8643/External/AircraftTypes', 'post', array('X-Requested-With: XMLHttpRequest', 'Accept: application/json, text/javascript, */*; q=0.01', 'Host: www4.icao.int', 'Origin: https://www.icao.int', 'Content-Length: 0'), '', '', 'https://www.icao.int/publications/DOC8643/Pages/Search.aspx', 60);
2992
+		$all = json_decode($data, true);
2993 2993
 		$Connection = new Connection();
2994 2994
 		$querychk = "SELECT COUNT(1) as nb FROM aircraft WHERE icao = :icao";
2995 2995
 		$sth = $Connection->db->prepare($querychk);
@@ -3001,8 +3001,8 @@  discard block
 block discarded – undo
3001 3001
 		foreach ($all as $model) {
3002 3002
 			$icao = $model['Designator'];
3003 3003
 			if (!isset($allicao[$icao])) {
3004
-				$aircraft_shadow = 'generic_'.substr($model['EngineType'],0,1).$model['EngineCount'].$model['WTC'].'.png';
3005
-				$allicao[$icao] = array(':icao' => $icao,':type' => $model['ModelFullName'],':manufacturer' => $model['ManufacturerCode'],':aircraft_shadow' => $aircraft_shadow,':aircraft_description' => $model['AircraftDescription'],':engine_type' => $model['EngineType'],':engine_count' => $model['EngineCount'],':wake_category' => $model['WTC']);
3004
+				$aircraft_shadow = 'generic_'.substr($model['EngineType'], 0, 1).$model['EngineCount'].$model['WTC'].'.png';
3005
+				$allicao[$icao] = array(':icao' => $icao, ':type' => $model['ModelFullName'], ':manufacturer' => $model['ManufacturerCode'], ':aircraft_shadow' => $aircraft_shadow, ':aircraft_description' => $model['AircraftDescription'], ':engine_type' => $model['EngineType'], ':engine_count' => $model['EngineCount'], ':wake_category' => $model['WTC']);
3006 3006
 			} else {
3007 3007
 				$allicao[$icao][':type'] = $allicao[$icao][':type'].'/'.$model['ModelFullName'];
3008 3008
 			}
@@ -3014,9 +3014,9 @@  discard block
 block discarded – undo
3014 3014
 				if ($exist[0]['nb'] == 0) {
3015 3015
 					$sthins->execute($airdata);
3016 3016
 				} else {
3017
-					$sthup->execute(array(':type' => $airdata[':type'],':icao' => $icao));
3017
+					$sthup->execute(array(':type' => $airdata[':type'], ':icao' => $icao));
3018 3018
 				}
3019
-			} catch(PDOException $e) {
3019
+			} catch (PDOException $e) {
3020 3020
 				return "error : ".$e->getMessage();
3021 3021
 			}
3022 3022
 		}
@@ -3048,23 +3048,23 @@  discard block
 block discarded – undo
3048 3048
 			$Connection = new Connection();
3049 3049
 			$sth = $Connection->db->prepare($query);
3050 3050
                         $sth->execute();
3051
-                } catch(PDOException $e) {
3051
+                } catch (PDOException $e) {
3052 3052
                         return "error : ".$e->getMessage();
3053 3053
                 }
3054 3054
 
3055 3055
 		$error = '';
3056 3056
 		if ($globalDebug) echo "Notam : Download...";
3057
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
3057
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
3058 3058
 		if (file_exists($tmp_dir.'notam.rss')) {
3059
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
3059
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
3060 3060
 			foreach ($notams['channel']['item'] as $notam) {
3061
-				$title = explode(':',$notam['title']);
3061
+				$title = explode(':', $notam['title']);
3062 3062
 				$data['ref'] = trim($title[0]);
3063 3063
 				unset($title[0]);
3064
-				$data['title'] = trim(implode(':',$title));
3065
-				$description = strip_tags($notam['description'],'<pre>');
3066
-				preg_match(':^(.*?)<pre>:',$description,$match);
3067
-				$q = explode('/',$match[1]);
3064
+				$data['title'] = trim(implode(':', $title));
3065
+				$description = strip_tags($notam['description'], '<pre>');
3066
+				preg_match(':^(.*?)<pre>:', $description, $match);
3067
+				$q = explode('/', $match[1]);
3068 3068
 				$data['fir'] = $q[0];
3069 3069
 				$data['code'] = $q[1];
3070 3070
 				$ifrvfr = $q[2];
@@ -3080,30 +3080,30 @@  discard block
 block discarded – undo
3080 3080
 				$data['lower_limit'] = $q[5];
3081 3081
 				$data['upper_limit'] = $q[6];
3082 3082
 				$latlonrad = $q[7];
3083
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
3084
-				$latitude = $Common->convertDec($las,'latitude');
3085
-				$longitude = $Common->convertDec($lns,'longitude');
3083
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
3084
+				$latitude = $Common->convertDec($las, 'latitude');
3085
+				$longitude = $Common->convertDec($lns, 'longitude');
3086 3086
 				if ($lac == 'S') $latitude = '-'.$latitude;
3087 3087
 				if ($lnc == 'W') $longitude = '-'.$longitude;
3088 3088
 				$data['center_latitude'] = $latitude;
3089 3089
 				$data['center_longitude'] = $longitude;
3090 3090
 				$data['radius'] = intval($radius);
3091 3091
 				
3092
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
3092
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
3093 3093
 				$data['text'] = $match[1];
3094
-				preg_match(':</pre>(.*?)$:',$description,$match);
3094
+				preg_match(':</pre>(.*?)$:', $description, $match);
3095 3095
 				$fromto = $match[1];
3096
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
3096
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
3097 3097
 				$fromall = trim($match[1]);
3098
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
3098
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
3099 3099
 				$from = trim($match[1]);
3100
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
3101
-				preg_match('#TO:(.*?)$#',$fromto,$match);
3100
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
3101
+				preg_match('#TO:(.*?)$#', $fromto, $match);
3102 3102
 				$toall = trim($match[1]);
3103
-				if (!preg_match(':Permanent:',$toall)) {
3104
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
3103
+				if (!preg_match(':Permanent:', $toall)) {
3104
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
3105 3105
 					$to = trim($match[1]);
3106
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
3106
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
3107 3107
 					$data['permanent'] = 0;
3108 3108
 				} else {
3109 3109
 				    $data['date_end'] = NULL;
@@ -3111,7 +3111,7 @@  discard block
 block discarded – undo
3111 3111
 				}
3112 3112
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
3113 3113
 				$NOTAM = new NOTAM();
3114
-				$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']);
3114
+				$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']);
3115 3115
 				unset($data);
3116 3116
 			} 
3117 3117
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -3134,16 +3134,16 @@  discard block
 block discarded – undo
3134 3134
 				$Connection = new Connection();
3135 3135
 				$sth = $Connection->db->prepare($query);
3136 3136
 				$sth->execute();
3137
-			} catch(PDOException $e) {
3137
+			} catch (PDOException $e) {
3138 3138
 				return "error : ".$e->getMessage();
3139 3139
 			}
3140 3140
 		}
3141 3141
 		$Common = new Common();
3142 3142
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
3143
-		$airspace_json = json_decode($airspace_lst,true);
3143
+		$airspace_json = json_decode($airspace_lst, true);
3144 3144
 		foreach ($airspace_json['records'] as $airspace) {
3145 3145
 			if ($globalDebug) echo $airspace['name']."...\n";
3146
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
3146
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
3147 3147
 			if (file_exists($tmp_dir.$airspace['name'])) {
3148 3148
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
3149 3149
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -3165,7 +3165,7 @@  discard block
 block discarded – undo
3165 3165
 				$Connection = new Connection();
3166 3166
 				$sth = $Connection->db->prepare($query);
3167 3167
 				$sth->execute(array(':new' => $new, ':old' => $old));
3168
-			} catch(PDOException $e) {
3168
+			} catch (PDOException $e) {
3169 3169
 				return "error : ".$e->getMessage();
3170 3170
 			}
3171 3171
 		}
@@ -3182,7 +3182,7 @@  discard block
 block discarded – undo
3182 3182
 			$Connection = new Connection();
3183 3183
 			$sth = $Connection->db->prepare($query);
3184 3184
                         $sth->execute();
3185
-                } catch(PDOException $e) {
3185
+                } catch (PDOException $e) {
3186 3186
                         return "error : ".$e->getMessage();
3187 3187
                 }
3188 3188
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3197,7 +3197,7 @@  discard block
 block discarded – undo
3197 3197
 			$Connection = new Connection();
3198 3198
 			$sth = $Connection->db->prepare($query);
3199 3199
                         $sth->execute();
3200
-                } catch(PDOException $e) {
3200
+                } catch (PDOException $e) {
3201 3201
                         return "error : ".$e->getMessage();
3202 3202
                 }
3203 3203
 	}
@@ -3208,7 +3208,7 @@  discard block
 block discarded – undo
3208 3208
 			$Connection = new Connection();
3209 3209
 			$sth = $Connection->db->prepare($query);
3210 3210
                         $sth->execute(array(':version' => $version));
3211
-                } catch(PDOException $e) {
3211
+                } catch (PDOException $e) {
3212 3212
                         return "error : ".$e->getMessage();
3213 3213
                 }
3214 3214
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3222,7 +3222,7 @@  discard block
 block discarded – undo
3222 3222
 			$Connection = new Connection();
3223 3223
 			$sth = $Connection->db->prepare($query);
3224 3224
                         $sth->execute(array(':version' => $version));
3225
-                } catch(PDOException $e) {
3225
+                } catch (PDOException $e) {
3226 3226
                         return "error : ".$e->getMessage();
3227 3227
                 }
3228 3228
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3236,7 +3236,7 @@  discard block
 block discarded – undo
3236 3236
 			$Connection = new Connection();
3237 3237
 			$sth = $Connection->db->prepare($query);
3238 3238
 			$sth->execute(array(':version' => $version));
3239
-		} catch(PDOException $e) {
3239
+		} catch (PDOException $e) {
3240 3240
 			return "error : ".$e->getMessage();
3241 3241
 		}
3242 3242
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3250,7 +3250,7 @@  discard block
 block discarded – undo
3250 3250
 			$Connection = new Connection();
3251 3251
 			$sth = $Connection->db->prepare($query);
3252 3252
 			$sth->execute(array(':version' => $version));
3253
-		} catch(PDOException $e) {
3253
+		} catch (PDOException $e) {
3254 3254
 			return "error : ".$e->getMessage();
3255 3255
 		}
3256 3256
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3264,7 +3264,7 @@  discard block
 block discarded – undo
3264 3264
 			$Connection = new Connection();
3265 3265
 			$sth = $Connection->db->prepare($query);
3266 3266
 			$sth->execute(array(':version' => $version));
3267
-		} catch(PDOException $e) {
3267
+		} catch (PDOException $e) {
3268 3268
 			return "error : ".$e->getMessage();
3269 3269
 		}
3270 3270
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3278,7 +3278,7 @@  discard block
 block discarded – undo
3278 3278
 			$Connection = new Connection();
3279 3279
 			$sth = $Connection->db->prepare($query);
3280 3280
 			$sth->execute(array(':version' => $version));
3281
-		} catch(PDOException $e) {
3281
+		} catch (PDOException $e) {
3282 3282
 			return "error : ".$e->getMessage();
3283 3283
 		}
3284 3284
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3293,7 +3293,7 @@  discard block
 block discarded – undo
3293 3293
 			$Connection = new Connection();
3294 3294
 			$sth = $Connection->db->prepare($query);
3295 3295
 			$sth->execute(array(':version' => $version));
3296
-		} catch(PDOException $e) {
3296
+		} catch (PDOException $e) {
3297 3297
 			return "error : ".$e->getMessage();
3298 3298
 		}
3299 3299
 	}
@@ -3305,7 +3305,7 @@  discard block
 block discarded – undo
3305 3305
 			$Connection = new Connection();
3306 3306
 			$sth = $Connection->db->prepare($query);
3307 3307
 			$sth->execute(array(':version' => $version));
3308
-		} catch(PDOException $e) {
3308
+		} catch (PDOException $e) {
3309 3309
 			return "error : ".$e->getMessage();
3310 3310
 		}
3311 3311
 	}
@@ -3317,7 +3317,7 @@  discard block
 block discarded – undo
3317 3317
 			$Connection = new Connection();
3318 3318
 			$sth = $Connection->db->prepare($query);
3319 3319
 			$sth->execute(array(':version' => $version));
3320
-		} catch(PDOException $e) {
3320
+		} catch (PDOException $e) {
3321 3321
 			return "error : ".$e->getMessage();
3322 3322
 		}
3323 3323
 	}
@@ -3329,7 +3329,7 @@  discard block
 block discarded – undo
3329 3329
 			$Connection = new Connection();
3330 3330
 			$sth = $Connection->db->prepare($query);
3331 3331
                         $sth->execute(array(':version' => $version));
3332
-                } catch(PDOException $e) {
3332
+                } catch (PDOException $e) {
3333 3333
                         return "error : ".$e->getMessage();
3334 3334
                 }
3335 3335
 	}
@@ -3341,7 +3341,7 @@  discard block
 block discarded – undo
3341 3341
 			$Connection = new Connection();
3342 3342
 			$sth = $Connection->db->prepare($query);
3343 3343
 			$sth->execute(array(':version' => $version));
3344
-		} catch(PDOException $e) {
3344
+		} catch (PDOException $e) {
3345 3345
 			return "error : ".$e->getMessage();
3346 3346
 		}
3347 3347
 	}
@@ -3353,7 +3353,7 @@  discard block
 block discarded – undo
3353 3353
 			$Connection = new Connection();
3354 3354
 			$sth = $Connection->db->prepare($query);
3355 3355
 			$sth->execute(array(':version' => $version));
3356
-		} catch(PDOException $e) {
3356
+		} catch (PDOException $e) {
3357 3357
 			return "error : ".$e->getMessage();
3358 3358
 		}
3359 3359
 	}
@@ -3369,7 +3369,7 @@  discard block
 block discarded – undo
3369 3369
 			$Connection = new Connection();
3370 3370
 			$sth = $Connection->db->prepare($query);
3371 3371
                         $sth->execute();
3372
-                } catch(PDOException $e) {
3372
+                } catch (PDOException $e) {
3373 3373
                         return "error : ".$e->getMessage();
3374 3374
                 }
3375 3375
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3384,7 +3384,7 @@  discard block
 block discarded – undo
3384 3384
 			$Connection = new Connection();
3385 3385
 			$sth = $Connection->db->prepare($query);
3386 3386
                         $sth->execute();
3387
-                } catch(PDOException $e) {
3387
+                } catch (PDOException $e) {
3388 3388
                         return "error : ".$e->getMessage();
3389 3389
                 }
3390 3390
 	}
@@ -3400,7 +3400,7 @@  discard block
 block discarded – undo
3400 3400
 			$Connection = new Connection();
3401 3401
 			$sth = $Connection->db->prepare($query);
3402 3402
                         $sth->execute();
3403
-                } catch(PDOException $e) {
3403
+                } catch (PDOException $e) {
3404 3404
                         return "error : ".$e->getMessage();
3405 3405
                 }
3406 3406
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3415,7 +3415,7 @@  discard block
 block discarded – undo
3415 3415
 			$Connection = new Connection();
3416 3416
 			$sth = $Connection->db->prepare($query);
3417 3417
                         $sth->execute();
3418
-                } catch(PDOException $e) {
3418
+                } catch (PDOException $e) {
3419 3419
                         return "error : ".$e->getMessage();
3420 3420
                 }
3421 3421
 	}
@@ -3431,7 +3431,7 @@  discard block
 block discarded – undo
3431 3431
 			$Connection = new Connection();
3432 3432
 			$sth = $Connection->db->prepare($query);
3433 3433
                         $sth->execute();
3434
-                } catch(PDOException $e) {
3434
+                } catch (PDOException $e) {
3435 3435
                         return "error : ".$e->getMessage();
3436 3436
                 }
3437 3437
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3446,7 +3446,7 @@  discard block
 block discarded – undo
3446 3446
 			$Connection = new Connection();
3447 3447
 			$sth = $Connection->db->prepare($query);
3448 3448
                         $sth->execute();
3449
-                } catch(PDOException $e) {
3449
+                } catch (PDOException $e) {
3450 3450
                         return "error : ".$e->getMessage();
3451 3451
                 }
3452 3452
 	}
@@ -3462,7 +3462,7 @@  discard block
 block discarded – undo
3462 3462
 			$Connection = new Connection();
3463 3463
 			$sth = $Connection->db->prepare($query);
3464 3464
 			$sth->execute();
3465
-		} catch(PDOException $e) {
3465
+		} catch (PDOException $e) {
3466 3466
 			return "error : ".$e->getMessage();
3467 3467
 		}
3468 3468
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3477,7 +3477,7 @@  discard block
 block discarded – undo
3477 3477
 			$Connection = new Connection();
3478 3478
 			$sth = $Connection->db->prepare($query);
3479 3479
 			$sth->execute();
3480
-		} catch(PDOException $e) {
3480
+		} catch (PDOException $e) {
3481 3481
 			return "error : ".$e->getMessage();
3482 3482
 		}
3483 3483
 	}
@@ -3493,7 +3493,7 @@  discard block
 block discarded – undo
3493 3493
 			$Connection = new Connection();
3494 3494
 			$sth = $Connection->db->prepare($query);
3495 3495
 			$sth->execute();
3496
-		} catch(PDOException $e) {
3496
+		} catch (PDOException $e) {
3497 3497
 			return "error : ".$e->getMessage();
3498 3498
 		}
3499 3499
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3508,7 +3508,7 @@  discard block
 block discarded – undo
3508 3508
 			$Connection = new Connection();
3509 3509
 			$sth = $Connection->db->prepare($query);
3510 3510
 			$sth->execute();
3511
-		} catch(PDOException $e) {
3511
+		} catch (PDOException $e) {
3512 3512
 			return "error : ".$e->getMessage();
3513 3513
 		}
3514 3514
 	}
@@ -3524,7 +3524,7 @@  discard block
 block discarded – undo
3524 3524
 			$Connection = new Connection();
3525 3525
 			$sth = $Connection->db->prepare($query);
3526 3526
 			$sth->execute();
3527
-		} catch(PDOException $e) {
3527
+		} catch (PDOException $e) {
3528 3528
 			return "error : ".$e->getMessage();
3529 3529
 		}
3530 3530
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3539,7 +3539,7 @@  discard block
 block discarded – undo
3539 3539
 			$Connection = new Connection();
3540 3540
 			$sth = $Connection->db->prepare($query);
3541 3541
 			$sth->execute();
3542
-		} catch(PDOException $e) {
3542
+		} catch (PDOException $e) {
3543 3543
 			return "error : ".$e->getMessage();
3544 3544
 		}
3545 3545
 	}
@@ -3555,7 +3555,7 @@  discard block
 block discarded – undo
3555 3555
 			$Connection = new Connection();
3556 3556
 			$sth = $Connection->db->prepare($query);
3557 3557
                         $sth->execute();
3558
-                } catch(PDOException $e) {
3558
+                } catch (PDOException $e) {
3559 3559
                         return "error : ".$e->getMessage();
3560 3560
                 }
3561 3561
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3570,7 +3570,7 @@  discard block
 block discarded – undo
3570 3570
 			$Connection = new Connection();
3571 3571
 			$sth = $Connection->db->prepare($query);
3572 3572
 			$sth->execute();
3573
-		} catch(PDOException $e) {
3573
+		} catch (PDOException $e) {
3574 3574
 			return "error : ".$e->getMessage();
3575 3575
 		}
3576 3576
 	}
@@ -3586,7 +3586,7 @@  discard block
 block discarded – undo
3586 3586
 			$Connection = new Connection();
3587 3587
 			$sth = $Connection->db->prepare($query);
3588 3588
 			$sth->execute();
3589
-		} catch(PDOException $e) {
3589
+		} catch (PDOException $e) {
3590 3590
 			return "error : ".$e->getMessage();
3591 3591
 		}
3592 3592
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3601,7 +3601,7 @@  discard block
 block discarded – undo
3601 3601
 			$Connection = new Connection();
3602 3602
 			$sth = $Connection->db->prepare($query);
3603 3603
 			$sth->execute();
3604
-		} catch(PDOException $e) {
3604
+		} catch (PDOException $e) {
3605 3605
 			return "error : ".$e->getMessage();
3606 3606
 		}
3607 3607
 	}
@@ -3617,7 +3617,7 @@  discard block
 block discarded – undo
3617 3617
 			$Connection = new Connection();
3618 3618
 			$sth = $Connection->db->prepare($query);
3619 3619
 			$sth->execute();
3620
-		} catch(PDOException $e) {
3620
+		} catch (PDOException $e) {
3621 3621
 			return "error : ".$e->getMessage();
3622 3622
 		}
3623 3623
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3632,7 +3632,7 @@  discard block
 block discarded – undo
3632 3632
 			$Connection = new Connection();
3633 3633
 			$sth = $Connection->db->prepare($query);
3634 3634
 			$sth->execute();
3635
-		} catch(PDOException $e) {
3635
+		} catch (PDOException $e) {
3636 3636
 			return "error : ".$e->getMessage();
3637 3637
 		}
3638 3638
 	}
@@ -3648,7 +3648,7 @@  discard block
 block discarded – undo
3648 3648
 			$Connection = new Connection();
3649 3649
 			$sth = $Connection->db->prepare($query);
3650 3650
 			$sth->execute();
3651
-		} catch(PDOException $e) {
3651
+		} catch (PDOException $e) {
3652 3652
 			return "error : ".$e->getMessage();
3653 3653
 		}
3654 3654
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3663,7 +3663,7 @@  discard block
 block discarded – undo
3663 3663
 			$Connection = new Connection();
3664 3664
 			$sth = $Connection->db->prepare($query);
3665 3665
 			$sth->execute();
3666
-		} catch(PDOException $e) {
3666
+		} catch (PDOException $e) {
3667 3667
 			return "error : ".$e->getMessage();
3668 3668
 		}
3669 3669
 	}
@@ -3679,7 +3679,7 @@  discard block
 block discarded – undo
3679 3679
 			$Connection = new Connection();
3680 3680
 			$sth = $Connection->db->prepare($query);
3681 3681
 			$sth->execute();
3682
-		} catch(PDOException $e) {
3682
+		} catch (PDOException $e) {
3683 3683
 			return "error : ".$e->getMessage();
3684 3684
 		}
3685 3685
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3698,7 +3698,7 @@  discard block
 block discarded – undo
3698 3698
 			$Connection = new Connection();
3699 3699
 			$sth = $Connection->db->prepare($query);
3700 3700
 			$sth->execute();
3701
-		} catch(PDOException $e) {
3701
+		} catch (PDOException $e) {
3702 3702
 			return "error : ".$e->getMessage();
3703 3703
 		}
3704 3704
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3713,7 +3713,7 @@  discard block
 block discarded – undo
3713 3713
 			$Connection = new Connection();
3714 3714
 			$sth = $Connection->db->prepare($query);
3715 3715
 			$sth->execute();
3716
-		} catch(PDOException $e) {
3716
+		} catch (PDOException $e) {
3717 3717
 			return "error : ".$e->getMessage();
3718 3718
 		}
3719 3719
 	}
@@ -3725,7 +3725,7 @@  discard block
 block discarded – undo
3725 3725
 			$Connection = new Connection();
3726 3726
 			$sth = $Connection->db->prepare($query);
3727 3727
 			$sth->execute();
3728
-		} catch(PDOException $e) {
3728
+		} catch (PDOException $e) {
3729 3729
 			return "error : ".$e->getMessage();
3730 3730
 		}
3731 3731
 	}
@@ -3741,7 +3741,7 @@  discard block
 block discarded – undo
3741 3741
 			$Connection = new Connection();
3742 3742
 			$sth = $Connection->db->prepare($query);
3743 3743
                         $sth->execute();
3744
-                } catch(PDOException $e) {
3744
+                } catch (PDOException $e) {
3745 3745
                         return "error : ".$e->getMessage();
3746 3746
                 }
3747 3747
 	}
@@ -3756,7 +3756,7 @@  discard block
 block discarded – undo
3756 3756
 			$Connection = new Connection();
3757 3757
 			$sth = $Connection->db->prepare($query);
3758 3758
                         $sth->execute();
3759
-                } catch(PDOException $e) {
3759
+                } catch (PDOException $e) {
3760 3760
                         return "error : ".$e->getMessage();
3761 3761
                 }
3762 3762
 	}
Please login to merge, or discard this patch.
Braces   +1205 added lines, -417 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
27 27
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
28 28
 		curl_setopt($ch, CURLOPT_TIMEOUT, 200);
29
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
29
+		if ($referer != '') {
30
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
31
+		}
30 32
 		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');
31 33
 		curl_setopt($ch, CURLOPT_FILE, $fp);
32 34
 		curl_exec($ch);
@@ -37,12 +39,16 @@  discard block
 block discarded – undo
37 39
 	public static function gunzip($in_file,$out_file_name = '') {
38 40
 		//echo $in_file.' -> '.$out_file_name."\n";
39 41
 		$buffer_size = 4096; // read 4kb at a time
40
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
42
+		if ($out_file_name == '') {
43
+			$out_file_name = str_replace('.gz', '', $in_file);
44
+		}
41 45
 		if ($in_file != '' && file_exists($in_file)) {
42 46
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
43
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
44
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
45
-			else {
47
+			if (function_exists('gzopen')) {
48
+				$file = gzopen($in_file,'rb');
49
+			} elseif (function_exists('gzopen64')) {
50
+				$file = gzopen64($in_file,'rb');
51
+			} else {
46 52
 				echo 'gzopen not available';
47 53
 				die;
48 54
 			}
@@ -63,8 +69,12 @@  discard block
 block discarded – undo
63 69
 			if ($res === TRUE) {
64 70
 				$zip->extractTo($path);
65 71
 				$zip->close();
66
-			} else return false;
67
-		} else return false;
72
+			} else {
73
+				return false;
74
+			}
75
+		} else {
76
+			return false;
77
+		}
68 78
 	}
69 79
 	
70 80
 	public static function connect_sqlite($database) {
@@ -79,7 +89,9 @@  discard block
 block discarded – undo
79 89
 	public static function retrieve_route_sqlite_to_dest($database_file) {
80 90
 		global $globalDebug, $globalTransaction;
81 91
 		//$query = 'TRUNCATE TABLE routes';
82
-		if ($globalDebug) echo " - Delete previous routes from DB -";
92
+		if ($globalDebug) {
93
+			echo " - Delete previous routes from DB -";
94
+		}
83 95
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
84 96
 		$Connection = new Connection();
85 97
 		try {
@@ -90,7 +102,9 @@  discard block
 block discarded – undo
90 102
                         return "error : ".$e->getMessage();
91 103
                 }
92 104
 
93
-    		if ($globalDebug) echo " - Add routes to DB -";
105
+    		if ($globalDebug) {
106
+    			echo " - Add routes to DB -";
107
+    		}
94 108
     		update_db::connect_sqlite($database_file);
95 109
 		//$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';
96 110
 		$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";
@@ -105,15 +119,21 @@  discard block
 block discarded – undo
105 119
 		$Connection = new Connection();
106 120
 		$sth_dest = $Connection->db->prepare($query_dest);
107 121
 		try {
108
-			if ($globalTransaction) $Connection->db->beginTransaction();
122
+			if ($globalTransaction) {
123
+				$Connection->db->beginTransaction();
124
+			}
109 125
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
110 126
 				//$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);
111 127
 				$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);
112 128
 				$sth_dest->execute($query_dest_values);
113 129
             		}
114
-			if ($globalTransaction) $Connection->db->commit();
130
+			if ($globalTransaction) {
131
+				$Connection->db->commit();
132
+			}
115 133
 		} catch(PDOException $e) {
116
-			if ($globalTransaction) $Connection->db->rollBack(); 
134
+			if ($globalTransaction) {
135
+				$Connection->db->rollBack();
136
+			}
117 137
 			return "error : ".$e->getMessage();
118 138
 		}
119 139
                 return '';
@@ -121,7 +141,9 @@  discard block
 block discarded – undo
121 141
 	public static function retrieve_route_oneworld($database_file) {
122 142
 		global $globalDebug, $globalTransaction;
123 143
 		//$query = 'TRUNCATE TABLE routes';
124
-		if ($globalDebug) echo " - Delete previous routes from DB -";
144
+		if ($globalDebug) {
145
+			echo " - Delete previous routes from DB -";
146
+		}
125 147
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
126 148
 		$Connection = new Connection();
127 149
 		try {
@@ -132,14 +154,18 @@  discard block
 block discarded – undo
132 154
                         return "error : ".$e->getMessage();
133 155
                 }
134 156
 
135
-    		if ($globalDebug) echo " - Add routes to DB -";
157
+    		if ($globalDebug) {
158
+    			echo " - Add routes to DB -";
159
+    		}
136 160
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
137 161
 		$Spotter = new Spotter();
138 162
 		if ($fh = fopen($database_file,"r")) {
139 163
 			$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)';
140 164
 			$Connection = new Connection();
141 165
 			$sth_dest = $Connection->db->prepare($query_dest);
142
-			if ($globalTransaction) $Connection->db->beginTransaction();
166
+			if ($globalTransaction) {
167
+				$Connection->db->beginTransaction();
168
+			}
143 169
 			while (!feof($fh)) {
144 170
 				$line = fgetcsv($fh,9999,',');
145 171
 				if ($line[0] != '') {
@@ -148,13 +174,17 @@  discard block
 block discarded – undo
148 174
 							$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');
149 175
 							$sth_dest->execute($query_dest_values);
150 176
 						} catch(PDOException $e) {
151
-							if ($globalTransaction) $Connection->db->rollBack(); 
177
+							if ($globalTransaction) {
178
+								$Connection->db->rollBack();
179
+							}
152 180
 							return "error : ".$e->getMessage();
153 181
 						}
154 182
 					}
155 183
 				}
156 184
 			}
157
-			if ($globalTransaction) $Connection->db->commit();
185
+			if ($globalTransaction) {
186
+				$Connection->db->commit();
187
+			}
158 188
 		}
159 189
                 return '';
160 190
 	}
@@ -162,7 +192,9 @@  discard block
 block discarded – undo
162 192
 	public static function retrieve_route_skyteam($database_file) {
163 193
 		global $globalDebug, $globalTransaction;
164 194
 		//$query = 'TRUNCATE TABLE routes';
165
-		if ($globalDebug) echo " - Delete previous routes from DB -";
195
+		if ($globalDebug) {
196
+			echo " - Delete previous routes from DB -";
197
+		}
166 198
 		$query = "DELETE FROM routes WHERE Source = '' OR Source = :source";
167 199
 		$Connection = new Connection();
168 200
 		try {
@@ -173,7 +205,9 @@  discard block
 block discarded – undo
173 205
                         return "error : ".$e->getMessage();
174 206
                 }
175 207
 
176
-    		if ($globalDebug) echo " - Add routes to DB -";
208
+    		if ($globalDebug) {
209
+    			echo " - Add routes to DB -";
210
+    		}
177 211
 
178 212
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
179 213
 		$Spotter = new Spotter();
@@ -182,7 +216,9 @@  discard block
 block discarded – undo
182 216
 			$Connection = new Connection();
183 217
 			$sth_dest = $Connection->db->prepare($query_dest);
184 218
 			try {
185
-				if ($globalTransaction) $Connection->db->beginTransaction();
219
+				if ($globalTransaction) {
220
+					$Connection->db->beginTransaction();
221
+				}
186 222
 				while (!feof($fh)) {
187 223
 					$line = fgetcsv($fh,9999,',');
188 224
 					if ($line[0] != '') {
@@ -193,9 +229,13 @@  discard block
 block discarded – undo
193 229
 						}
194 230
 					}
195 231
 				}
196
-				if ($globalTransaction) $Connection->db->commit();
232
+				if ($globalTransaction) {
233
+					$Connection->db->commit();
234
+				}
197 235
 			} catch(PDOException $e) {
198
-				if ($globalTransaction) $Connection->db->rollBack(); 
236
+				if ($globalTransaction) {
237
+					$Connection->db->rollBack();
238
+				}
199 239
 				return "error : ".$e->getMessage();
200 240
 			}
201 241
 		}
@@ -238,11 +278,16 @@  discard block
 block discarded – undo
238 278
 		$sth_dest = $Connection->db->prepare($query_dest);
239 279
 		$sth_dest_owner = $Connection->db->prepare($query_dest_owner);
240 280
 		try {
241
-			if ($globalTransaction) $Connection->db->beginTransaction();
281
+			if ($globalTransaction) {
282
+				$Connection->db->beginTransaction();
283
+			}
242 284
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
243 285
 			//$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']);
244
-				if ($values['UserString4'] == 'M') $type = 'military';
245
-				else $type = null;
286
+				if ($values['UserString4'] == 'M') {
287
+					$type = 'military';
288
+				} else {
289
+					$type = null;
290
+				}
246 291
 				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
247 292
 				$sth_dest->execute($query_dest_values);
248 293
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
@@ -250,7 +295,9 @@  discard block
 block discarded – undo
250 295
 				    $sth_dest_owner->execute($query_dest_owner_values);
251 296
 				}
252 297
             		}
253
-			if ($globalTransaction) $Connection->db->commit();
298
+			if ($globalTransaction) {
299
+				$Connection->db->commit();
300
+			}
254 301
 		} catch(PDOException $e) {
255 302
 			return "error : ".$e->getMessage();
256 303
 		}
@@ -287,7 +334,9 @@  discard block
 block discarded – undo
287 334
 			$Connection = new Connection();
288 335
 			$sth_dest = $Connection->db->prepare($query_dest);
289 336
 			try {
290
-				if ($globalTransaction) $Connection->db->beginTransaction();
337
+				if ($globalTransaction) {
338
+					$Connection->db->beginTransaction();
339
+				}
291 340
             			while (!feof($fh)) {
292 341
             				$values = array();
293 342
             				$line = $Common->hex2str(fgets($fh,9999));
@@ -298,7 +347,9 @@  discard block
 block discarded – undo
298 347
             				// Check if we can find ICAO, else set it to GLID
299 348
             				$aircraft_name_split = explode(' ',$aircraft_name);
300 349
             				$search_more = '';
301
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
350
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
351
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
352
+            				}
302 353
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
303 354
             				$sth_search = $Connection->db->prepare($query_search);
304 355
 					try {
@@ -311,7 +362,9 @@  discard block
 block discarded – undo
311 362
 					} catch(PDOException $e) {
312 363
 						return "error : ".$e->getMessage();
313 364
 					}
314
-					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
365
+					if (!isset($values['ICAOTypeCode'])) {
366
+						$values['ICAOTypeCode'] = 'GLID';
367
+					}
315 368
 					// Add data to db
316 369
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
317 370
 						//$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']);
@@ -320,7 +373,9 @@  discard block
 block discarded – undo
320 373
 						$sth_dest->execute($query_dest_values);
321 374
 					}
322 375
 				}
323
-				if ($globalTransaction) $Connection->db->commit();
376
+				if ($globalTransaction) {
377
+					$Connection->db->commit();
378
+				}
324 379
 			} catch(PDOException $e) {
325 380
 				return "error : ".$e->getMessage();
326 381
 			}
@@ -356,7 +411,9 @@  discard block
 block discarded – undo
356 411
 			$Connection = new Connection();
357 412
 			$sth_dest = $Connection->db->prepare($query_dest);
358 413
 			try {
359
-				if ($globalTransaction) $Connection->db->beginTransaction();
414
+				if ($globalTransaction) {
415
+					$Connection->db->beginTransaction();
416
+				}
360 417
 				$tmp = fgetcsv($fh,9999,',',"'");
361 418
             			while (!feof($fh)) {
362 419
             				$line = fgetcsv($fh,9999,',',"'");
@@ -370,13 +427,17 @@  discard block
 block discarded – undo
370 427
             				// Check if we can find ICAO, else set it to GLID
371 428
             				$aircraft_name_split = explode(' ',$aircraft_name);
372 429
             				$search_more = '';
373
-            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
430
+            				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) {
431
+            					$search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
432
+            				}
374 433
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
375 434
             				$sth_search = $Connection->db->prepare($query_search);
376 435
 					try {
377 436
                                     		$sth_search->execute();
378 437
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
379
-	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
438
+	            				if (isset($result['icao']) && $result['icao'] != '') {
439
+	            					$values['ICAOTypeCode'] = $result['icao'];
440
+	            				}
380 441
 					} catch(PDOException $e) {
381 442
 						return "error : ".$e->getMessage();
382 443
 					}
@@ -389,7 +450,9 @@  discard block
 block discarded – undo
389 450
 						$sth_dest->execute($query_dest_values);
390 451
 					}
391 452
 				}
392
-				if ($globalTransaction) $Connection->db->commit();
453
+				if ($globalTransaction) {
454
+					$Connection->db->commit();
455
+				}
393 456
 			} catch(PDOException $e) {
394 457
 				return "error : ".$e->getMessage();
395 458
 			}
@@ -428,7 +491,9 @@  discard block
 block discarded – undo
428 491
 			$sth_dest = $Connection->db->prepare($query_dest);
429 492
 			$sth_modes = $Connection->db->prepare($query_modes);
430 493
 			try {
431
-				if ($globalTransaction) $Connection->db->beginTransaction();
494
+				if ($globalTransaction) {
495
+					$Connection->db->beginTransaction();
496
+				}
432 497
 				$tmp = fgetcsv($fh,9999,',','"');
433 498
             			while (!feof($fh)) {
434 499
             				$line = fgetcsv($fh,9999,',','"');
@@ -438,16 +503,22 @@  discard block
 block discarded – undo
438 503
             				    $values['registration'] = $line[0];
439 504
             				    $values['base'] = $line[4];
440 505
             				    $values['owner'] = $line[5];
441
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
442
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
506
+            				    if ($line[6] == '') {
507
+            				    	$values['date_first_reg'] = null;
508
+            				    } else {
509
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
510
+					    }
443 511
 					    $values['cancel'] = $line[7];
444 512
 					} elseif ($country == 'EI') {
445 513
 					    // TODO : add modeS & reg to aircraft_modes
446 514
             				    $values['registration'] = $line[0];
447 515
             				    $values['base'] = $line[3];
448 516
             				    $values['owner'] = $line[2];
449
-            				    if ($line[1] == '') $values['date_first_reg'] = null;
450
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
517
+            				    if ($line[1] == '') {
518
+            				    	$values['date_first_reg'] = null;
519
+            				    } else {
520
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
521
+					    }
451 522
 					    $values['cancel'] = '';
452 523
 					    $values['modes'] = $line[7];
453 524
 					    $values['icao'] = $line[8];
@@ -466,16 +537,22 @@  discard block
 block discarded – undo
466 537
             				    $values['registration'] = $line[3];
467 538
             				    $values['base'] = null;
468 539
             				    $values['owner'] = $line[5];
469
-            				    if ($line[18] == '') $values['date_first_reg'] = null;
470
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
540
+            				    if ($line[18] == '') {
541
+            				    	$values['date_first_reg'] = null;
542
+            				    } else {
543
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
544
+					    }
471 545
 					    $values['cancel'] = '';
472 546
 					} elseif ($country == 'VH') {
473 547
 					    // TODO : add modeS & reg to aircraft_modes
474 548
             				    $values['registration'] = $line[0];
475 549
             				    $values['base'] = null;
476 550
             				    $values['owner'] = $line[12];
477
-            				    if ($line[28] == '') $values['date_first_reg'] = null;
478
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
551
+            				    if ($line[28] == '') {
552
+            				    	$values['date_first_reg'] = null;
553
+            				    } else {
554
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
555
+					    }
479 556
 
480 557
 					    $values['cancel'] = $line[39];
481 558
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -494,29 +571,41 @@  discard block
 block discarded – undo
494 571
             				    $values['registration'] = $line[0];
495 572
             				    $values['base'] = null;
496 573
             				    $values['owner'] = $line[8];
497
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
498
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
574
+            				    if ($line[7] == '') {
575
+            				    	$values['date_first_reg'] = null;
576
+            				    } else {
577
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
578
+					    }
499 579
 					    $values['cancel'] = '';
500 580
 					} elseif ($country == 'PP') {
501 581
             				    $values['registration'] = $line[0];
502 582
             				    $values['base'] = null;
503 583
             				    $values['owner'] = $line[4];
504
-            				    if ($line[6] == '') $values['date_first_reg'] = null;
505
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
584
+            				    if ($line[6] == '') {
585
+            				    	$values['date_first_reg'] = null;
586
+            				    } else {
587
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
588
+					    }
506 589
 					    $values['cancel'] = $line[7];
507 590
 					} elseif ($country == 'E7') {
508 591
             				    $values['registration'] = $line[0];
509 592
             				    $values['base'] = null;
510 593
             				    $values['owner'] = $line[4];
511
-            				    if ($line[5] == '') $values['date_first_reg'] = null;
512
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
594
+            				    if ($line[5] == '') {
595
+            				    	$values['date_first_reg'] = null;
596
+            				    } else {
597
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
598
+					    }
513 599
 					    $values['cancel'] = '';
514 600
 					} elseif ($country == '8Q') {
515 601
             				    $values['registration'] = $line[0];
516 602
             				    $values['base'] = null;
517 603
             				    $values['owner'] = $line[3];
518
-            				    if ($line[7] == '') $values['date_first_reg'] = null;
519
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
604
+            				    if ($line[7] == '') {
605
+            				    	$values['date_first_reg'] = null;
606
+            				    } else {
607
+					    	$values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
608
+					    }
520 609
 					    $values['cancel'] = '';
521 610
 					} elseif ($country == 'ZK') {
522 611
             				    $values['registration'] = $line[0];
@@ -561,7 +650,9 @@  discard block
 block discarded – undo
561 650
 						$sth_modes->execute($query_modes_values);
562 651
 					}
563 652
 				}
564
-				if ($globalTransaction) $Connection->db->commit();
653
+				if ($globalTransaction) {
654
+					$Connection->db->commit();
655
+				}
565 656
 			} catch(PDOException $e) {
566 657
 				return "error : ".$e->getMessage();
567 658
 			}
@@ -697,25 +788,45 @@  discard block
 block discarded – undo
697 788
 		    VALUES (:name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)";
698 789
 		$Connection = new Connection();
699 790
 		$sth_dest = $Connection->db->prepare($query_dest);
700
-		if ($globalTransaction) $Connection->db->beginTransaction();
791
+		if ($globalTransaction) {
792
+			$Connection->db->beginTransaction();
793
+		}
701 794
   
702 795
 		$i = 0;
703 796
 		while($row = sparql_fetch_array($result))
704 797
 		{
705 798
 			if ($i >= 1) {
706 799
 			//print_r($row);
707
-			if (!isset($row['iata'])) $row['iata'] = '';
708
-			if (!isset($row['icao'])) $row['icao'] = '';
709
-			if (!isset($row['type'])) $row['type'] = '';
710
-			if (!isset($row['altitude'])) $row['altitude'] = '';
800
+			if (!isset($row['iata'])) {
801
+				$row['iata'] = '';
802
+			}
803
+			if (!isset($row['icao'])) {
804
+				$row['icao'] = '';
805
+			}
806
+			if (!isset($row['type'])) {
807
+				$row['type'] = '';
808
+			}
809
+			if (!isset($row['altitude'])) {
810
+				$row['altitude'] = '';
811
+			}
711 812
 			if (isset($row['city_bis'])) {
712 813
 				$row['city'] = $row['city_bis'];
713 814
 			}
714
-			if (!isset($row['city'])) $row['city'] = '';
715
-			if (!isset($row['country'])) $row['country'] = '';
716
-			if (!isset($row['homepage'])) $row['homepage'] = '';
717
-			if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = '';
718
-			if (!isset($row['name'])) continue;
815
+			if (!isset($row['city'])) {
816
+				$row['city'] = '';
817
+			}
818
+			if (!isset($row['country'])) {
819
+				$row['country'] = '';
820
+			}
821
+			if (!isset($row['homepage'])) {
822
+				$row['homepage'] = '';
823
+			}
824
+			if (!isset($row['wikipedia_page'])) {
825
+				$row['wikipedia_page'] = '';
826
+			}
827
+			if (!isset($row['name'])) {
828
+				continue;
829
+			}
719 830
 			if (!isset($row['image'])) {
720 831
 				$row['image'] = '';
721 832
 				$row['image_thumb'] = '';
@@ -771,7 +882,9 @@  discard block
 block discarded – undo
771 882
 
772 883
 			$i++;
773 884
 		}
774
-		if ($globalTransaction) $Connection->db->commit();
885
+		if ($globalTransaction) {
886
+			$Connection->db->commit();
887
+		}
775 888
 		/*
776 889
 		echo "Delete duplicate rows...\n";
777 890
 		$query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)';
@@ -814,7 +927,9 @@  discard block
 block discarded – undo
814 927
 		$delimiter = ',';
815 928
 		$out_file = $tmp_dir.'airports.csv';
816 929
 		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
817
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
930
+		if (!file_exists($out_file) || !is_readable($out_file)) {
931
+			return FALSE;
932
+		}
818 933
 		echo "Add data from ourairports.com...\n";
819 934
 
820 935
 		$header = NULL;
@@ -824,8 +939,9 @@  discard block
 block discarded – undo
824 939
 			//$Connection->db->beginTransaction();
825 940
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
826 941
 			{
827
-				if(!$header) $header = $row;
828
-				else {
942
+				if(!$header) {
943
+					$header = $row;
944
+				} else {
829 945
 					$data = array();
830 946
 					$data = array_combine($header, $row);
831 947
 					try {
@@ -866,7 +982,9 @@  discard block
 block discarded – undo
866 982
 		echo "Download data from another free database...\n";
867 983
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
868 984
 		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
869
-		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
985
+		if (!file_exists($out_file) || !is_readable($out_file)) {
986
+			return FALSE;
987
+		}
870 988
 		update_db::unzip($out_file);
871 989
 		$header = NULL;
872 990
 		echo "Add data from another free database...\n";
@@ -877,8 +995,9 @@  discard block
 block discarded – undo
877 995
 			//$Connection->db->beginTransaction();
878 996
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
879 997
 			{
880
-				if(!$header) $header = $row;
881
-				else {
998
+				if(!$header) {
999
+					$header = $row;
1000
+				} else {
882 1001
 					$data = $row;
883 1002
 
884 1003
 					$query = 'UPDATE airport SET city = :city, country = :country WHERE icao = :icao';
@@ -1047,7 +1166,9 @@  discard block
 block discarded – undo
1047 1166
 		if (($handle = fopen($tmp_dir.'MASTER.txt', 'r')) !== FALSE)
1048 1167
 		{
1049 1168
 			$i = 0;
1050
-			if ($globalTransaction) $Connection->db->beginTransaction();
1169
+			if ($globalTransaction) {
1170
+				$Connection->db->beginTransaction();
1171
+			}
1051 1172
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1052 1173
 			{
1053 1174
 				if ($i > 0) {
@@ -1060,7 +1181,9 @@  discard block
 block discarded – undo
1060 1181
 					}
1061 1182
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
1062 1183
 					if (!empty($result_search)) {
1063
-						if ($globalDebug) echo '.';
1184
+						if ($globalDebug) {
1185
+							echo '.';
1186
+						}
1064 1187
 							//if ($globalDBdriver == 'mysql') {
1065 1188
 							//	$queryi = 'INSERT INTO faamfr (mfr,icao) VALUES (:mfr,:icao) ON DUPLICATE KEY UPDATE icao = :icao';
1066 1189
 							//} else {
@@ -1082,8 +1205,12 @@  discard block
 block discarded – undo
1082 1205
 						}
1083 1206
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
1084 1207
 						if (!empty($result_search_mfr)) {
1085
-							if (trim($data[16]) == '' && trim($data[23]) != '') $data[16] = $data[23];
1086
-							if (trim($data[16]) == '' && trim($data[15]) != '') $data[16] = $data[15];
1208
+							if (trim($data[16]) == '' && trim($data[23]) != '') {
1209
+								$data[16] = $data[23];
1210
+							}
1211
+							if (trim($data[16]) == '' && trim($data[15]) != '') {
1212
+								$data[16] = $data[15];
1213
+							}
1087 1214
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1088 1215
 							try {
1089 1216
 								$sthf = $Connection->db->prepare($queryf);
@@ -1094,7 +1221,9 @@  discard block
 block discarded – undo
1094 1221
 						}
1095 1222
 					}
1096 1223
 					if (strtotime($data[29]) > time()) {
1097
-						if ($globalDebug) echo 'i';
1224
+						if ($globalDebug) {
1225
+							echo 'i';
1226
+						}
1098 1227
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1099 1228
 						try {
1100 1229
 							$sth = $Connection->db->prepare($query);
@@ -1105,13 +1234,19 @@  discard block
 block discarded – undo
1105 1234
 					}
1106 1235
 				}
1107 1236
 				if ($i % 90 == 0) {
1108
-					if ($globalTransaction) $Connection->db->commit();
1109
-					if ($globalTransaction) $Connection->db->beginTransaction();
1237
+					if ($globalTransaction) {
1238
+						$Connection->db->commit();
1239
+					}
1240
+					if ($globalTransaction) {
1241
+						$Connection->db->beginTransaction();
1242
+					}
1110 1243
 				}
1111 1244
 				$i++;
1112 1245
 			}
1113 1246
 			fclose($handle);
1114
-			if ($globalTransaction) $Connection->db->commit();
1247
+			if ($globalTransaction) {
1248
+				$Connection->db->commit();
1249
+			}
1115 1250
 		}
1116 1251
 		return '';
1117 1252
 	}
@@ -1131,11 +1266,15 @@  discard block
 block discarded – undo
1131 1266
 		if (($handle = fopen($tmp_dir.'modes.tsv', 'r')) !== FALSE)
1132 1267
 		{
1133 1268
 			$i = 0;
1134
-			if ($globalTransaction) $Connection->db->beginTransaction();
1269
+			if ($globalTransaction) {
1270
+				$Connection->db->beginTransaction();
1271
+			}
1135 1272
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1136 1273
 			{
1137 1274
 				if ($i > 0) {
1138
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1275
+					if ($data[1] == 'NULL') {
1276
+						$data[1] = $data[0];
1277
+					}
1139 1278
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1140 1279
 					try {
1141 1280
 						$sth = $Connection->db->prepare($query);
@@ -1147,7 +1286,9 @@  discard block
 block discarded – undo
1147 1286
 				$i++;
1148 1287
 			}
1149 1288
 			fclose($handle);
1150
-			if ($globalTransaction) $Connection->db->commit();
1289
+			if ($globalTransaction) {
1290
+				$Connection->db->commit();
1291
+			}
1151 1292
 		}
1152 1293
 		return '';
1153 1294
 	}
@@ -1179,11 +1320,15 @@  discard block
 block discarded – undo
1179 1320
 		if (($handle = fopen($tmp_dir.'airlines.tsv', 'r')) !== FALSE)
1180 1321
 		{
1181 1322
 			$i = 0;
1182
-			if ($globalTransaction) $Connection->db->beginTransaction();
1323
+			if ($globalTransaction) {
1324
+				$Connection->db->beginTransaction();
1325
+			}
1183 1326
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1184 1327
 			{
1185 1328
 				if ($i > 0) {
1186
-					if ($data[1] == 'NULL') $data[1] = $data[0];
1329
+					if ($data[1] == 'NULL') {
1330
+						$data[1] = $data[0];
1331
+					}
1187 1332
 					$query = 'INSERT INTO airlines (airline_id,name,alias,iata,icao,callsign,country,active,type,home_link,wikipedia_link,alliance,ban_eu) VALUES (0,:name,:alias,:iata,:icao,:callsign,:country,:active,:type,:home,:wikipedia_link,:alliance,:ban_eu)';
1188 1333
 					try {
1189 1334
 						$sth = $Connection->db->prepare($query);
@@ -1195,7 +1340,9 @@  discard block
 block discarded – undo
1195 1340
 				$i++;
1196 1341
 			}
1197 1342
 			fclose($handle);
1198
-			if ($globalTransaction) $Connection->db->commit();
1343
+			if ($globalTransaction) {
1344
+				$Connection->db->commit();
1345
+			}
1199 1346
 		}
1200 1347
 		/*
1201 1348
 		$query = "UNLOCK TABLES";
@@ -1225,7 +1372,9 @@  discard block
 block discarded – undo
1225 1372
 		if (($handle = fopen($tmp_dir.'owners.tsv', 'r')) !== FALSE)
1226 1373
 		{
1227 1374
 			$i = 0;
1228
-			if ($globalTransaction) $Connection->db->beginTransaction();
1375
+			if ($globalTransaction) {
1376
+				$Connection->db->beginTransaction();
1377
+			}
1229 1378
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1230 1379
 			{
1231 1380
 				if ($i > 0) {
@@ -1241,7 +1390,9 @@  discard block
 block discarded – undo
1241 1390
 				$i++;
1242 1391
 			}
1243 1392
 			fclose($handle);
1244
-			if ($globalTransaction) $Connection->db->commit();
1393
+			if ($globalTransaction) {
1394
+				$Connection->db->commit();
1395
+			}
1245 1396
 		}
1246 1397
 		return '';
1247 1398
         }
@@ -1261,7 +1412,9 @@  discard block
 block discarded – undo
1261 1412
 		if (($handle = fopen($tmp_dir.'routes.tsv', 'r')) !== FALSE)
1262 1413
 		{
1263 1414
 			$i = 0;
1264
-			if ($globalTransaction) $Connection->db->beginTransaction();
1415
+			if ($globalTransaction) {
1416
+				$Connection->db->beginTransaction();
1417
+			}
1265 1418
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1266 1419
 			{
1267 1420
 				if ($i > 0) {
@@ -1271,19 +1424,25 @@  discard block
 block discarded – undo
1271 1424
 						$sth = $Connection->db->prepare($query);
1272 1425
 						$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'));
1273 1426
 					} catch(PDOException $e) {
1274
-						if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1427
+						if ($globalDebug) {
1428
+							echo "error: ".$e->getMessage()." - data: ".implode(',',$data);
1429
+						}
1275 1430
 						die();
1276 1431
 					}
1277 1432
 				}
1278 1433
 				if ($globalTransaction && $i % 2000 == 0) {
1279 1434
 					$Connection->db->commit();
1280
-					if ($globalDebug) echo '.';
1435
+					if ($globalDebug) {
1436
+						echo '.';
1437
+					}
1281 1438
 					$Connection->db->beginTransaction();
1282 1439
 				}
1283 1440
 				$i++;
1284 1441
 			}
1285 1442
 			fclose($handle);
1286
-			if ($globalTransaction) $Connection->db->commit();
1443
+			if ($globalTransaction) {
1444
+				$Connection->db->commit();
1445
+			}
1287 1446
 		}
1288 1447
 		return '';
1289 1448
 	}
@@ -1302,7 +1461,9 @@  discard block
 block discarded – undo
1302 1461
 		if (($handle = fopen($tmp_dir.'block.tsv', 'r')) !== FALSE)
1303 1462
 		{
1304 1463
 			$i = 0;
1305
-			if ($globalTransaction) $Connection->db->beginTransaction();
1464
+			if ($globalTransaction) {
1465
+				$Connection->db->beginTransaction();
1466
+			}
1306 1467
 			while (($data = fgets($handle, 1000)) !== FALSE)
1307 1468
 			{
1308 1469
 				$query = 'INSERT INTO aircraft_block (callSign,Source) VALUES (:callSign,:source)';
@@ -1310,18 +1471,24 @@  discard block
 block discarded – undo
1310 1471
 					$sth = $Connection->db->prepare($query);
1311 1472
 					$sth->execute(array(':callSign' => trim($data),':source' => 'website_fam'));
1312 1473
 				} catch(PDOException $e) {
1313
-					if ($globalDebug) echo "error: ".$e->getMessage()." - data: ".$data;
1474
+					if ($globalDebug) {
1475
+						echo "error: ".$e->getMessage()." - data: ".$data;
1476
+					}
1314 1477
 					die();
1315 1478
 				}
1316 1479
 				if ($globalTransaction && $i % 2000 == 0) {
1317 1480
 					$Connection->db->commit();
1318
-					if ($globalDebug) echo '.';
1481
+					if ($globalDebug) {
1482
+						echo '.';
1483
+					}
1319 1484
 					$Connection->db->beginTransaction();
1320 1485
 				}
1321 1486
 				$i++;
1322 1487
 			}
1323 1488
 			fclose($handle);
1324
-			if ($globalTransaction) $Connection->db->commit();
1489
+			if ($globalTransaction) {
1490
+				$Connection->db->commit();
1491
+			}
1325 1492
 		}
1326 1493
 		return '';
1327 1494
         }
@@ -1346,7 +1513,9 @@  discard block
 block discarded – undo
1346 1513
 			$i = 0;
1347 1514
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1348 1515
 			//$Connection->db->beginTransaction();
1349
-			if ($globalTransaction) $Connection->db->beginTransaction();
1516
+			if ($globalTransaction) {
1517
+				$Connection->db->beginTransaction();
1518
+			}
1350 1519
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1351 1520
 			{
1352 1521
 				if ($i > 0) {
@@ -1362,7 +1531,9 @@  discard block
 block discarded – undo
1362 1531
 				$i++;
1363 1532
 			}
1364 1533
 			fclose($handle);
1365
-			if ($globalTransaction) $Connection->db->commit();
1534
+			if ($globalTransaction) {
1535
+				$Connection->db->commit();
1536
+			}
1366 1537
 		}
1367 1538
 		return '';
1368 1539
         }
@@ -1382,7 +1553,9 @@  discard block
 block discarded – undo
1382 1553
 		if (($handle = fopen($tmp_dir.'satellite.tsv', 'r')) !== FALSE)
1383 1554
 		{
1384 1555
 			$i = 0;
1385
-			if ($globalTransaction) $Connection->db->beginTransaction();
1556
+			if ($globalTransaction) {
1557
+				$Connection->db->beginTransaction();
1558
+			}
1386 1559
 			while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1387 1560
 			{
1388 1561
 				if ($i > 0) {
@@ -1399,7 +1572,9 @@  discard block
 block discarded – undo
1399 1572
 				$i++;
1400 1573
 			}
1401 1574
 			fclose($handle);
1402
-			if ($globalTransaction) $Connection->db->commit();
1575
+			if ($globalTransaction) {
1576
+				$Connection->db->commit();
1577
+			}
1403 1578
 		}
1404 1579
 		return '';
1405 1580
 	}
@@ -1418,7 +1593,9 @@  discard block
 block discarded – undo
1418 1593
 		$Connection = new Connection();
1419 1594
 		if (($handle = fopen($tmp_dir.'ban_eu.csv', 'r')) !== FALSE)
1420 1595
 		{
1421
-			if ($globalTransaction) $Connection->db->beginTransaction();
1596
+			if ($globalTransaction) {
1597
+				$Connection->db->beginTransaction();
1598
+			}
1422 1599
 			while (($data = fgetcsv($handle, 1000)) !== FALSE)
1423 1600
 			{
1424 1601
 				$query = 'UPDATE airlines SET ban_eu = 1 WHERE icao = :icao AND forsource IS NULL';
@@ -1433,7 +1610,9 @@  discard block
 block discarded – undo
1433 1610
 				}
1434 1611
 			}
1435 1612
 			fclose($handle);
1436
-			if ($globalTransaction) $Connection->db->commit();
1613
+			if ($globalTransaction) {
1614
+				$Connection->db->commit();
1615
+			}
1437 1616
 		}
1438 1617
 		return '';
1439 1618
         }
@@ -1511,9 +1690,14 @@  discard block
 block discarded – undo
1511 1690
 				if ($i > 0 && $data[0] != '') {
1512 1691
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1513 1692
 					$period = str_replace(',','',$data[14]);
1514
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1515
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1516
-					else $launch_date = NULL;
1693
+					if (!empty($period) && strpos($period,'days')) {
1694
+						$period = str_replace(' days','',$period)*24*60;
1695
+					}
1696
+					if ($data[18] != '') {
1697
+						$launch_date = date('Y-m-d',strtotime($data[18]));
1698
+					} else {
1699
+						$launch_date = NULL;
1700
+					}
1517 1701
 					$data = array_map(function($value) {
1518 1702
 						return trim($value) === '' ? null : $value;
1519 1703
 					}, $data);
@@ -1876,7 +2060,9 @@  discard block
 block discarded – undo
1876 2060
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1877 2061
 		{
1878 2062
 			$i = 0;
1879
-			if ($globalTransaction) $Connection->db->beginTransaction();
2063
+			if ($globalTransaction) {
2064
+				$Connection->db->beginTransaction();
2065
+			}
1880 2066
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1881 2067
 			{
1882 2068
 				$i++;
@@ -1904,7 +2090,9 @@  discard block
 block discarded – undo
1904 2090
 				}
1905 2091
 			}
1906 2092
 			fclose($handle);
1907
-			if ($globalTransaction) $Connection->db->commit();
2093
+			if ($globalTransaction) {
2094
+				$Connection->db->commit();
2095
+			}
1908 2096
 		}
1909 2097
 		return '';
1910 2098
 	}
@@ -1947,7 +2135,9 @@  discard block
 block discarded – undo
1947 2135
 		$Connection = new Connection();
1948 2136
 		if (($handle = fopen($filename, 'r')) !== FALSE)
1949 2137
 		{
1950
-			if ($globalTransaction) $Connection->db->beginTransaction();
2138
+			if ($globalTransaction) {
2139
+				$Connection->db->beginTransaction();
2140
+			}
1951 2141
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1952 2142
 			{
1953 2143
 				if(count($row) > 1) {
@@ -1961,7 +2151,9 @@  discard block
 block discarded – undo
1961 2151
 				}
1962 2152
 			}
1963 2153
 			fclose($handle);
1964
-			if ($globalTransaction) $Connection->db->commit();
2154
+			if ($globalTransaction) {
2155
+				$Connection->db->commit();
2156
+			}
1965 2157
 		}
1966 2158
 		return '';
1967 2159
         }
@@ -1981,8 +2173,9 @@  discard block
 block discarded – undo
1981 2173
 	        }
1982 2174
 
1983 2175
 
1984
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1985
-		else {
2176
+		if ($globalDBdriver == 'mysql') {
2177
+			update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
2178
+		} else {
1986 2179
 			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1987 2180
 			$query = "CREATE EXTENSION postgis";
1988 2181
 			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
@@ -2001,7 +2194,9 @@  discard block
 block discarded – undo
2001 2194
 		global $tmp_dir, $globalDebug;
2002 2195
 		include_once('class.create_db.php');
2003 2196
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
2004
-		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
2197
+		if ($globalDebug) {
2198
+			echo "NOTAM from FlightAirMap website : Download...";
2199
+		}
2005 2200
 		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5');
2006 2201
 		$error = '';
2007 2202
 		if (file_exists($tmp_dir.'notam.txt.gz.md5')) {
@@ -2011,20 +2206,34 @@  discard block
 block discarded – undo
2011 2206
 				update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
2012 2207
 				if (file_exists($tmp_dir.'notam.txt.gz')) {
2013 2208
 					if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) {
2014
-						if ($globalDebug) echo "Gunzip...";
2209
+						if ($globalDebug) {
2210
+							echo "Gunzip...";
2211
+						}
2015 2212
 						update_db::gunzip($tmp_dir.'notam.txt.gz');
2016
-						if ($globalDebug) echo "Add to DB...";
2213
+						if ($globalDebug) {
2214
+							echo "Add to DB...";
2215
+						}
2017 2216
 						//$error = create_db::import_file($tmp_dir.'notam.sql');
2018 2217
 						$NOTAM = new NOTAM();
2019 2218
 						$NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt');
2020 2219
 						update_db::insert_notam_version($notam_md5);
2021
-					} else $error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
2022
-				} else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2023
-			} elseif ($globalDebug) echo "No new version.";
2024
-		} else $error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed.";
2220
+					} else {
2221
+						$error = "File ".$tmp_dir.'notam.txt.gz'." md5 failed. Download failed.";
2222
+					}
2223
+				} else {
2224
+					$error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed.";
2225
+				}
2226
+			} elseif ($globalDebug) {
2227
+				echo "No new version.";
2228
+			}
2229
+		} else {
2230
+			$error = "File ".$tmp_dir.'notam.txt.gz.md5'." doesn't exist. Download failed.";
2231
+		}
2025 2232
 		if ($error != '') {
2026 2233
 			return $error;
2027
-		} elseif ($globalDebug) echo "Done\n";
2234
+		} elseif ($globalDebug) {
2235
+			echo "Done\n";
2236
+		}
2028 2237
 		return '';
2029 2238
 	}
2030 2239
 
@@ -2079,68 +2288,114 @@  discard block
 block discarded – undo
2079 2288
 		//update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip');
2080 2289
 		if (extension_loaded('zip')) {
2081 2290
 			if (file_exists($tmp_dir.'ivae_feb2013.zip')) {
2082
-				if ($globalDebug) echo "Unzip...";
2291
+				if ($globalDebug) {
2292
+					echo "Unzip...";
2293
+				}
2083 2294
 				update_db::unzip($tmp_dir.'ivae_feb2013.zip');
2084
-				if ($globalDebug) echo "Add to DB...";
2295
+				if ($globalDebug) {
2296
+					echo "Add to DB...";
2297
+				}
2085 2298
 				update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
2086
-				if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2299
+				if ($globalDebug) {
2300
+					echo "Copy airlines logos to airlines images directory...";
2301
+				}
2087 2302
 				if (is_writable(dirname(__FILE__).'/../images/airlines')) {
2088
-					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2089
-				} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2090
-			} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2091
-		} else $error = "ZIP module not loaded but required for IVAO.";
2303
+					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) {
2304
+						$error = "Failed to copy airlines logo.";
2305
+					}
2306
+				} else {
2307
+					$error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2308
+				}
2309
+			} else {
2310
+				$error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2311
+			}
2312
+		} else {
2313
+			$error = "ZIP module not loaded but required for IVAO.";
2314
+		}
2092 2315
 		if ($error != '') {
2093 2316
 			return $error;
2094
-		} elseif ($globalDebug) echo "Done\n";
2317
+		} elseif ($globalDebug) {
2318
+			echo "Done\n";
2319
+		}
2095 2320
 		return '';
2096 2321
 	}
2097 2322
 
2098 2323
 	public static function update_routes() {
2099 2324
 		global $tmp_dir, $globalDebug;
2100 2325
 		$error = '';
2101
-		if ($globalDebug) echo "Routes : Download...";
2326
+		if ($globalDebug) {
2327
+			echo "Routes : Download...";
2328
+		}
2102 2329
 		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
2103 2330
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
2104
-			if ($globalDebug) echo "Gunzip...";
2331
+			if ($globalDebug) {
2332
+				echo "Gunzip...";
2333
+			}
2105 2334
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
2106
-			if ($globalDebug) echo "Add to DB...";
2335
+			if ($globalDebug) {
2336
+				echo "Add to DB...";
2337
+			}
2107 2338
 			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
2108
-		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2339
+		} else {
2340
+			$error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
2341
+		}
2109 2342
 		if ($error != '') {
2110 2343
 			return $error;
2111
-		} elseif ($globalDebug) echo "Done\n";
2344
+		} elseif ($globalDebug) {
2345
+			echo "Done\n";
2346
+		}
2112 2347
 		return '';
2113 2348
 	}
2114 2349
 	public static function update_oneworld() {
2115 2350
 		global $tmp_dir, $globalDebug;
2116 2351
 		$error = '';
2117
-		if ($globalDebug) echo "Schedules Oneworld : Download...";
2352
+		if ($globalDebug) {
2353
+			echo "Schedules Oneworld : Download...";
2354
+		}
2118 2355
 		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
2119 2356
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
2120
-			if ($globalDebug) echo "Gunzip...";
2357
+			if ($globalDebug) {
2358
+				echo "Gunzip...";
2359
+			}
2121 2360
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
2122
-			if ($globalDebug) echo "Add to DB...";
2361
+			if ($globalDebug) {
2362
+				echo "Add to DB...";
2363
+			}
2123 2364
 			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
2124
-		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2365
+		} else {
2366
+			$error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
2367
+		}
2125 2368
 		if ($error != '') {
2126 2369
 			return $error;
2127
-		} elseif ($globalDebug) echo "Done\n";
2370
+		} elseif ($globalDebug) {
2371
+			echo "Done\n";
2372
+		}
2128 2373
 		return '';
2129 2374
 	}
2130 2375
 	public static function update_skyteam() {
2131 2376
 		global $tmp_dir, $globalDebug;
2132 2377
 		$error = '';
2133
-		if ($globalDebug) echo "Schedules Skyteam : Download...";
2378
+		if ($globalDebug) {
2379
+			echo "Schedules Skyteam : Download...";
2380
+		}
2134 2381
 		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
2135 2382
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
2136
-			if ($globalDebug) echo "Gunzip...";
2383
+			if ($globalDebug) {
2384
+				echo "Gunzip...";
2385
+			}
2137 2386
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
2138
-			if ($globalDebug) echo "Add to DB...";
2387
+			if ($globalDebug) {
2388
+				echo "Add to DB...";
2389
+			}
2139 2390
 			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
2140
-		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2391
+		} else {
2392
+			$error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
2393
+		}
2141 2394
 		if ($error != '') {
2142 2395
 			return $error;
2143
-		} elseif ($globalDebug) echo "Done\n";
2396
+		} elseif ($globalDebug) {
2397
+			echo "Done\n";
2398
+		}
2144 2399
 		return '';
2145 2400
 	}
2146 2401
 	public static function update_ModeS() {
@@ -2157,340 +2412,590 @@  discard block
 block discarded – undo
2157 2412
 			exit;
2158 2413
 		} elseif ($globalDebug) echo "Done\n";
2159 2414
 */
2160
-		if ($globalDebug) echo "Modes : Download...";
2161
-//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2415
+		if ($globalDebug) {
2416
+			echo "Modes : Download...";
2417
+		}
2418
+		//		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2162 2419
 		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2163 2420
 
2164 2421
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2165 2422
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
2166
-			if ($globalDebug) echo "Unzip...";
2167
-//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2423
+			if ($globalDebug) {
2424
+				echo "Unzip...";
2425
+			}
2426
+			//			update_db::unzip($tmp_dir.'basestation_latest.zip');
2168 2427
 			update_db::gunzip($tmp_dir.'BaseStation.sqb.gz');
2169
-			if ($globalDebug) echo "Add to DB...";
2428
+			if ($globalDebug) {
2429
+				echo "Add to DB...";
2430
+			}
2170 2431
 			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
2171 2432
 //			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'basestation.sqb');
2172
-		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2433
+		} else {
2434
+			$error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
2435
+		}
2173 2436
 		if ($error != '') {
2174 2437
 			return $error;
2175
-		} elseif ($globalDebug) echo "Done\n";
2438
+		} elseif ($globalDebug) {
2439
+			echo "Done\n";
2440
+		}
2176 2441
 		return '';
2177 2442
 	}
2178 2443
 
2179 2444
 	public static function update_ModeS_faa() {
2180 2445
 		global $tmp_dir, $globalDebug;
2181
-		if ($globalDebug) echo "Modes FAA: Download...";
2446
+		if ($globalDebug) {
2447
+			echo "Modes FAA: Download...";
2448
+		}
2182 2449
 		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2183 2450
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2184
-			if ($globalDebug) echo "Unzip...";
2451
+			if ($globalDebug) {
2452
+				echo "Unzip...";
2453
+			}
2185 2454
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
2186
-			if ($globalDebug) echo "Add to DB...";
2455
+			if ($globalDebug) {
2456
+				echo "Add to DB...";
2457
+			}
2187 2458
 			$error = update_db::modes_faa();
2188
-		} else $error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2459
+		} else {
2460
+			$error = "File ".$tmp_dir.'ReleasableAircraft.zip'." doesn't exist. Download failed.";
2461
+		}
2189 2462
 		if ($error != '') {
2190 2463
 			return $error;
2191
-		} elseif ($globalDebug) echo "Done\n";
2464
+		} elseif ($globalDebug) {
2465
+			echo "Done\n";
2466
+		}
2192 2467
 		return '';
2193 2468
 	}
2194 2469
 
2195 2470
 	public static function update_ModeS_flarm() {
2196 2471
 		global $tmp_dir, $globalDebug;
2197
-		if ($globalDebug) echo "Modes Flarmnet: Download...";
2472
+		if ($globalDebug) {
2473
+			echo "Modes Flarmnet: Download...";
2474
+		}
2198 2475
 		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2199 2476
 		if (file_exists($tmp_dir.'data.fln')) {
2200
-			if ($globalDebug) echo "Add to DB...";
2477
+			if ($globalDebug) {
2478
+				echo "Add to DB...";
2479
+			}
2201 2480
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
2202
-		} else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2481
+		} else {
2482
+			$error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed.";
2483
+		}
2203 2484
 		if ($error != '') {
2204 2485
 			return $error;
2205
-		} elseif ($globalDebug) echo "Done\n";
2486
+		} elseif ($globalDebug) {
2487
+			echo "Done\n";
2488
+		}
2206 2489
 		return '';
2207 2490
 	}
2208 2491
 
2209 2492
 	public static function update_ModeS_ogn() {
2210 2493
 		global $tmp_dir, $globalDebug;
2211
-		if ($globalDebug) echo "Modes OGN: Download...";
2494
+		if ($globalDebug) {
2495
+			echo "Modes OGN: Download...";
2496
+		}
2212 2497
 		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2213 2498
 		if (file_exists($tmp_dir.'ogn.csv')) {
2214
-			if ($globalDebug) echo "Add to DB...";
2499
+			if ($globalDebug) {
2500
+				echo "Add to DB...";
2501
+			}
2215 2502
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
2216
-		} else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2503
+		} else {
2504
+			$error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed.";
2505
+		}
2217 2506
 		if ($error != '') {
2218 2507
 			return $error;
2219
-		} elseif ($globalDebug) echo "Done\n";
2508
+		} elseif ($globalDebug) {
2509
+			echo "Done\n";
2510
+		}
2220 2511
 		return '';
2221 2512
 	}
2222 2513
 
2223 2514
 	public static function update_owner() {
2224 2515
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2225 2516
 		
2226
-		if ($globalDebug) echo "Owner France: Download...";
2517
+		if ($globalDebug) {
2518
+			echo "Owner France: Download...";
2519
+		}
2227 2520
 		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2228 2521
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2229
-			if ($globalDebug) echo "Add to DB...";
2522
+			if ($globalDebug) {
2523
+				echo "Add to DB...";
2524
+			}
2230 2525
 			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2231
-		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2526
+		} else {
2527
+			$error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2528
+		}
2232 2529
 		if ($error != '') {
2233 2530
 			return $error;
2234
-		} elseif ($globalDebug) echo "Done\n";
2531
+		} elseif ($globalDebug) {
2532
+			echo "Done\n";
2533
+		}
2235 2534
 		
2236
-		if ($globalDebug) echo "Owner Ireland: Download...";
2535
+		if ($globalDebug) {
2536
+			echo "Owner Ireland: Download...";
2537
+		}
2237 2538
 		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2238 2539
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2239
-			if ($globalDebug) echo "Add to DB...";
2540
+			if ($globalDebug) {
2541
+				echo "Add to DB...";
2542
+			}
2240 2543
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2241
-		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2544
+		} else {
2545
+			$error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2546
+		}
2242 2547
 		if ($error != '') {
2243 2548
 			return $error;
2244
-		} elseif ($globalDebug) echo "Done\n";
2245
-		if ($globalDebug) echo "Owner Switzerland: Download...";
2549
+		} elseif ($globalDebug) {
2550
+			echo "Done\n";
2551
+		}
2552
+		if ($globalDebug) {
2553
+			echo "Owner Switzerland: Download...";
2554
+		}
2246 2555
 		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2247 2556
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2248
-			if ($globalDebug) echo "Add to DB...";
2557
+			if ($globalDebug) {
2558
+				echo "Add to DB...";
2559
+			}
2249 2560
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2250
-		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2561
+		} else {
2562
+			$error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2563
+		}
2251 2564
 		if ($error != '') {
2252 2565
 			return $error;
2253
-		} elseif ($globalDebug) echo "Done\n";
2254
-		if ($globalDebug) echo "Owner Czech Republic: Download...";
2566
+		} elseif ($globalDebug) {
2567
+			echo "Done\n";
2568
+		}
2569
+		if ($globalDebug) {
2570
+			echo "Owner Czech Republic: Download...";
2571
+		}
2255 2572
 		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2256 2573
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2257
-			if ($globalDebug) echo "Add to DB...";
2574
+			if ($globalDebug) {
2575
+				echo "Add to DB...";
2576
+			}
2258 2577
 			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2259
-		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2578
+		} else {
2579
+			$error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2580
+		}
2260 2581
 		if ($error != '') {
2261 2582
 			return $error;
2262
-		} elseif ($globalDebug) echo "Done\n";
2263
-		if ($globalDebug) echo "Owner Australia: Download...";
2583
+		} elseif ($globalDebug) {
2584
+			echo "Done\n";
2585
+		}
2586
+		if ($globalDebug) {
2587
+			echo "Owner Australia: Download...";
2588
+		}
2264 2589
 		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2265 2590
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2266
-			if ($globalDebug) echo "Add to DB...";
2591
+			if ($globalDebug) {
2592
+				echo "Add to DB...";
2593
+			}
2267 2594
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2268
-		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2595
+		} else {
2596
+			$error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2597
+		}
2269 2598
 		if ($error != '') {
2270 2599
 			return $error;
2271
-		} elseif ($globalDebug) echo "Done\n";
2272
-		if ($globalDebug) echo "Owner Austria: Download...";
2600
+		} elseif ($globalDebug) {
2601
+			echo "Done\n";
2602
+		}
2603
+		if ($globalDebug) {
2604
+			echo "Owner Austria: Download...";
2605
+		}
2273 2606
 		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2274 2607
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2275
-			if ($globalDebug) echo "Add to DB...";
2608
+			if ($globalDebug) {
2609
+				echo "Add to DB...";
2610
+			}
2276 2611
 			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2277
-		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2612
+		} else {
2613
+			$error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2614
+		}
2278 2615
 		if ($error != '') {
2279 2616
 			return $error;
2280
-		} elseif ($globalDebug) echo "Done\n";
2281
-		if ($globalDebug) echo "Owner Chile: Download...";
2617
+		} elseif ($globalDebug) {
2618
+			echo "Done\n";
2619
+		}
2620
+		if ($globalDebug) {
2621
+			echo "Owner Chile: Download...";
2622
+		}
2282 2623
 		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2283 2624
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2284
-			if ($globalDebug) echo "Add to DB...";
2625
+			if ($globalDebug) {
2626
+				echo "Add to DB...";
2627
+			}
2285 2628
 			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2286
-		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2629
+		} else {
2630
+			$error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2631
+		}
2287 2632
 		if ($error != '') {
2288 2633
 			return $error;
2289
-		} elseif ($globalDebug) echo "Done\n";
2290
-		if ($globalDebug) echo "Owner Colombia: Download...";
2634
+		} elseif ($globalDebug) {
2635
+			echo "Done\n";
2636
+		}
2637
+		if ($globalDebug) {
2638
+			echo "Owner Colombia: Download...";
2639
+		}
2291 2640
 		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2292 2641
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2293
-			if ($globalDebug) echo "Add to DB...";
2642
+			if ($globalDebug) {
2643
+				echo "Add to DB...";
2644
+			}
2294 2645
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2295
-		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2646
+		} else {
2647
+			$error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2648
+		}
2296 2649
 		if ($error != '') {
2297 2650
 			return $error;
2298
-		} elseif ($globalDebug) echo "Done\n";
2299
-		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2651
+		} elseif ($globalDebug) {
2652
+			echo "Done\n";
2653
+		}
2654
+		if ($globalDebug) {
2655
+			echo "Owner Bosnia Herzegobina: Download...";
2656
+		}
2300 2657
 		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2301 2658
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2302
-			if ($globalDebug) echo "Add to DB...";
2659
+			if ($globalDebug) {
2660
+				echo "Add to DB...";
2661
+			}
2303 2662
 			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2304
-		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2663
+		} else {
2664
+			$error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2665
+		}
2305 2666
 		if ($error != '') {
2306 2667
 			return $error;
2307
-		} elseif ($globalDebug) echo "Done\n";
2308
-		if ($globalDebug) echo "Owner Brazil: Download...";
2668
+		} elseif ($globalDebug) {
2669
+			echo "Done\n";
2670
+		}
2671
+		if ($globalDebug) {
2672
+			echo "Owner Brazil: Download...";
2673
+		}
2309 2674
 		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2310 2675
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2311
-			if ($globalDebug) echo "Add to DB...";
2676
+			if ($globalDebug) {
2677
+				echo "Add to DB...";
2678
+			}
2312 2679
 			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2313
-		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2680
+		} else {
2681
+			$error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2682
+		}
2314 2683
 		if ($error != '') {
2315 2684
 			return $error;
2316
-		} elseif ($globalDebug) echo "Done\n";
2317
-		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2685
+		} elseif ($globalDebug) {
2686
+			echo "Done\n";
2687
+		}
2688
+		if ($globalDebug) {
2689
+			echo "Owner Cayman Islands: Download...";
2690
+		}
2318 2691
 		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2319 2692
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2320
-			if ($globalDebug) echo "Add to DB...";
2693
+			if ($globalDebug) {
2694
+				echo "Add to DB...";
2695
+			}
2321 2696
 			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2322
-		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2697
+		} else {
2698
+			$error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2699
+		}
2323 2700
 		if ($error != '') {
2324 2701
 			return $error;
2325
-		} elseif ($globalDebug) echo "Done\n";
2326
-		if ($globalDebug) echo "Owner Croatia: Download...";
2702
+		} elseif ($globalDebug) {
2703
+			echo "Done\n";
2704
+		}
2705
+		if ($globalDebug) {
2706
+			echo "Owner Croatia: Download...";
2707
+		}
2327 2708
 		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2328 2709
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2329
-			if ($globalDebug) echo "Add to DB...";
2710
+			if ($globalDebug) {
2711
+				echo "Add to DB...";
2712
+			}
2330 2713
 			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2331
-		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2714
+		} else {
2715
+			$error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2716
+		}
2332 2717
 		if ($error != '') {
2333 2718
 			return $error;
2334
-		} elseif ($globalDebug) echo "Done\n";
2335
-		if ($globalDebug) echo "Owner Luxembourg: Download...";
2719
+		} elseif ($globalDebug) {
2720
+			echo "Done\n";
2721
+		}
2722
+		if ($globalDebug) {
2723
+			echo "Owner Luxembourg: Download...";
2724
+		}
2336 2725
 		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2337 2726
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2338
-			if ($globalDebug) echo "Add to DB...";
2727
+			if ($globalDebug) {
2728
+				echo "Add to DB...";
2729
+			}
2339 2730
 			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2340
-		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2731
+		} else {
2732
+			$error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2733
+		}
2341 2734
 		if ($error != '') {
2342 2735
 			return $error;
2343
-		} elseif ($globalDebug) echo "Done\n";
2344
-		if ($globalDebug) echo "Owner Maldives: Download...";
2736
+		} elseif ($globalDebug) {
2737
+			echo "Done\n";
2738
+		}
2739
+		if ($globalDebug) {
2740
+			echo "Owner Maldives: Download...";
2741
+		}
2345 2742
 		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2346 2743
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2347
-			if ($globalDebug) echo "Add to DB...";
2744
+			if ($globalDebug) {
2745
+				echo "Add to DB...";
2746
+			}
2348 2747
 			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2349
-		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2748
+		} else {
2749
+			$error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2750
+		}
2350 2751
 		if ($error != '') {
2351 2752
 			return $error;
2352
-		} elseif ($globalDebug) echo "Done\n";
2353
-		if ($globalDebug) echo "Owner New Zealand: Download...";
2753
+		} elseif ($globalDebug) {
2754
+			echo "Done\n";
2755
+		}
2756
+		if ($globalDebug) {
2757
+			echo "Owner New Zealand: Download...";
2758
+		}
2354 2759
 		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2355 2760
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2356
-			if ($globalDebug) echo "Add to DB...";
2761
+			if ($globalDebug) {
2762
+				echo "Add to DB...";
2763
+			}
2357 2764
 			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2358
-		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2765
+		} else {
2766
+			$error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2767
+		}
2359 2768
 		if ($error != '') {
2360 2769
 			return $error;
2361
-		} elseif ($globalDebug) echo "Done\n";
2362
-		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2770
+		} elseif ($globalDebug) {
2771
+			echo "Done\n";
2772
+		}
2773
+		if ($globalDebug) {
2774
+			echo "Owner Papua New Guinea: Download...";
2775
+		}
2363 2776
 		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2364 2777
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2365
-			if ($globalDebug) echo "Add to DB...";
2778
+			if ($globalDebug) {
2779
+				echo "Add to DB...";
2780
+			}
2366 2781
 			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2367
-		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2782
+		} else {
2783
+			$error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2784
+		}
2368 2785
 		if ($error != '') {
2369 2786
 			return $error;
2370
-		} elseif ($globalDebug) echo "Done\n";
2371
-		if ($globalDebug) echo "Owner Slovakia: Download...";
2787
+		} elseif ($globalDebug) {
2788
+			echo "Done\n";
2789
+		}
2790
+		if ($globalDebug) {
2791
+			echo "Owner Slovakia: Download...";
2792
+		}
2372 2793
 		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2373 2794
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2374
-			if ($globalDebug) echo "Add to DB...";
2795
+			if ($globalDebug) {
2796
+				echo "Add to DB...";
2797
+			}
2375 2798
 			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2376
-		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2799
+		} else {
2800
+			$error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2801
+		}
2377 2802
 		if ($error != '') {
2378 2803
 			return $error;
2379
-		} elseif ($globalDebug) echo "Done\n";
2380
-		if ($globalDebug) echo "Owner Ecuador: Download...";
2804
+		} elseif ($globalDebug) {
2805
+			echo "Done\n";
2806
+		}
2807
+		if ($globalDebug) {
2808
+			echo "Owner Ecuador: Download...";
2809
+		}
2381 2810
 		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2382 2811
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2383
-			if ($globalDebug) echo "Add to DB...";
2812
+			if ($globalDebug) {
2813
+				echo "Add to DB...";
2814
+			}
2384 2815
 			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2385
-		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2816
+		} else {
2817
+			$error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2818
+		}
2386 2819
 		if ($error != '') {
2387 2820
 			return $error;
2388
-		} elseif ($globalDebug) echo "Done\n";
2389
-		if ($globalDebug) echo "Owner Iceland: Download...";
2821
+		} elseif ($globalDebug) {
2822
+			echo "Done\n";
2823
+		}
2824
+		if ($globalDebug) {
2825
+			echo "Owner Iceland: Download...";
2826
+		}
2390 2827
 		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2391 2828
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2392
-			if ($globalDebug) echo "Add to DB...";
2829
+			if ($globalDebug) {
2830
+				echo "Add to DB...";
2831
+			}
2393 2832
 			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2394
-		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2833
+		} else {
2834
+			$error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2835
+		}
2395 2836
 		if ($error != '') {
2396 2837
 			return $error;
2397
-		} elseif ($globalDebug) echo "Done\n";
2398
-		if ($globalDebug) echo "Owner Isle of Man: Download...";
2838
+		} elseif ($globalDebug) {
2839
+			echo "Done\n";
2840
+		}
2841
+		if ($globalDebug) {
2842
+			echo "Owner Isle of Man: Download...";
2843
+		}
2399 2844
 		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2400 2845
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2401
-			if ($globalDebug) echo "Add to DB...";
2846
+			if ($globalDebug) {
2847
+				echo "Add to DB...";
2848
+			}
2402 2849
 			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2403
-		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2850
+		} else {
2851
+			$error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2852
+		}
2404 2853
 		if ($error != '') {
2405 2854
 			return $error;
2406
-		} elseif ($globalDebug) echo "Done\n";
2855
+		} elseif ($globalDebug) {
2856
+			echo "Done\n";
2857
+		}
2407 2858
 		if ($globalMasterSource) {
2408
-			if ($globalDebug) echo "ModeS Netherlands: Download...";
2859
+			if ($globalDebug) {
2860
+				echo "ModeS Netherlands: Download...";
2861
+			}
2409 2862
 			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2410 2863
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2411
-				if ($globalDebug) echo "Add to DB...";
2864
+				if ($globalDebug) {
2865
+					echo "Add to DB...";
2866
+				}
2412 2867
 				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2413
-			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2868
+			} else {
2869
+				$error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2870
+			}
2414 2871
 			if ($error != '') {
2415 2872
 				return $error;
2416
-			} elseif ($globalDebug) echo "Done\n";
2417
-			if ($globalDebug) echo "ModeS Denmark: Download...";
2873
+			} elseif ($globalDebug) {
2874
+				echo "Done\n";
2875
+			}
2876
+			if ($globalDebug) {
2877
+				echo "ModeS Denmark: Download...";
2878
+			}
2418 2879
 			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2419 2880
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2420
-				if ($globalDebug) echo "Add to DB...";
2881
+				if ($globalDebug) {
2882
+					echo "Add to DB...";
2883
+				}
2421 2884
 				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2422
-			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2885
+			} else {
2886
+				$error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2887
+			}
2423 2888
 			if ($error != '') {
2424 2889
 				return $error;
2425
-			} elseif ($globalDebug) echo "Done\n";
2426
-		} elseif ($globalDebug) echo "Done\n";
2890
+			} elseif ($globalDebug) {
2891
+				echo "Done\n";
2892
+			}
2893
+		} elseif ($globalDebug) {
2894
+			echo "Done\n";
2895
+		}
2427 2896
 		return '';
2428 2897
 	}
2429 2898
 
2430 2899
 	public static function update_translation() {
2431 2900
 		global $tmp_dir, $globalDebug;
2432 2901
 		$error = '';
2433
-		if ($globalDebug) echo "Translation : Download...";
2902
+		if ($globalDebug) {
2903
+			echo "Translation : Download...";
2904
+		}
2434 2905
 		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2435 2906
 		if (file_exists($tmp_dir.'translation.zip')) {
2436
-			if ($globalDebug) echo "Unzip...";
2907
+			if ($globalDebug) {
2908
+				echo "Unzip...";
2909
+			}
2437 2910
 			update_db::unzip($tmp_dir.'translation.zip');
2438
-			if ($globalDebug) echo "Add to DB...";
2911
+			if ($globalDebug) {
2912
+				echo "Add to DB...";
2913
+			}
2439 2914
 			$error = update_db::translation();
2440
-		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2915
+		} else {
2916
+			$error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
2917
+		}
2441 2918
 		if ($error != '') {
2442 2919
 			return $error;
2443
-		} elseif ($globalDebug) echo "Done\n";
2920
+		} elseif ($globalDebug) {
2921
+			echo "Done\n";
2922
+		}
2444 2923
 		return '';
2445 2924
 	}
2446 2925
 
2447 2926
 	public static function update_translation_fam() {
2448 2927
 		global $tmp_dir, $globalDebug;
2449 2928
 		$error = '';
2450
-		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2929
+		if ($globalDebug) {
2930
+			echo "Translation from FlightAirMap website : Download...";
2931
+		}
2451 2932
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2452 2933
 		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5');
2453 2934
 		if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) {
2454 2935
 			$translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2455 2936
 			$translation_md5 = $translation_md5_file[0];
2456 2937
 			if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) {
2457
-				if ($globalDebug) echo "Gunzip...";
2938
+				if ($globalDebug) {
2939
+					echo "Gunzip...";
2940
+				}
2458 2941
 				update_db::gunzip($tmp_dir.'translation.tsv.gz');
2459
-				if ($globalDebug) echo "Add to DB...";
2942
+				if ($globalDebug) {
2943
+					echo "Add to DB...";
2944
+				}
2460 2945
 				$error = update_db::translation_fam();
2461
-			} else $error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2462
-		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2946
+			} else {
2947
+				$error = "File ".$tmp_dir.'translation.tsv.gz'." md5 failed. Download failed.";
2948
+			}
2949
+		} else {
2950
+			$error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
2951
+		}
2463 2952
 		if ($error != '') {
2464 2953
 			return $error;
2465
-		} elseif ($globalDebug) echo "Done\n";
2954
+		} elseif ($globalDebug) {
2955
+			echo "Done\n";
2956
+		}
2466 2957
 		return '';
2467 2958
 	}
2468 2959
 	public static function update_ModeS_fam() {
2469 2960
 		global $tmp_dir, $globalDebug;
2470 2961
 		$error = '';
2471
-		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2962
+		if ($globalDebug) {
2963
+			echo "ModeS from FlightAirMap website : Download...";
2964
+		}
2472 2965
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2473 2966
 		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5');
2474 2967
 		if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) {
2475 2968
 			$modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2476 2969
 			$modes_md5 = $modes_md5_file[0];
2477 2970
 			if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) {
2478
-				if ($globalDebug) echo "Gunzip...";
2971
+				if ($globalDebug) {
2972
+					echo "Gunzip...";
2973
+				}
2479 2974
 				update_db::gunzip($tmp_dir.'modes.tsv.gz');
2480
-				if ($globalDebug) echo "Add to DB...";
2975
+				if ($globalDebug) {
2976
+					echo "Add to DB...";
2977
+				}
2481 2978
 				$error = update_db::modes_fam();
2482
-			} else $error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
2483
-		} else $error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2979
+			} else {
2980
+				$error = "File ".$tmp_dir.'modes.tsv.gz'." md5 failed. Download failed.";
2981
+			}
2982
+		} else {
2983
+			$error = "File ".$tmp_dir.'modes.tsv.gz'." doesn't exist. Download failed.";
2984
+		}
2484 2985
 		if ($error != '') {
2485 2986
 			return $error;
2486
-		} elseif ($globalDebug) echo "Done\n";
2987
+		} elseif ($globalDebug) {
2988
+			echo "Done\n";
2989
+		}
2487 2990
 		return '';
2488 2991
 	}
2489 2992
 
2490 2993
 	public static function update_airlines_fam() {
2491 2994
 		global $tmp_dir, $globalDebug;
2492 2995
 		$error = '';
2493
-		if ($globalDebug) echo "Airlines from FlightAirMap website : Download...";
2996
+		if ($globalDebug) {
2997
+			echo "Airlines from FlightAirMap website : Download...";
2998
+		}
2494 2999
 		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5');
2495 3000
 		if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) {
2496 3001
 			$airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
@@ -2499,26 +3004,42 @@  discard block
 block discarded – undo
2499 3004
 				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz');
2500 3005
 				if (file_exists($tmp_dir.'airlines.tsv.gz')) {
2501 3006
 					if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) {
2502
-						if ($globalDebug) echo "Gunzip...";
3007
+						if ($globalDebug) {
3008
+							echo "Gunzip...";
3009
+						}
2503 3010
 						update_db::gunzip($tmp_dir.'airlines.tsv.gz');
2504
-						if ($globalDebug) echo "Add to DB...";
3011
+						if ($globalDebug) {
3012
+							echo "Add to DB...";
3013
+						}
2505 3014
 						$error = update_db::airlines_fam();
2506 3015
 						update_db::insert_airlines_version($airlines_md5);
2507
-					} else $error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
2508
-			    } else $error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
2509
-			} elseif ($globalDebug) echo "No update.";
2510
-		} else $error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
3016
+					} else {
3017
+						$error = "File ".$tmp_dir.'airlines.tsv.gz'." md5 failed. Download failed.";
3018
+					}
3019
+			    } else {
3020
+			    	$error = "File ".$tmp_dir.'airlines.tsv.gz'." doesn't exist. Download failed.";
3021
+			    }
3022
+			} elseif ($globalDebug) {
3023
+				echo "No update.";
3024
+			}
3025
+		} else {
3026
+			$error = "File ".$tmp_dir.'airlines.tsv.gz.md5'." doesn't exist. Download failed.";
3027
+		}
2511 3028
 		if ($error != '') {
2512 3029
 			return $error;
2513 3030
 		} else {
2514
-			if ($globalDebug) echo "Done\n";
3031
+			if ($globalDebug) {
3032
+				echo "Done\n";
3033
+			}
2515 3034
 		}
2516 3035
 		return '';
2517 3036
 	}
2518 3037
 
2519 3038
 	public static function update_owner_fam() {
2520 3039
 		global $tmp_dir, $globalDebug, $globalOwner;
2521
-		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
3040
+		if ($globalDebug) {
3041
+			echo "owner from FlightAirMap website : Download...";
3042
+		}
2522 3043
 		$error = '';
2523 3044
 		if ($globalOwner === TRUE) {
2524 3045
 			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
@@ -2531,55 +3052,89 @@  discard block
 block discarded – undo
2531 3052
 			$owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2532 3053
 			$owners_md5 = $owners_md5_file[0];
2533 3054
 			if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) {
2534
-				if ($globalDebug) echo "Gunzip...";
3055
+				if ($globalDebug) {
3056
+					echo "Gunzip...";
3057
+				}
2535 3058
 				update_db::gunzip($tmp_dir.'owners.tsv.gz');
2536
-				if ($globalDebug) echo "Add to DB...";
3059
+				if ($globalDebug) {
3060
+					echo "Add to DB...";
3061
+				}
2537 3062
 				$error = update_db::owner_fam();
2538
-			} else $error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
2539
-		} else $error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
3063
+			} else {
3064
+				$error = "File ".$tmp_dir.'owners.tsv.gz'." md5 failed. Download failed.";
3065
+			}
3066
+		} else {
3067
+			$error = "File ".$tmp_dir.'owners.tsv.gz'." doesn't exist. Download failed.";
3068
+		}
2540 3069
 		if ($error != '') {
2541 3070
 			return $error;
2542
-		} elseif ($globalDebug) echo "Done\n";
3071
+		} elseif ($globalDebug) {
3072
+			echo "Done\n";
3073
+		}
2543 3074
 		return '';
2544 3075
 	}
2545 3076
 	public static function update_routes_fam() {
2546 3077
 		global $tmp_dir, $globalDebug;
2547
-		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
3078
+		if ($globalDebug) {
3079
+			echo "Routes from FlightAirMap website : Download...";
3080
+		}
2548 3081
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2549 3082
 		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5');
2550 3083
 		if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) {
2551 3084
 			$routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2552 3085
 			$routes_md5 = $routes_md5_file[0];
2553 3086
 			if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) {
2554
-				if ($globalDebug) echo "Gunzip...";
3087
+				if ($globalDebug) {
3088
+					echo "Gunzip...";
3089
+				}
2555 3090
 				update_db::gunzip($tmp_dir.'routes.tsv.gz');
2556
-				if ($globalDebug) echo "Add to DB...";
3091
+				if ($globalDebug) {
3092
+					echo "Add to DB...";
3093
+				}
2557 3094
 				$error = update_db::routes_fam();
2558
-			} else $error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
2559
-		} else $error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
3095
+			} else {
3096
+				$error = "File ".$tmp_dir.'routes.tsv.gz'." md5 failed. Download failed.";
3097
+			}
3098
+		} else {
3099
+			$error = "File ".$tmp_dir.'routes.tsv.gz'." doesn't exist. Download failed.";
3100
+		}
2560 3101
 		if ($error != '') {
2561 3102
 			return $error;
2562
-		} elseif ($globalDebug) echo "Done\n";
3103
+		} elseif ($globalDebug) {
3104
+			echo "Done\n";
3105
+		}
2563 3106
 		return '';
2564 3107
 	}
2565 3108
 	public static function update_block_fam() {
2566 3109
 		global $tmp_dir, $globalDebug;
2567
-		if ($globalDebug) echo "Blocked aircraft from FlightAirMap website : Download...";
3110
+		if ($globalDebug) {
3111
+			echo "Blocked aircraft from FlightAirMap website : Download...";
3112
+		}
2568 3113
 		update_db::download('http://data.flightairmap.com/data/block.tsv.gz',$tmp_dir.'block.tsv.gz');
2569 3114
 		update_db::download('http://data.flightairmap.com/data/block.tsv.gz.md5',$tmp_dir.'block.tsv.gz.md5');
2570 3115
 		if (file_exists($tmp_dir.'block.tsv.gz') && file_exists($tmp_dir.'block.tsv.gz.md5')) {
2571 3116
 			$block_md5_file = explode(' ',file_get_contents($tmp_dir.'block.tsv.gz.md5'));
2572 3117
 			$block_md5 = $block_md5_file[0];
2573 3118
 			if (md5_file($tmp_dir.'block.tsv.gz') == $block_md5) {
2574
-				if ($globalDebug) echo "Gunzip...";
3119
+				if ($globalDebug) {
3120
+					echo "Gunzip...";
3121
+				}
2575 3122
 				update_db::gunzip($tmp_dir.'block.tsv.gz');
2576
-				if ($globalDebug) echo "Add to DB...";
3123
+				if ($globalDebug) {
3124
+					echo "Add to DB...";
3125
+				}
2577 3126
 				$error = update_db::block_fam();
2578
-			} else $error = "File ".$tmp_dir.'block.tsv.gz'." md5 failed. Download failed.";
2579
-		} else $error = "File ".$tmp_dir.'block.tsv.gz'." doesn't exist. Download failed.";
3127
+			} else {
3128
+				$error = "File ".$tmp_dir.'block.tsv.gz'." md5 failed. Download failed.";
3129
+			}
3130
+		} else {
3131
+			$error = "File ".$tmp_dir.'block.tsv.gz'." doesn't exist. Download failed.";
3132
+		}
2580 3133
 		if ($error != '') {
2581 3134
 			return $error;
2582
-		} elseif ($globalDebug) echo "Done\n";
3135
+		} elseif ($globalDebug) {
3136
+			echo "Done\n";
3137
+		}
2583 3138
 		return '';
2584 3139
 	}
2585 3140
 	public static function update_marine_identity_fam() {
@@ -2589,21 +3144,33 @@  discard block
 block discarded – undo
2589 3144
 			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2590 3145
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2591 3146
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2592
-				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
3147
+				if ($globalDebug) {
3148
+					echo "Marine identity from FlightAirMap website : Download...";
3149
+				}
2593 3150
 				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2594 3151
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2595 3152
 					if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) {
2596
-						if ($globalDebug) echo "Gunzip...";
3153
+						if ($globalDebug) {
3154
+							echo "Gunzip...";
3155
+						}
2597 3156
 						update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
2598
-						if ($globalDebug) echo "Add to DB...";
3157
+						if ($globalDebug) {
3158
+							echo "Add to DB...";
3159
+						}
2599 3160
 						$error = update_db::marine_identity_fam();
2600
-					} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
2601
-				} else $error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
3161
+					} else {
3162
+						$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." md5 failed. Download failed.";
3163
+					}
3164
+				} else {
3165
+					$error = "File ".$tmp_dir.'marine_identity.tsv.gz'." doesn't exist. Download failed.";
3166
+				}
2602 3167
 				if ($error != '') {
2603 3168
 					return $error;
2604 3169
 				} else {
2605 3170
 					update_db::insert_marine_identity_version($marine_identity_md5);
2606
-					if ($globalDebug) echo "Done\n";
3171
+					if ($globalDebug) {
3172
+						echo "Done\n";
3173
+					}
2607 3174
 				}
2608 3175
 			}
2609 3176
 		}
@@ -2617,21 +3184,33 @@  discard block
 block discarded – undo
2617 3184
 			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2618 3185
 			$satellite_md5 = $satellite_md5_file[0];
2619 3186
 			if (!update_db::check_satellite_version($satellite_md5)) {
2620
-				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
3187
+				if ($globalDebug) {
3188
+					echo "Satellite from FlightAirMap website : Download...";
3189
+				}
2621 3190
 				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2622 3191
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2623 3192
 					if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) {
2624
-						if ($globalDebug) echo "Gunzip...";
3193
+						if ($globalDebug) {
3194
+							echo "Gunzip...";
3195
+						}
2625 3196
 						update_db::gunzip($tmp_dir.'satellite.tsv.gz');
2626
-						if ($globalDebug) echo "Add to DB...";
3197
+						if ($globalDebug) {
3198
+							echo "Add to DB...";
3199
+						}
2627 3200
 						$error = update_db::satellite_fam();
2628
-					} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
2629
-				} else $error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
3201
+					} else {
3202
+						$error = "File ".$tmp_dir.'satellite.tsv.gz'." md5 failed. Download failed.";
3203
+					}
3204
+				} else {
3205
+					$error = "File ".$tmp_dir.'satellite.tsv.gz'." doesn't exist. Download failed.";
3206
+				}
2630 3207
 				if ($error != '') {
2631 3208
 					return $error;
2632 3209
 				} else {
2633 3210
 					update_db::insert_satellite_version($satellite_md5);
2634
-					if ($globalDebug) echo "Done\n";
3211
+					if ($globalDebug) {
3212
+						echo "Done\n";
3213
+					}
2635 3214
 				}
2636 3215
 			}
2637 3216
 		}
@@ -2639,17 +3218,25 @@  discard block
 block discarded – undo
2639 3218
 	}
2640 3219
 	public static function update_banned_fam() {
2641 3220
 		global $tmp_dir, $globalDebug;
2642
-		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
3221
+		if ($globalDebug) {
3222
+			echo "Banned airlines in Europe from FlightAirMap website : Download...";
3223
+		}
2643 3224
 		update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2644 3225
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2645 3226
 			//if ($globalDebug) echo "Gunzip...";
2646 3227
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
2647
-			if ($globalDebug) echo "Add to DB...";
3228
+			if ($globalDebug) {
3229
+				echo "Add to DB...";
3230
+			}
2648 3231
 			$error = update_db::banned_fam();
2649
-		} else $error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
3232
+		} else {
3233
+			$error = "File ".$tmp_dir.'ban_eu.csv'." doesn't exist. Download failed.";
3234
+		}
2650 3235
 		if ($error != '') {
2651 3236
 			return $error;
2652
-		} elseif ($globalDebug) echo "Done\n";
3237
+		} elseif ($globalDebug) {
3238
+			echo "Done\n";
3239
+		}
2653 3240
 		return '';
2654 3241
 	}
2655 3242
 
@@ -2657,7 +3244,9 @@  discard block
 block discarded – undo
2657 3244
 		global $tmp_dir, $globalDebug, $globalDBdriver;
2658 3245
 		include_once('class.create_db.php');
2659 3246
 		$error = '';
2660
-		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
3247
+		if ($globalDebug) {
3248
+			echo "Airspace from FlightAirMap website : Download...";
3249
+		}
2661 3250
 		if ($globalDBdriver == 'mysql') {
2662 3251
 			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2663 3252
 		} else {
@@ -2674,9 +3263,13 @@  discard block
 block discarded – undo
2674 3263
 				}
2675 3264
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2676 3265
 					if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) {
2677
-						if ($globalDebug) echo "Gunzip...";
3266
+						if ($globalDebug) {
3267
+							echo "Gunzip...";
3268
+						}
2678 3269
 						update_db::gunzip($tmp_dir.'airspace.sql.gz');
2679
-						if ($globalDebug) echo "Add to DB...";
3270
+						if ($globalDebug) {
3271
+							echo "Add to DB...";
3272
+						}
2680 3273
 						$Connection = new Connection();
2681 3274
 						if ($Connection->tableExists('airspace')) {
2682 3275
 							$query = 'DROP TABLE airspace';
@@ -2689,20 +3282,30 @@  discard block
 block discarded – undo
2689 3282
 						}
2690 3283
 						$error = create_db::import_file($tmp_dir.'airspace.sql');
2691 3284
 						update_db::insert_airspace_version($airspace_md5);
2692
-					} else $error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
2693
-				} else $error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3285
+					} else {
3286
+						$error = "File ".$tmp_dir.'airspace.sql.gz'." md5 failed. Download failed.";
3287
+					}
3288
+				} else {
3289
+					$error = "File ".$tmp_dir.'airspace.sql.gz'." doesn't exist. Download failed.";
3290
+				}
2694 3291
 			}
2695
-		} else $error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3292
+		} else {
3293
+			$error = "File ".$tmp_dir.'airspace.sql.gz.md5'." doesn't exist. Download failed.";
3294
+		}
2696 3295
 		if ($error != '') {
2697 3296
 			return $error;
2698
-		} elseif ($globalDebug) echo "Done\n";
3297
+		} elseif ($globalDebug) {
3298
+			echo "Done\n";
3299
+		}
2699 3300
 		return '';
2700 3301
 	}
2701 3302
 
2702 3303
 	public static function update_geoid_fam() {
2703 3304
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2704 3305
 		$error = '';
2705
-		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
3306
+		if ($globalDebug) {
3307
+			echo "Geoid from FlightAirMap website : Download...";
3308
+		}
2706 3309
 		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2707 3310
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2708 3311
 			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
@@ -2711,76 +3314,120 @@  discard block
 block discarded – undo
2711 3314
 				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2712 3315
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2713 3316
 					if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) {
2714
-						if ($globalDebug) echo "Gunzip...";
3317
+						if ($globalDebug) {
3318
+							echo "Gunzip...";
3319
+						}
2715 3320
 						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2716 3321
 						if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2717 3322
 							update_db::insert_geoid_version($geoid_md5);
2718
-						} else $error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
2719
-					} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
2720
-				} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
2721
-			} elseif ($globalDebug) echo 'No new version'."\n";
2722
-		} else $error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3323
+						} else {
3324
+							$error = "File data/".$globalGeoidSource.'.pgm'." doesn't exist. Gunzip failed.";
3325
+						}
3326
+					} else {
3327
+						$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." md5 failed. Download failed.";
3328
+					}
3329
+				} else {
3330
+					$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz'." doesn't exist. Download failed.";
3331
+				}
3332
+			} elseif ($globalDebug) {
3333
+				echo 'No new version'."\n";
3334
+			}
3335
+		} else {
3336
+			$error = "File ".$tmp_dir.$globalGeoidSource.'.pgm.gz.md5'." doesn't exist. Download failed.";
3337
+		}
2723 3338
 		if ($error != '') {
2724 3339
 			return $error;
2725
-		} elseif ($globalDebug) echo "Done\n";
3340
+		} elseif ($globalDebug) {
3341
+			echo "Done\n";
3342
+		}
2726 3343
 		return '';
2727 3344
 	}
2728 3345
 
2729 3346
 	public static function update_tle() {
2730 3347
 		global $tmp_dir, $globalDebug;
2731
-		if ($globalDebug) echo "Download TLE : Download...";
3348
+		if ($globalDebug) {
3349
+			echo "Download TLE : Download...";
3350
+		}
2732 3351
 		$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',
2733 3352
 		'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',
2734 3353
 		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt','visual.txt','sarsat.txt','argos.txt','ses.txt','iridium-NEXT.txt','beidou.txt');
2735 3354
 		foreach ($alltle as $filename) {
2736
-			if ($globalDebug) echo "downloading ".$filename.'...';
3355
+			if ($globalDebug) {
3356
+				echo "downloading ".$filename.'...';
3357
+			}
2737 3358
 			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2738 3359
 			if (file_exists($tmp_dir.$filename)) {
2739
-				if ($globalDebug) echo "Add to DB ".$filename."...";
3360
+				if ($globalDebug) {
3361
+					echo "Add to DB ".$filename."...";
3362
+				}
2740 3363
 				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2741
-			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3364
+			} else {
3365
+				$error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
3366
+			}
2742 3367
 			if ($error != '') {
2743 3368
 				echo $error."\n";
2744
-			} elseif ($globalDebug) echo "Done\n";
3369
+			} elseif ($globalDebug) {
3370
+				echo "Done\n";
3371
+			}
2745 3372
 		}
2746 3373
 		return '';
2747 3374
 	}
2748 3375
 
2749 3376
 	public static function update_ucsdb() {
2750 3377
 		global $tmp_dir, $globalDebug;
2751
-		if ($globalDebug) echo "Download UCS DB : Download...";
3378
+		if ($globalDebug) {
3379
+			echo "Download UCS DB : Download...";
3380
+		}
2752 3381
 		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/9-1-17-update/UCS_Satellite_Database_officialname_9-1-2017.txt',$tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt');
2753 3382
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2754
-			if ($globalDebug) echo "Add to DB...";
3383
+			if ($globalDebug) {
3384
+				echo "Add to DB...";
3385
+			}
2755 3386
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt');
2756
-		} else $error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt'." doesn't exist. Download failed.";
3387
+		} else {
3388
+			$error = "File ".$tmp_dir.'UCS_Satellite_Database_officialname_9-1-2017.txt'." doesn't exist. Download failed.";
3389
+		}
2757 3390
 		if ($error != '') {
2758 3391
 			echo $error."\n";
2759
-		} elseif ($globalDebug) echo "Done\n";
3392
+		} elseif ($globalDebug) {
3393
+			echo "Done\n";
3394
+		}
2760 3395
 		return '';
2761 3396
 	}
2762 3397
 
2763 3398
 	public static function update_celestrak() {
2764 3399
 		global $tmp_dir, $globalDebug;
2765
-		if ($globalDebug) echo "Download Celestrak DB : Download...";
3400
+		if ($globalDebug) {
3401
+			echo "Download Celestrak DB : Download...";
3402
+		}
2766 3403
 		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2767 3404
 		if (file_exists($tmp_dir.'satcat.txt')) {
2768
-			if ($globalDebug) echo "Add to DB...";
3405
+			if ($globalDebug) {
3406
+				echo "Add to DB...";
3407
+			}
2769 3408
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
2770
-		} else $error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3409
+		} else {
3410
+			$error = "File ".$tmp_dir.'satcat.txt'." doesn't exist. Download failed.";
3411
+		}
2771 3412
 		if ($error != '') {
2772 3413
 			echo $error."\n";
2773
-		} elseif ($globalDebug) echo "Done\n";
3414
+		} elseif ($globalDebug) {
3415
+			echo "Done\n";
3416
+		}
2774 3417
 		return '';
2775 3418
 	}
2776 3419
 
2777 3420
 	public static function update_models() {
2778 3421
 		global $tmp_dir, $globalDebug;
2779 3422
 		$error = '';
2780
-		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
3423
+		if ($globalDebug) {
3424
+			echo "Models from FlightAirMap website : Download...";
3425
+		}
2781 3426
 		update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2782 3427
 		if (file_exists($tmp_dir.'models.md5sum')) {
2783
-			if ($globalDebug) echo "Check files...\n";
3428
+			if ($globalDebug) {
3429
+				echo "Check files...\n";
3430
+			}
2784 3431
 			$newmodelsdb = array();
2785 3432
 			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2786 3433
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2799,19 +3446,29 @@  discard block
 block discarded – undo
2799 3446
 			}
2800 3447
 			$diff = array_diff($newmodelsdb,$modelsdb);
2801 3448
 			foreach ($diff as $key => $value) {
2802
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3449
+				if ($globalDebug) {
3450
+					echo 'Downloading model '.$key.' ...'."\n";
3451
+				}
2803 3452
 				update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2804 3453
 				
2805 3454
 			}
2806 3455
 			update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2807
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3456
+		} else {
3457
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3458
+		}
2808 3459
 		if ($error != '') {
2809 3460
 			return $error;
2810
-		} elseif ($globalDebug) echo "Done\n";
2811
-		if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download...";
3461
+		} elseif ($globalDebug) {
3462
+			echo "Done\n";
3463
+		}
3464
+		if ($globalDebug) {
3465
+			echo "glTF 2.0 Models from FlightAirMap website : Download...";
3466
+		}
2812 3467
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum');
2813 3468
 		if (file_exists($tmp_dir.'modelsgltf2.md5sum')) {
2814
-			if ($globalDebug) echo "Check files...\n";
3469
+			if ($globalDebug) {
3470
+				echo "Check files...\n";
3471
+			}
2815 3472
 			$newmodelsdb = array();
2816 3473
 			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) {
2817 3474
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2830,19 +3487,29 @@  discard block
 block discarded – undo
2830 3487
 			}
2831 3488
 			$diff = array_diff($newmodelsdb,$modelsdb);
2832 3489
 			foreach ($diff as $key => $value) {
2833
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3490
+				if ($globalDebug) {
3491
+					echo 'Downloading model '.$key.' ...'."\n";
3492
+				}
2834 3493
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key);
2835 3494
 				
2836 3495
 			}
2837 3496
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum');
2838
-		} else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
3497
+		} else {
3498
+			$error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
3499
+		}
2839 3500
 		if ($error != '') {
2840 3501
 			return $error;
2841
-		} elseif ($globalDebug) echo "Done\n";
2842
-		if ($globalDebug) echo "Weather Models from FlightAirMap website : Download...";
3502
+		} elseif ($globalDebug) {
3503
+			echo "Done\n";
3504
+		}
3505
+		if ($globalDebug) {
3506
+			echo "Weather Models from FlightAirMap website : Download...";
3507
+		}
2843 3508
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',$tmp_dir.'modelsweather.md5sum');
2844 3509
 		if (file_exists($tmp_dir.'modelsweather.md5sum')) {
2845
-			if ($globalDebug) echo "Check files...\n";
3510
+			if ($globalDebug) {
3511
+				echo "Check files...\n";
3512
+			}
2846 3513
 			$newmodelsdb = array();
2847 3514
 			if (($handle = fopen($tmp_dir.'modelsweather.md5sum','r')) !== FALSE) {
2848 3515
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2861,25 +3528,35 @@  discard block
 block discarded – undo
2861 3528
 			}
2862 3529
 			$diff = array_diff($newmodelsdb,$modelsdb);
2863 3530
 			foreach ($diff as $key => $value) {
2864
-				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
3531
+				if ($globalDebug) {
3532
+					echo 'Downloading model '.$key.' ...'."\n";
3533
+				}
2865 3534
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/'.$key,dirname(__FILE__).'/../models/gltf2/weather/'.$key);
2866 3535
 				
2867 3536
 			}
2868 3537
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/weather/models.md5sum',dirname(__FILE__).'/../models/gltf2/weather/models.md5sum');
2869
-		} else $error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed.";
3538
+		} else {
3539
+			$error = "File ".$tmp_dir.'modelsweather.md5sum'." doesn't exist. Download failed.";
3540
+		}
2870 3541
 		if ($error != '') {
2871 3542
 			return $error;
2872
-		} elseif ($globalDebug) echo "Done\n";
3543
+		} elseif ($globalDebug) {
3544
+			echo "Done\n";
3545
+		}
2873 3546
 		return '';
2874 3547
 	}
2875 3548
 
2876 3549
 	public static function update_liveries() {
2877 3550
 		global $tmp_dir, $globalDebug;
2878 3551
 		$error = '';
2879
-		if ($globalDebug) echo "Liveries from FlightAirMap website : Download...";
3552
+		if ($globalDebug) {
3553
+			echo "Liveries from FlightAirMap website : Download...";
3554
+		}
2880 3555
 		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum');
2881 3556
 		if (file_exists($tmp_dir.'liveries.md5sum')) {
2882
-			if ($globalDebug) echo "Check files...\n";
3557
+			if ($globalDebug) {
3558
+				echo "Check files...\n";
3559
+			}
2883 3560
 			$newmodelsdb = array();
2884 3561
 			if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) {
2885 3562
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2898,25 +3575,35 @@  discard block
 block discarded – undo
2898 3575
 			}
2899 3576
 			$diff = array_diff($newmodelsdb,$modelsdb);
2900 3577
 			foreach ($diff as $key => $value) {
2901
-				if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n";
3578
+				if ($globalDebug) {
3579
+					echo 'Downloading liveries '.$key.' ...'."\n";
3580
+				}
2902 3581
 				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2903 3582
 				
2904 3583
 			}
2905 3584
 			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2906
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3585
+		} else {
3586
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3587
+		}
2907 3588
 		if ($error != '') {
2908 3589
 			return $error;
2909
-		} elseif ($globalDebug) echo "Done\n";
3590
+		} elseif ($globalDebug) {
3591
+			echo "Done\n";
3592
+		}
2910 3593
 		return '';
2911 3594
 	}
2912 3595
 
2913 3596
 	public static function update_space_models() {
2914 3597
 		global $tmp_dir, $globalDebug;
2915 3598
 		$error = '';
2916
-		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
3599
+		if ($globalDebug) {
3600
+			echo "Space models from FlightAirMap website : Download...";
3601
+		}
2917 3602
 		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2918 3603
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2919
-			if ($globalDebug) echo "Check files...\n";
3604
+			if ($globalDebug) {
3605
+				echo "Check files...\n";
3606
+			}
2920 3607
 			$newmodelsdb = array();
2921 3608
 			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2922 3609
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2935,25 +3622,35 @@  discard block
 block discarded – undo
2935 3622
 			}
2936 3623
 			$diff = array_diff($newmodelsdb,$modelsdb);
2937 3624
 			foreach ($diff as $key => $value) {
2938
-				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
3625
+				if ($globalDebug) {
3626
+					echo 'Downloading space model '.$key.' ...'."\n";
3627
+				}
2939 3628
 				update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2940 3629
 				
2941 3630
 			}
2942 3631
 			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2943
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3632
+		} else {
3633
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3634
+		}
2944 3635
 		if ($error != '') {
2945 3636
 			return $error;
2946
-		} elseif ($globalDebug) echo "Done\n";
3637
+		} elseif ($globalDebug) {
3638
+			echo "Done\n";
3639
+		}
2947 3640
 		return '';
2948 3641
 	}
2949 3642
 
2950 3643
 	public static function update_vehicules_models() {
2951 3644
 		global $tmp_dir, $globalDebug;
2952 3645
 		$error = '';
2953
-		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
3646
+		if ($globalDebug) {
3647
+			echo "Vehicules models from FlightAirMap website : Download...";
3648
+		}
2954 3649
 		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2955 3650
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2956
-			if ($globalDebug) echo "Check files...\n";
3651
+			if ($globalDebug) {
3652
+				echo "Check files...\n";
3653
+			}
2957 3654
 			$newmodelsdb = array();
2958 3655
 			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2959 3656
 				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
@@ -2972,15 +3669,21 @@  discard block
 block discarded – undo
2972 3669
 			}
2973 3670
 			$diff = array_diff($newmodelsdb,$modelsdb);
2974 3671
 			foreach ($diff as $key => $value) {
2975
-				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
3672
+				if ($globalDebug) {
3673
+					echo 'Downloading vehicules model '.$key.' ...'."\n";
3674
+				}
2976 3675
 				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2977 3676
 				
2978 3677
 			}
2979 3678
 			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2980
-		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3679
+		} else {
3680
+			$error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
3681
+		}
2981 3682
 		if ($error != '') {
2982 3683
 			return $error;
2983
-		} elseif ($globalDebug) echo "Done\n";
3684
+		} elseif ($globalDebug) {
3685
+			echo "Done\n";
3686
+		}
2984 3687
 		return '';
2985 3688
 	}
2986 3689
 
@@ -3053,7 +3756,9 @@  discard block
 block discarded – undo
3053 3756
                 }
3054 3757
 
3055 3758
 		$error = '';
3056
-		if ($globalDebug) echo "Notam : Download...";
3759
+		if ($globalDebug) {
3760
+			echo "Notam : Download...";
3761
+		}
3057 3762
 		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
3058 3763
 		if (file_exists($tmp_dir.'notam.rss')) {
3059 3764
 			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
@@ -3068,14 +3773,30 @@  discard block
 block discarded – undo
3068 3773
 				$data['fir'] = $q[0];
3069 3774
 				$data['code'] = $q[1];
3070 3775
 				$ifrvfr = $q[2];
3071
-				if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR';
3072
-				if ($ifrvfr == 'I') $data['rules'] = 'IFR';
3073
-				if ($ifrvfr == 'V') $data['rules'] = 'VFR';
3074
-				if ($q[4] == 'A') $data['scope'] = 'Airport warning';
3075
-				if ($q[4] == 'E') $data['scope'] = 'Enroute warning';
3076
-				if ($q[4] == 'W') $data['scope'] = 'Navigation warning';
3077
-				if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning';
3078
-				if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning';
3776
+				if ($ifrvfr == 'IV') {
3777
+					$data['rules'] = 'IFR/VFR';
3778
+				}
3779
+				if ($ifrvfr == 'I') {
3780
+					$data['rules'] = 'IFR';
3781
+				}
3782
+				if ($ifrvfr == 'V') {
3783
+					$data['rules'] = 'VFR';
3784
+				}
3785
+				if ($q[4] == 'A') {
3786
+					$data['scope'] = 'Airport warning';
3787
+				}
3788
+				if ($q[4] == 'E') {
3789
+					$data['scope'] = 'Enroute warning';
3790
+				}
3791
+				if ($q[4] == 'W') {
3792
+					$data['scope'] = 'Navigation warning';
3793
+				}
3794
+				if ($q[4] == 'AE') {
3795
+					$data['scope'] = 'Airport/Enroute warning';
3796
+				}
3797
+				if ($q[4] == 'AW') {
3798
+					$data['scope'] = 'Airport/Navigation warning';
3799
+				}
3079 3800
 				//$data['scope'] = $q[4];
3080 3801
 				$data['lower_limit'] = $q[5];
3081 3802
 				$data['upper_limit'] = $q[6];
@@ -3083,8 +3804,12 @@  discard block
 block discarded – undo
3083 3804
 				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
3084 3805
 				$latitude = $Common->convertDec($las,'latitude');
3085 3806
 				$longitude = $Common->convertDec($lns,'longitude');
3086
-				if ($lac == 'S') $latitude = '-'.$latitude;
3087
-				if ($lnc == 'W') $longitude = '-'.$longitude;
3807
+				if ($lac == 'S') {
3808
+					$latitude = '-'.$latitude;
3809
+				}
3810
+				if ($lnc == 'W') {
3811
+					$longitude = '-'.$longitude;
3812
+				}
3088 3813
 				$data['center_latitude'] = $latitude;
3089 3814
 				$data['center_longitude'] = $longitude;
3090 3815
 				$data['radius'] = intval($radius);
@@ -3114,10 +3839,14 @@  discard block
 block discarded – undo
3114 3839
 				$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']);
3115 3840
 				unset($data);
3116 3841
 			} 
3117
-		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3842
+		} else {
3843
+			$error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
3844
+		}
3118 3845
 		if ($error != '') {
3119 3846
 			return $error;
3120
-		} elseif ($globalDebug) echo "Done\n";
3847
+		} elseif ($globalDebug) {
3848
+			echo "Done\n";
3849
+		}
3121 3850
 		return '';
3122 3851
 	}
3123 3852
 	
@@ -3142,7 +3871,9 @@  discard block
 block discarded – undo
3142 3871
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
3143 3872
 		$airspace_json = json_decode($airspace_lst,true);
3144 3873
 		foreach ($airspace_json['records'] as $airspace) {
3145
-			if ($globalDebug) echo $airspace['name']."...\n";
3874
+			if ($globalDebug) {
3875
+				echo $airspace['name']."...\n";
3876
+			}
3146 3877
 			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
3147 3878
 			if (file_exists($tmp_dir.$airspace['name'])) {
3148 3879
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
@@ -3186,8 +3917,11 @@  discard block
 block discarded – undo
3186 3917
                         return "error : ".$e->getMessage();
3187 3918
                 }
3188 3919
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3189
-                if ($row['nb'] > 0) return false;
3190
-                else return true;
3920
+                if ($row['nb'] > 0) {
3921
+                	return false;
3922
+                } else {
3923
+                	return true;
3924
+                }
3191 3925
 	}
3192 3926
 
3193 3927
 	public static function insert_last_update() {
@@ -3212,8 +3946,11 @@  discard block
 block discarded – undo
3212 3946
                         return "error : ".$e->getMessage();
3213 3947
                 }
3214 3948
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3215
-                if ($row['nb'] > 0) return true;
3216
-                else return false;
3949
+                if ($row['nb'] > 0) {
3950
+                	return true;
3951
+                } else {
3952
+                	return false;
3953
+                }
3217 3954
 	}
3218 3955
 
3219 3956
 	public static function check_geoid_version($version) {
@@ -3226,8 +3963,11 @@  discard block
 block discarded – undo
3226 3963
                         return "error : ".$e->getMessage();
3227 3964
                 }
3228 3965
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3229
-                if ($row['nb'] > 0) return true;
3230
-                else return false;
3966
+                if ($row['nb'] > 0) {
3967
+                	return true;
3968
+                } else {
3969
+                	return false;
3970
+                }
3231 3971
 	}
3232 3972
 
3233 3973
 	public static function check_marine_identity_version($version) {
@@ -3240,8 +3980,11 @@  discard block
 block discarded – undo
3240 3980
 			return "error : ".$e->getMessage();
3241 3981
 		}
3242 3982
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3243
-		if ($row['nb'] > 0) return true;
3244
-		else return false;
3983
+		if ($row['nb'] > 0) {
3984
+			return true;
3985
+		} else {
3986
+			return false;
3987
+		}
3245 3988
 	}
3246 3989
 
3247 3990
 	public static function check_satellite_version($version) {
@@ -3254,8 +3997,11 @@  discard block
 block discarded – undo
3254 3997
 			return "error : ".$e->getMessage();
3255 3998
 		}
3256 3999
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3257
-		if ($row['nb'] > 0) return true;
3258
-		else return false;
4000
+		if ($row['nb'] > 0) {
4001
+			return true;
4002
+		} else {
4003
+			return false;
4004
+		}
3259 4005
 	}
3260 4006
 
3261 4007
 	public static function check_airlines_version($version) {
@@ -3268,8 +4014,11 @@  discard block
 block discarded – undo
3268 4014
 			return "error : ".$e->getMessage();
3269 4015
 		}
3270 4016
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3271
-		if ($row['nb'] > 0) return true;
3272
-		else return false;
4017
+		if ($row['nb'] > 0) {
4018
+			return true;
4019
+		} else {
4020
+			return false;
4021
+		}
3273 4022
 	}
3274 4023
 
3275 4024
 	public static function check_notam_version($version) {
@@ -3282,8 +4031,11 @@  discard block
 block discarded – undo
3282 4031
 			return "error : ".$e->getMessage();
3283 4032
 		}
3284 4033
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3285
-		if ($row['nb'] > 0) return true;
3286
-		else return false;
4034
+		if ($row['nb'] > 0) {
4035
+			return true;
4036
+		} else {
4037
+			return false;
4038
+		}
3287 4039
 	}
3288 4040
 
3289 4041
 	public static function insert_airlines_version($version) {
@@ -3373,8 +4125,11 @@  discard block
 block discarded – undo
3373 4125
                         return "error : ".$e->getMessage();
3374 4126
                 }
3375 4127
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3376
-                if ($row['nb'] > 0) return false;
3377
-                else return true;
4128
+                if ($row['nb'] > 0) {
4129
+                	return false;
4130
+                } else {
4131
+                	return true;
4132
+                }
3378 4133
 	}
3379 4134
 
3380 4135
 	public static function insert_last_notam_update() {
@@ -3404,8 +4159,11 @@  discard block
 block discarded – undo
3404 4159
                         return "error : ".$e->getMessage();
3405 4160
                 }
3406 4161
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3407
-                if ($row['nb'] > 0) return false;
3408
-                else return true;
4162
+                if ($row['nb'] > 0) {
4163
+                	return false;
4164
+                } else {
4165
+                	return true;
4166
+                }
3409 4167
 	}
3410 4168
 
3411 4169
 	public static function insert_last_airspace_update() {
@@ -3435,8 +4193,11 @@  discard block
 block discarded – undo
3435 4193
                         return "error : ".$e->getMessage();
3436 4194
                 }
3437 4195
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3438
-                if ($row['nb'] > 0) return false;
3439
-                else return true;
4196
+                if ($row['nb'] > 0) {
4197
+                	return false;
4198
+                } else {
4199
+                	return true;
4200
+                }
3440 4201
 	}
3441 4202
 
3442 4203
 	public static function insert_last_geoid_update() {
@@ -3466,8 +4227,11 @@  discard block
 block discarded – undo
3466 4227
 			return "error : ".$e->getMessage();
3467 4228
 		}
3468 4229
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3469
-		if ($row['nb'] > 0) return false;
3470
-		else return true;
4230
+		if ($row['nb'] > 0) {
4231
+			return false;
4232
+		} else {
4233
+			return true;
4234
+		}
3471 4235
 	}
3472 4236
 
3473 4237
 	public static function insert_last_owner_update() {
@@ -3497,8 +4261,11 @@  discard block
 block discarded – undo
3497 4261
 			return "error : ".$e->getMessage();
3498 4262
 		}
3499 4263
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3500
-		if ($row['nb'] > 0) return false;
3501
-		else return true;
4264
+		if ($row['nb'] > 0) {
4265
+			return false;
4266
+		} else {
4267
+			return true;
4268
+		}
3502 4269
 	}
3503 4270
 
3504 4271
 	public static function insert_last_fires_update() {
@@ -3528,8 +4295,11 @@  discard block
 block discarded – undo
3528 4295
 			return "error : ".$e->getMessage();
3529 4296
 		}
3530 4297
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3531
-		if ($row['nb'] > 0) return false;
3532
-		else return true;
4298
+		if ($row['nb'] > 0) {
4299
+			return false;
4300
+		} else {
4301
+			return true;
4302
+		}
3533 4303
 	}
3534 4304
 
3535 4305
 	public static function insert_last_airlines_update() {
@@ -3559,8 +4329,11 @@  discard block
 block discarded – undo
3559 4329
                         return "error : ".$e->getMessage();
3560 4330
                 }
3561 4331
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
3562
-                if ($row['nb'] > 0) return false;
3563
-                else return true;
4332
+                if ($row['nb'] > 0) {
4333
+                	return false;
4334
+                } else {
4335
+                	return true;
4336
+                }
3564 4337
 	}
3565 4338
 
3566 4339
 	public static function insert_last_schedules_update() {
@@ -3590,8 +4363,11 @@  discard block
 block discarded – undo
3590 4363
 			return "error : ".$e->getMessage();
3591 4364
 		}
3592 4365
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3593
-		if ($row['nb'] > 0) return false;
3594
-		else return true;
4366
+		if ($row['nb'] > 0) {
4367
+			return false;
4368
+		} else {
4369
+			return true;
4370
+		}
3595 4371
 	}
3596 4372
 
3597 4373
 	public static function insert_last_tle_update() {
@@ -3621,8 +4397,11 @@  discard block
 block discarded – undo
3621 4397
 			return "error : ".$e->getMessage();
3622 4398
 		}
3623 4399
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3624
-		if ($row['nb'] > 0) return false;
3625
-		else return true;
4400
+		if ($row['nb'] > 0) {
4401
+			return false;
4402
+		} else {
4403
+			return true;
4404
+		}
3626 4405
 	}
3627 4406
 
3628 4407
 	public static function insert_last_ucsdb_update() {
@@ -3652,8 +4431,11 @@  discard block
 block discarded – undo
3652 4431
 			return "error : ".$e->getMessage();
3653 4432
 		}
3654 4433
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3655
-		if ($row['nb'] > 0) return false;
3656
-		else return true;
4434
+		if ($row['nb'] > 0) {
4435
+			return false;
4436
+		} else {
4437
+			return true;
4438
+		}
3657 4439
 	}
3658 4440
 
3659 4441
 	public static function insert_last_celestrak_update() {
@@ -3683,8 +4465,11 @@  discard block
 block discarded – undo
3683 4465
 			return "error : ".$e->getMessage();
3684 4466
 		}
3685 4467
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3686
-		if ($row['nb'] > 0) return false;
3687
-		else return true;
4468
+		if ($row['nb'] > 0) {
4469
+			return false;
4470
+		} else {
4471
+			return true;
4472
+		}
3688 4473
 	}
3689 4474
 
3690 4475
 	public static function check_last_satellite_update() {
@@ -3702,8 +4487,11 @@  discard block
 block discarded – undo
3702 4487
 			return "error : ".$e->getMessage();
3703 4488
 		}
3704 4489
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
3705
-		if ($row['nb'] > 0) return false;
3706
-		else return true;
4490
+		if ($row['nb'] > 0) {
4491
+			return false;
4492
+		} else {
4493
+			return true;
4494
+		}
3707 4495
 	}
3708 4496
 
3709 4497
 	public static function insert_last_marine_identity_update() {
Please login to merge, or discard this patch.
require/class.Common.php 4 patches
Doc Comments   +14 added lines, -2 removed lines patch added patch discarded remove patch
@@ -102,6 +102,9 @@  discard block
 block discarded – undo
102 102
 	}
103 103
 
104 104
 
105
+	/**
106
+	 * @param string $url
107
+	 */
105 108
 	public static function download($url, $file, $referer = '') {
106 109
 		global $globalDebug, $globalProxy, $globalForceIPv4;
107 110
 		$fp = fopen($file, 'w');
@@ -126,6 +129,9 @@  discard block
 block discarded – undo
126 129
 		fclose($fp);
127 130
 	}
128 131
 
132
+	/**
133
+	 * @param string $in_file
134
+	 */
129 135
 	public static function gunzip($in_file,$out_file_name = '') {
130 136
 		//echo $in_file.' -> '.$out_file_name."\n";
131 137
 		$buffer_size = 4096; // read 4kb at a time
@@ -287,7 +293,7 @@  discard block
 block discarded – undo
287 293
 	* Check is distance realistic
288 294
 	* @param int $timeDifference the time between the reception of both messages
289 295
 	* @param float $distance distance covered
290
-	* @return whether distance is realistic
296
+	* @return boolean distance is realistic
291 297
 	*/
292 298
 	public function withinThreshold ($timeDifference, $distance) {
293 299
 		$x = abs($timeDifference);
@@ -311,6 +317,9 @@  discard block
 block discarded – undo
311 317
 	}
312 318
 
313 319
 
320
+	/**
321
+	 * @param string $latlong
322
+	 */
314 323
 	public function convertDec($dms,$latlong) {
315 324
 		if ($latlong == 'latitude') {
316 325
 			$deg = substr($dms, 0, 2);
@@ -345,6 +354,9 @@  discard block
 block discarded – undo
345 354
 		return array('latitude' => round($latitude,5),'longitude' => round($longitude,5));
346 355
 	}
347 356
 	
357
+	/**
358
+	 * @param string $latlong
359
+	 */
348 360
 	public function convertDM($coord,$latlong) {
349 361
 		if ($latlong == 'latitude') {
350 362
 			if ($coord < 0) $NSEW = 'S';
@@ -482,7 +494,7 @@  discard block
 block discarded – undo
482 494
 	/**
483 495
 	* Returns list of available locales
484 496
 	*
485
-	* @return array
497
+	* @return string[]
486 498
 	 */
487 499
 	public function listLocaleDir()
488 500
 	{
Please login to merge, or discard this patch.
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
 	//protected $cookies = array();
8 8
 	
9 9
 	/**
10
-	* Get data from form result
11
-	* @param String $url form URL
12
-	* @param String $type type of submit form method (get or post)
13
-	* @param String|Array $data values form post method
14
-	* @param Array $headers header to submit with the form
15
-	* @return String the result
16
-	*/
10
+	 * Get data from form result
11
+	 * @param String $url form URL
12
+	 * @param String $type type of submit form method (get or post)
13
+	 * @param String|Array $data values form post method
14
+	 * @param Array $headers header to submit with the form
15
+	 * @return String the result
16
+	 */
17 17
 	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '', $sizelimit = false, $async = false, $getheaders = false) {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
@@ -168,10 +168,10 @@  discard block
 block discarded – undo
168 168
 	}
169 169
 
170 170
 	/**
171
-	* Convert a HTML table to an array
172
-	* @param String $data HTML page
173
-	* @return Array array of the tables in HTML page
174
-	*/
171
+	 * Convert a HTML table to an array
172
+	 * @param String $data HTML page
173
+	 * @return Array array of the tables in HTML page
174
+	 */
175 175
 	public function table2array($data) {
176 176
 		if (!is_string($data)) return array();
177 177
 		if ($data == '') return array();
@@ -205,10 +205,10 @@  discard block
 block discarded – undo
205 205
 	}
206 206
 	
207 207
 	/**
208
-	* Convert <p> part of a HTML page to an array
209
-	* @param String $data HTML page
210
-	* @return Array array of the <p> in HTML page
211
-	*/
208
+	 * Convert <p> part of a HTML page to an array
209
+	 * @param String $data HTML page
210
+	 * @return Array array of the <p> in HTML page
211
+	 */
212 212
 	public function text2array($data) {
213 213
 		$html = str_get_html($data);
214 214
 		if ($html === false) return array();
@@ -223,14 +223,14 @@  discard block
 block discarded – undo
223 223
 	}
224 224
 
225 225
 	/**
226
-	* Give distance between 2 coordonnates
227
-	* @param Float $lat latitude of first point
228
-	* @param Float $lon longitude of first point
229
-	* @param Float $latc latitude of second point
230
-	* @param Float $lonc longitude of second point
231
-	* @param String $unit km else no unit used
232
-	* @return Float Distance in $unit
233
-	*/
226
+	 * Give distance between 2 coordonnates
227
+	 * @param Float $lat latitude of first point
228
+	 * @param Float $lon longitude of first point
229
+	 * @param Float $latc latitude of second point
230
+	 * @param Float $lonc longitude of second point
231
+	 * @param String $unit km else no unit used
232
+	 * @return Float Distance in $unit
233
+	 */
234 234
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
235 235
 		if ($lat == $latc && $lon == $lonc) return 0;
236 236
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
 	}
249 249
 
250 250
 	/**
251
-	* Give plunge between 2 altitudes and distance
252
-	* @param Float $initial_altitude altitude of first point in m
253
-	* @param Float $final_altitude altitude of second point in m
254
-	* @param String $distance distance between two points in m
255
-	* @return Float plunge
256
-	*/
251
+	 * Give plunge between 2 altitudes and distance
252
+	 * @param Float $initial_altitude altitude of first point in m
253
+	 * @param Float $final_altitude altitude of second point in m
254
+	 * @param String $distance distance between two points in m
255
+	 * @return Float plunge
256
+	 */
257 257
 	public function plunge($initial_altitude,$final_altitude,$distance) {
258 258
 		$plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance));
259 259
 		/*
@@ -267,13 +267,13 @@  discard block
 block discarded – undo
267 267
 	}
268 268
 
269 269
 	/**
270
-	* Give azimuth between 2 coordonnates
271
-	* @param Float $lat latitude of first point
272
-	* @param Float $lon longitude of first point
273
-	* @param Float $latc latitude of second point
274
-	* @param Float $lonc longitude of second point
275
-	* @return Float Azimuth
276
-	*/
270
+	 * Give azimuth between 2 coordonnates
271
+	 * @param Float $lat latitude of first point
272
+	 * @param Float $lon longitude of first point
273
+	 * @param Float $latc latitude of second point
274
+	 * @param Float $lonc longitude of second point
275
+	 * @return Float Azimuth
276
+	 */
277 277
 	public function azimuth($lat, $lon, $latc, $lonc) {
278 278
 		$dX = $latc - $lat;
279 279
 		$dY = $lonc - $lon;
@@ -284,11 +284,11 @@  discard block
 block discarded – undo
284 284
 	
285 285
 	
286 286
 	/**
287
-	* Check is distance realistic
288
-	* @param int $timeDifference the time between the reception of both messages
289
-	* @param float $distance distance covered
290
-	* @return whether distance is realistic
291
-	*/
287
+	 * Check is distance realistic
288
+	 * @param int $timeDifference the time between the reception of both messages
289
+	 * @param float $distance distance covered
290
+	 * @return whether distance is realistic
291
+	 */
292 292
 	public function withinThreshold ($timeDifference, $distance) {
293 293
 		$x = abs($timeDifference);
294 294
 		$d = abs($distance);
@@ -361,11 +361,11 @@  discard block
 block discarded – undo
361 361
 	}
362 362
 	
363 363
 	/**
364
-	* Copy folder contents
365
-	* @param       string   $source    Source path
366
-	* @param       string   $dest      Destination path
367
-	* @return      bool     Returns true on success, false on failure
368
-	*/
364
+	 * Copy folder contents
365
+	 * @param       string   $source    Source path
366
+	 * @param       string   $dest      Destination path
367
+	 * @return      bool     Returns true on success, false on failure
368
+	 */
369 369
 	public function xcopy($source, $dest)
370 370
 	{
371 371
 		$files = glob($source.'*.*');
@@ -377,20 +377,20 @@  discard block
 block discarded – undo
377 377
 	}
378 378
 	
379 379
 	/**
380
-	* Check if an url exist
381
-	* @param	String $url url to check
382
-	* @return	bool Return true on succes false on failure
383
-	*/
380
+	 * Check if an url exist
381
+	 * @param	String $url url to check
382
+	 * @return	bool Return true on succes false on failure
383
+	 */
384 384
 	public function urlexist($url){
385 385
 		$headers=get_headers($url);
386 386
 		return stripos($headers[0],"200 OK")?true:false;
387 387
 	}
388 388
 	
389 389
 	/**
390
-	* Convert hexa to string
391
-	* @param	String $hex data in hexa
392
-	* @return	String Return result
393
-	*/
390
+	 * Convert hexa to string
391
+	 * @param	String $hex data in hexa
392
+	 * @return	String Return result
393
+	 */
394 394
 	public function hex2str($hex) {
395 395
 		$str = '';
396 396
 		$hexln = strlen($hex);
@@ -399,10 +399,10 @@  discard block
 block discarded – undo
399 399
 	}
400 400
 	
401 401
 	/**
402
-	* Convert hexa color to rgb
403
-	* @param	String $hex data in hexa
404
-	* @return	String Return result
405
-	*/
402
+	 * Convert hexa color to rgb
403
+	 * @param	String $hex data in hexa
404
+	 * @return	String Return result
405
+	 */
406 406
 	public function hex2rgb($hex) {
407 407
 		$hex = str_replace('#','',$hex);
408 408
 		return sscanf($hex, "%02x%02x%02x"); 
@@ -480,9 +480,9 @@  discard block
 block discarded – undo
480 480
 	}
481 481
 	
482 482
 	/**
483
-	* Returns list of available locales
484
-	*
485
-	* @return array
483
+	 * Returns list of available locales
484
+	 *
485
+	 * @return array
486 486
 	 */
487 487
 	public function listLocaleDir()
488 488
 	{
@@ -581,100 +581,100 @@  discard block
 block discarded – undo
581 581
 	public function remove_accents($string) {
582 582
 		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
583 583
 		$chars = array(
584
-		    // Decompositions for Latin-1 Supplement
585
-		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
586
-		    chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
587
-		    chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
588
-		    chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
589
-		    chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
590
-		    chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
591
-		    chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
592
-		    chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
593
-		    chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
594
-		    chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
595
-		    chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
596
-		    chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
597
-		    chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
598
-		    chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
599
-		    chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
600
-		    chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
601
-		    chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
602
-		    chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
603
-		    chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
604
-		    chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
605
-		    chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
606
-		    chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
607
-		    chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
608
-		    chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
609
-		    chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
610
-		    chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
611
-		    chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
612
-		    chr(195).chr(191) => 'y',
613
-		    // Decompositions for Latin Extended-A
614
-		    chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
615
-		    chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
616
-		    chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
617
-		    chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
618
-		    chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
619
-		    chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
620
-		    chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
621
-		    chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
622
-		    chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
623
-		    chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
624
-		    chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
625
-		    chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
626
-		    chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
627
-		    chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
628
-		    chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
629
-		    chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
630
-		    chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
631
-		    chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
632
-		    chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
633
-		    chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
634
-		    chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
635
-		    chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
636
-		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
637
-		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
638
-		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
639
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
640
-		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
641
-		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
642
-		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
643
-		    chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
644
-		    chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
645
-		    chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
646
-		    chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
647
-		    chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
648
-		    chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
649
-		    chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
650
-		    chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
651
-		    chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
652
-		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
653
-		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
654
-		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
655
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
656
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
657
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
658
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
659
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
660
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
661
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
662
-		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
663
-		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
664
-		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
665
-		    chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
666
-		    chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
667
-		    chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
668
-		    chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
669
-		    chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
670
-		    chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
671
-		    chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
672
-		    chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
673
-		    chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
674
-		    chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
675
-		    chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
676
-		    chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
677
-		    chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
584
+			// Decompositions for Latin-1 Supplement
585
+			chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
586
+			chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
587
+			chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
588
+			chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
589
+			chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
590
+			chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
591
+			chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
592
+			chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
593
+			chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
594
+			chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
595
+			chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
596
+			chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
597
+			chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
598
+			chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
599
+			chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
600
+			chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
601
+			chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
602
+			chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
603
+			chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
604
+			chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
605
+			chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
606
+			chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
607
+			chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
608
+			chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
609
+			chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
610
+			chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
611
+			chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
612
+			chr(195).chr(191) => 'y',
613
+			// Decompositions for Latin Extended-A
614
+			chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
615
+			chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
616
+			chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
617
+			chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
618
+			chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
619
+			chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
620
+			chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
621
+			chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
622
+			chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
623
+			chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
624
+			chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
625
+			chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
626
+			chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
627
+			chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
628
+			chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
629
+			chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
630
+			chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
631
+			chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
632
+			chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
633
+			chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
634
+			chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
635
+			chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
636
+			chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
637
+			chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
638
+			chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
639
+			chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
640
+			chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
641
+			chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
642
+			chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
643
+			chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
644
+			chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
645
+			chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
646
+			chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
647
+			chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
648
+			chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
649
+			chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
650
+			chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
651
+			chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
652
+			chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
653
+			chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
654
+			chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
655
+			chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
656
+			chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
657
+			chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
658
+			chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
659
+			chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
660
+			chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
661
+			chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
662
+			chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
663
+			chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
664
+			chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
665
+			chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
666
+			chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
667
+			chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
668
+			chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
669
+			chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
670
+			chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
671
+			chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
672
+			chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
673
+			chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
674
+			chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
675
+			chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
676
+			chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
677
+			chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
678 678
 		);
679 679
 		$string = strtr($string, $chars);
680 680
 		return $string;
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
 			$dfX = $first_pass[$j][0];
816 816
 			$dfDiffLong = abs($dfX - $dfPrevX);
817 817
 			if ($dfDiffLong > $dfDiffSpace &&
818
-			    (($dfX > $dfLeftBorderX && $dfPrevX < $dfRightBorderX) || ($dfPrevX > $dfLeftBorderX && $dfX < $dfRightBorderX))) 
818
+				(($dfX > $dfLeftBorderX && $dfPrevX < $dfRightBorderX) || ($dfPrevX > $dfLeftBorderX && $dfX < $dfRightBorderX))) 
819 819
 			{
820 820
 				$bHasBigDiff = true;
821 821
 			} else if ($dfDiffLong > $dfMaxSmallDiffLong) {
@@ -835,8 +835,8 @@  discard block
 block discarded – undo
835 835
 					$dfX2 = floatval($first_pass[$k][0]);
836 836
 					$dfY2 = floatval($first_pass[$k][1]);
837 837
 					if ($dfX1 > -180 && $dfX1 < $dfRightBorderX && $dfX2 == 180 &&
838
-					    $k+1 < count($first_pass) &&
839
-					    $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
838
+						$k+1 < count($first_pass) &&
839
+						$first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
840 840
 					{
841 841
 						$poNewLS[] = array(-180, $first_pass[$k][1]);
842 842
 						$k++;
@@ -844,8 +844,8 @@  discard block
 block discarded – undo
844 844
 						$poNewLS[] = array($first_pass[$k][0], $first_pass[$k][1]);
845 845
 						continue;
846 846
 					} else if ($dfX1 > $dfLeftBorderX && $dfX1 < 180 && $dfX2 == -180 &&
847
-					    $k+1 < $first_pass_ln &&
848
-					    $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
847
+						$k+1 < $first_pass_ln &&
848
+						$first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
849 849
 					{
850 850
 						$poNewLS[] = array(180, $first_pass[$k][1]);
851 851
 						$k++;
Please login to merge, or discard this patch.
Spacing   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
 	* @param Array $headers header to submit with the form
15 15
 	* @return String the result
16 16
 	*/
17
-	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '', $sizelimit = false, $async = false, $getheaders = false) {
17
+	public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '', $sizelimit = false, $async = false, $getheaders = false) {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
20 20
 		curl_setopt($ch, CURLOPT_URL, $url);
21 21
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
22
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
22
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
23 23
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
24 24
 			}
25 25
 		}
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
31 31
 		curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
32 32
 		if ($getheaders) curl_setopt($ch, CURLOPT_HEADER, 1); 
33
-		curl_setopt($ch,CURLOPT_ENCODING , "gzip");
33
+		curl_setopt($ch, CURLOPT_ENCODING, "gzip");
34 34
 		//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');
35 35
 //		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0');
36 36
 		if ($useragent == '') {
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 			if (is_array($data)) {
47 47
 				curl_setopt($ch, CURLOPT_POST, count($data));
48 48
 				$data_string = '';
49
-				foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
49
+				foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
50 50
 				rtrim($data_string, '&');
51 51
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
52 52
 			} else {
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		}
59 59
 		if ($cookie != '') {
60 60
 			if (is_array($cookie)) {
61
-				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';'));
61
+				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';'));
62 62
 			} else {
63 63
 				curl_setopt($ch, CURLOPT_COOKIE, $cookie);
64 64
 			}
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		if ($sizelimit === true) {
70 70
 			curl_setopt($ch, CURLOPT_BUFFERSIZE, 128);
71 71
 			curl_setopt($ch, CURLOPT_NOPROGRESS, false);
72
-			curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr,$downloadsize, $downloaded, $uploadsize, $uploaded){
72
+			curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr, $downloadsize, $downloaded, $uploadsize, $uploaded) {
73 73
 				return ($downloaded > (3*1024)) ? 1 : 0;
74 74
 			});
75 75
 		}
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
 		$result = curl_exec($ch);
81 81
 		$info = curl_getinfo($ch);
82 82
 		curl_close($ch);
83
-		if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) {
83
+		if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) {
84 84
 			echo "Cloudflare Detected\n";
85 85
 			require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php');
86 86
 			$useragent = UAgent::random();
87 87
 			cloudflare::useUserAgent($useragent);
88 88
 			if ($clearanceCookie = cloudflare::bypass($url)) {
89
-				return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent);
89
+				return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent);
90 90
 			}
91 91
 		} else {
92 92
 			return $result;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
112 112
 		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
113 113
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
114
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
114
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
115 115
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
116 116
 			}
117 117
 		}
@@ -126,20 +126,20 @@  discard block
 block discarded – undo
126 126
 		fclose($fp);
127 127
 	}
128 128
 
129
-	public static function gunzip($in_file,$out_file_name = '') {
129
+	public static function gunzip($in_file, $out_file_name = '') {
130 130
 		//echo $in_file.' -> '.$out_file_name."\n";
131 131
 		$buffer_size = 4096; // read 4kb at a time
132 132
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
133 133
 		if ($in_file != '' && file_exists($in_file)) {
134 134
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
135
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
136
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
135
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
136
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
137 137
 			else {
138 138
 				echo 'gzopen not available';
139 139
 				die;
140 140
 			}
141 141
 			$out_file = fopen($out_file_name, 'wb'); 
142
-			while(!gzeof($file)) {
142
+			while (!gzeof($file)) {
143 143
 				fwrite($out_file, gzread($file, $buffer_size));
144 144
 			}  
145 145
 			fclose($out_file);
@@ -147,19 +147,19 @@  discard block
 block discarded – undo
147 147
 		}
148 148
 	}
149 149
 
150
-	public static function bunzip2($in_file,$out_file_name = '') {
150
+	public static function bunzip2($in_file, $out_file_name = '') {
151 151
 		//echo $in_file.' -> '.$out_file_name."\n";
152 152
 		$buffer_size = 4096; // read 4kb at a time
153 153
 		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
154 154
 		if ($in_file != '' && file_exists($in_file)) {
155 155
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
156
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
156
+			if (function_exists('bzopen')) $file = bzopen($in_file, 'rb');
157 157
 			else {
158 158
 				echo 'bzopen not available';
159 159
 				die;
160 160
 			}
161 161
 			$out_file = fopen($out_file_name, 'wb'); 
162
-			while(!feof($file)) {
162
+			while (!feof($file)) {
163 163
 				fwrite($out_file, bzread($file, $buffer_size));
164 164
 			}  
165 165
 			fclose($out_file);
@@ -177,27 +177,27 @@  discard block
 block discarded – undo
177 177
 		if ($data == '') return array();
178 178
 		$html = str_get_html($data);
179 179
 		if ($html === false) return array();
180
-		$tabledata=array();
181
-		foreach($html->find('tr') as $element)
180
+		$tabledata = array();
181
+		foreach ($html->find('tr') as $element)
182 182
 		{
183 183
 			$td = array();
184
-			foreach( $element->find('th') as $row)
184
+			foreach ($element->find('th') as $row)
185 185
 			{
186 186
 				$td [] = trim($row->plaintext);
187 187
 			}
188
-			$td=array_filter($td);
188
+			$td = array_filter($td);
189 189
 			$tabledata[] = $td;
190 190
 
191 191
 			$td = array();
192 192
 			$tdi = array();
193
-			foreach( $element->find('td') as $row)
193
+			foreach ($element->find('td') as $row)
194 194
 			{
195 195
 				$td [] = trim($row->plaintext);
196 196
 				$tdi [] = trim($row->innertext);
197 197
 			}
198
-			$td=array_filter($td);
199
-			$tdi=array_filter($tdi);
200
-			$tabledata[]=array_merge($td,$tdi);
198
+			$td = array_filter($td);
199
+			$tdi = array_filter($tdi);
200
+			$tabledata[] = array_merge($td, $tdi);
201 201
 		}
202 202
 		$html->clear();
203 203
 		unset($html);
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
 	public function text2array($data) {
213 213
 		$html = str_get_html($data);
214 214
 		if ($html === false) return array();
215
-		$tabledata=array();
216
-		foreach($html->find('p') as $element)
215
+		$tabledata = array();
216
+		foreach ($html->find('p') as $element)
217 217
 		{
218 218
 			$tabledata [] = trim($element->plaintext);
219 219
 		}
@@ -233,11 +233,11 @@  discard block
 block discarded – undo
233 233
 	*/
234 234
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
235 235
 		if ($lat == $latc && $lon == $lonc) return 0;
236
-		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
236
+		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc))) + cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon) - floatval($lonc)))))*60*1.1515;
237 237
 		if ($unit == "km") {
238
-			return round($dist * 1.609344);
238
+			return round($dist*1.609344);
239 239
 		} elseif ($unit == "m") {
240
-			return round($dist * 1.609344 * 1000);
240
+			return round($dist*1.609344*1000);
241 241
 		} elseif ($unit == "mile" || $unit == "mi") {
242 242
 			return round($dist);
243 243
 		} elseif ($unit == "nm") {
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
 	* @param String $distance distance between two points in m
255 255
 	* @return Float plunge
256 256
 	*/
257
-	public function plunge($initial_altitude,$final_altitude,$distance) {
258
-		$plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance));
257
+	public function plunge($initial_altitude, $final_altitude, $distance) {
258
+		$plunge = rad2deg(asin(($final_altitude - $initial_altitude)/$distance));
259 259
 		/*
260 260
 		$siter = 6378137.0 + $initial_altitude;
261 261
 		$planer = 6378137.0 + $final_altitude;
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 	public function azimuth($lat, $lon, $latc, $lonc) {
278 278
 		$dX = $latc - $lat;
279 279
 		$dY = $lonc - $lon;
280
-		$azimuth = rad2deg(atan2($dY,$dX));
281
-		if ($azimuth < 0) return $azimuth+360;
280
+		$azimuth = rad2deg(atan2($dY, $dX));
281
+		if ($azimuth < 0) return $azimuth + 360;
282 282
 		return $azimuth;
283 283
 	}
284 284
 	
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	* @param float $distance distance covered
290 290
 	* @return whether distance is realistic
291 291
 	*/
292
-	public function withinThreshold ($timeDifference, $distance) {
292
+	public function withinThreshold($timeDifference, $distance) {
293 293
 		$x = abs($timeDifference);
294 294
 		$d = abs($distance);
295 295
 		if ($x == 0 || $d == 0) return true;
@@ -305,13 +305,13 @@  discard block
 block discarded – undo
305 305
 		return ($array !== array_values($array));
306 306
 	}
307 307
 
308
-	public function isInteger($input){
308
+	public function isInteger($input) {
309 309
 		//return(ctype_digit(strval($input)));
310
-		return preg_match('/^-?[0-9]+$/', (string)$input) ? true : false;
310
+		return preg_match('/^-?[0-9]+$/', (string) $input) ? true : false;
311 311
 	}
312 312
 
313 313
 
314
-	public function convertDec($dms,$latlong) {
314
+	public function convertDec($dms, $latlong) {
315 315
 		if ($latlong == 'latitude') {
316 316
 			$deg = substr($dms, 0, 2);
317 317
 			$min = substr($dms, 2, 4);
@@ -319,33 +319,33 @@  discard block
 block discarded – undo
319 319
 			$deg = substr($dms, 0, 3);
320 320
 			$min = substr($dms, 3, 5);
321 321
 		}
322
-		return $deg+(($min*60)/3600);
322
+		return $deg + (($min*60)/3600);
323 323
 	}
324 324
 	
325 325
 	public function convertDecLatLong($coord) {
326 326
 		//N43°36.763' W5°46.845'
327
-		$coords = explode(' ',$coord);
327
+		$coords = explode(' ', $coord);
328 328
 		$latitude = '';
329 329
 		$longitude = '';
330 330
 		foreach ($coords as $latlong) {
331
-			$type = substr($latlong,0,1);
332
-			$degmin = explode('°',substr($latlong,1,-1));
331
+			$type = substr($latlong, 0, 1);
332
+			$degmin = explode('°', substr($latlong, 1, -1));
333 333
 			$deg = $degmin[0];
334 334
 			$min = $degmin[1];
335 335
 			if ($type == 'N') {
336
-				$latitude = $deg+(($min*60)/3600);
336
+				$latitude = $deg + (($min*60)/3600);
337 337
 			} elseif ($type == 'S') {
338
-				$latitude = -($deg+(($min*60)/3600));
338
+				$latitude = -($deg + (($min*60)/3600));
339 339
 			} elseif ($type == 'E') {
340
-				$longitude = ($deg+(($min*60)/3600));
340
+				$longitude = ($deg + (($min*60)/3600));
341 341
 			} elseif ($type == 'W') {
342
-				$longitude = -($deg+(($min*60)/3600));
342
+				$longitude = -($deg + (($min*60)/3600));
343 343
 			}
344 344
 		}
345
-		return array('latitude' => round($latitude,5),'longitude' => round($longitude,5));
345
+		return array('latitude' => round($latitude, 5), 'longitude' => round($longitude, 5));
346 346
 	}
347 347
 	
348
-	public function convertDM($coord,$latlong) {
348
+	public function convertDM($coord, $latlong) {
349 349
 		if ($latlong == 'latitude') {
350 350
 			if ($coord < 0) $NSEW = 'S';
351 351
 			else $NSEW = 'N';
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
 		}
356 356
 		$coord = abs($coord);
357 357
 		$deg = floor($coord);
358
-		$coord = ($coord-$deg)*60;
358
+		$coord = ($coord - $deg)*60;
359 359
 		$min = $coord;
360
-		return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW);
360
+		return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW);
361 361
 	}
362 362
 	
363 363
 	/**
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
 	public function xcopy($source, $dest)
370 370
 	{
371 371
 		$files = glob($source.'*.*');
372
-		foreach($files as $file){
373
-			$file_to_go = str_replace($source,$dest,$file);
372
+		foreach ($files as $file) {
373
+			$file_to_go = str_replace($source, $dest, $file);
374 374
 			copy($file, $file_to_go);
375 375
 		}
376 376
 		return true;
@@ -381,9 +381,9 @@  discard block
 block discarded – undo
381 381
 	* @param	String $url url to check
382 382
 	* @return	bool Return true on succes false on failure
383 383
 	*/
384
-	public function urlexist($url){
385
-		$headers=get_headers($url);
386
-		return stripos($headers[0],"200 OK")?true:false;
384
+	public function urlexist($url) {
385
+		$headers = get_headers($url);
386
+		return stripos($headers[0], "200 OK") ?true:false;
387 387
 	}
388 388
 	
389 389
 	/**
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 	public function hex2str($hex) {
395 395
 		$str = '';
396 396
 		$hexln = strlen($hex);
397
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
397
+		for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2)));
398 398
 		return $str;
399 399
 	}
400 400
 	
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 	* @return	String Return result
405 405
 	*/
406 406
 	public function hex2rgb($hex) {
407
-		$hex = str_replace('#','',$hex);
407
+		$hex = str_replace('#', '', $hex);
408 408
 		return sscanf($hex, "%02x%02x%02x"); 
409 409
 	}
410 410
 	
@@ -412,33 +412,33 @@  discard block
 block discarded – undo
412 412
 		//difference in longitudinal coordinates
413 413
 		$dLon = deg2rad($lon2) - deg2rad($lon1);
414 414
 		//difference in the phi of latitudinal coordinates
415
-		$dPhi = log(tan(deg2rad($lat2) / 2 + M_PI / 4) / tan(deg2rad($lat1) / 2 + M_PI / 4));
415
+		$dPhi = log(tan(deg2rad($lat2)/2 + M_PI/4)/tan(deg2rad($lat1)/2 + M_PI/4));
416 416
 		//we need to recalculate $dLon if it is greater than pi
417
-		if(abs($dLon) > M_PI) {
418
-			if($dLon > 0) {
419
-				$dLon = (2 * M_PI - $dLon) * -1;
417
+		if (abs($dLon) > M_PI) {
418
+			if ($dLon > 0) {
419
+				$dLon = (2*M_PI - $dLon)*-1;
420 420
 			} else {
421
-				$dLon = 2 * M_PI + $dLon;
421
+				$dLon = 2*M_PI + $dLon;
422 422
 			}
423 423
 		}
424 424
 		//return the angle, normalized
425
-		return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360;
425
+		return (rad2deg(atan2($dLon, $dPhi)) + 360)%360;
426 426
 	}
427 427
 
428
-	public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.15) {
428
+	public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.15) {
429 429
 		//$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1);
430
-		$a = -($lon2-$lon1);
430
+		$a = -($lon2 - $lon1);
431 431
 		$b = $lat2 - $lat1;
432
-		$c = -($a*$lat1+$b*$lon1);
433
-		$d = $a*$lat3+$b*$lon3+$c;
432
+		$c = -($a*$lat1 + $b*$lon1);
433
+		$d = $a*$lat3 + $b*$lon3 + $c;
434 434
 		if ($d > -$approx && $d < $approx) return true;
435 435
 		else return false;
436 436
 	}
437 437
 	
438 438
 	public function array_merge_noappend() {
439 439
 		$output = array();
440
-		foreach(func_get_args() as $array) {
441
-			foreach($array as $key => $value) {
440
+		foreach (func_get_args() as $array) {
441
+			foreach ($array as $key => $value) {
442 442
 				$output[$key] = isset($output[$key]) ?
443 443
 				array_merge($output[$key], $value) : $value;
444 444
 			}
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 		return $result;
503 503
 	}
504 504
 
505
-	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = ''){
505
+	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = '') {
506 506
 		global $globalMapRefresh;
507 507
 		if ($seconds == '') {
508 508
 			$distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000;
@@ -513,27 +513,27 @@  discard block
 block discarded – undo
513 513
 		$latitude = deg2rad($latitude);
514 514
 		$longitude = deg2rad($longitude);
515 515
 		$bearing = deg2rad($heading); 
516
-		$latitude2 =  asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) );
517
-		$longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) );
518
-		return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.',''));
516
+		$latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing)));
517
+		$longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2)));
518
+		return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', ''));
519 519
 	}
520 520
 	
521
-	public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) {
521
+	public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) {
522 522
 		// distance in meter
523 523
 		$R = 6378.14;
524
-		$latitude1 = $latitude * (M_PI/180);
525
-		$longitude1 = $longitude * (M_PI/180);
526
-		$brng = $bearing * (M_PI/180);
524
+		$latitude1 = $latitude*(M_PI/180);
525
+		$longitude1 = $longitude*(M_PI/180);
526
+		$brng = $bearing*(M_PI/180);
527 527
 		$d = $distance;
528 528
 
529 529
 		$latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng));
530
-		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2));
530
+		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2));
531 531
 
532
-		$latitude2 = $latitude2 * (180/M_PI);
533
-		$longitude2 = $longitude2 * (180/M_PI);
532
+		$latitude2 = $latitude2*(180/M_PI);
533
+		$longitude2 = $longitude2*(180/M_PI);
534 534
 
535
-		$flat = round ($latitude2,6);
536
-		$flong = round ($longitude2,6);
535
+		$flat = round($latitude2, 6);
536
+		$flong = round($longitude2, 6);
537 537
 /*
538 538
 		$dx = $distance*cos($bearing);
539 539
 		$dy = $distance*sin($bearing);
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 		$flong = $longitude + $dlong;
543 543
 		$flat = $latitude + $dlat;
544 544
 */
545
-		return array('latitude' => $flat,'longitude' => $flong);
545
+		return array('latitude' => $flat, 'longitude' => $flong);
546 546
 	}
547 547
 
548 548
 	/**
@@ -556,14 +556,14 @@  discard block
 block discarded – undo
556 556
 	 * @param integer $level GZIP compression level (default: 9)
557 557
 	 * @return string New filename (with .gz appended) if success, or false if operation fails
558 558
 	 */
559
-	public function gzCompressFile($source, $level = 9){ 
560
-		$dest = $source . '.gz'; 
561
-		$mode = 'wb' . $level; 
559
+	public function gzCompressFile($source, $level = 9) { 
560
+		$dest = $source.'.gz'; 
561
+		$mode = 'wb'.$level; 
562 562
 		$error = false; 
563 563
 		if ($fp_out = gzopen($dest, $mode)) { 
564
-			if ($fp_in = fopen($source,'rb')) { 
564
+			if ($fp_in = fopen($source, 'rb')) { 
565 565
 				while (!feof($fp_in)) 
566
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
566
+					gzwrite($fp_out, fread($fp_in, 1024*512)); 
567 567
 				fclose($fp_in); 
568 568
 			} else {
569 569
 				$error = true; 
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 	} 
580 580
 	
581 581
 	public function remove_accents($string) {
582
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
582
+		if (!preg_match('/[\x80-\xff]/', $string)) return $string;
583 583
 		$chars = array(
584 584
 		    // Decompositions for Latin-1 Supplement
585 585
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
637 637
 		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
638 638
 		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
639
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
639
+		    chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij',
640 640
 		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
641 641
 		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
642 642
 		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
@@ -652,13 +652,13 @@  discard block
 block discarded – undo
652 652
 		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
653 653
 		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
654 654
 		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
655
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
656
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
657
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
658
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
659
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
660
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
661
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
655
+		    chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
656
+		    chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
657
+		    chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
658
+		    chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
659
+		    chr(197).chr(154) => 'S', chr(197).chr(155) => 's',
660
+		    chr(197).chr(156) => 'S', chr(197).chr(157) => 's',
661
+		    chr(197).chr(158) => 'S', chr(197).chr(159) => 's',
662 662
 		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
663 663
 		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
664 664
 		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 		for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) {
693 693
 			if (is_numeric($string[$i]) && $concat_flag) {
694 694
 				$int .= $string[$i];
695
-			} elseif(!$concat && $concat_flag && strlen($int) > 0) {
695
+			} elseif (!$concat && $concat_flag && strlen($int) > 0) {
696 696
 				$concat_flag = false;
697 697
 			}
698 698
 		}
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 			$slice = array_slice($arr, $offset + 1, $length);
739 739
 			return implode("", $slice);
740 740
 		} else {
741
-			return mb_substr($string,$offset,$length,'UTF-8');
741
+			return mb_substr($string, $offset, $length, 'UTF-8');
742 742
 		}
743 743
 	}
744 744
 
@@ -748,14 +748,14 @@  discard block
 block discarded – undo
748 748
 		//NOTE: use a trailing slash for folders!!!
749 749
 		//see http://bugs.php.net/bug.php?id=27609
750 750
 		//see http://bugs.php.net/bug.php?id=30931
751
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
751
+		if ($path{strlen($path) - 1} == '/') // recursively return a temporary file path
752 752
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
753 753
 		else if (is_dir($path))
754 754
 			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
755 755
 		// check tmp file for read/write capabilities
756 756
 		$rm = file_exists($path);
757 757
 		$f = @fopen($path, 'a');
758
-		if ($f===false)
758
+		if ($f === false)
759 759
 			return false;
760 760
 		fclose($f);
761 761
 		if (!$rm)
@@ -774,29 +774,29 @@  discard block
 block discarded – undo
774 774
 	 * @param Integer $offset Controls the likelyhood that lines will be split which cross the dateline
775 775
 	 * @return Array Coordinate of the route
776 776
 	*/
777
-	public function greatcircle($begin_lat,$begin_lon,$end_lat,$end_lon,$nbpts = 20, $offset = 10) {
778
-		if ($nbpts <= 2) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
777
+	public function greatcircle($begin_lat, $begin_lon, $end_lat, $end_lon, $nbpts = 20, $offset = 10) {
778
+		if ($nbpts <= 2) return array(array($begin_lon, $begin_lat), array($end_lon, $end_lat));
779 779
 		$sx = deg2rad($begin_lon);
780 780
 		$sy = deg2rad($begin_lat);
781 781
 		$ex = deg2rad($end_lon);
782 782
 		$ey = deg2rad($end_lat);
783 783
 		$w = $sx - $ex;
784 784
 		$h = $sy - $ey;
785
-		$z = pow(sin($h/2.0),2) + cos($sy)*cos($ey)*pow(sin($w/2.0),2);
785
+		$z = pow(sin($h/2.0), 2) + cos($sy)*cos($ey)*pow(sin($w/2.0), 2);
786 786
 		$g = 2.0*asin(sqrt($z));
787
-		if ($g == M_PI || is_nan($g)) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
787
+		if ($g == M_PI || is_nan($g)) return array(array($begin_lon, $begin_lat), array($end_lon, $end_lat));
788 788
 		$first_pass = array();
789
-		$delta = 1.0/($nbpts-1);
790
-		for ($i =0; $i < $nbpts; ++$i) {
789
+		$delta = 1.0/($nbpts - 1);
790
+		for ($i = 0; $i < $nbpts; ++$i) {
791 791
 			$step = $delta*$i;
792
-			$A = sin((1 - $step) * $g) / sin($g);
793
-			$B = sin($step * $g) / sin($g);
794
-			$x = $A * cos($sy) * cos($sx) + $B * cos($ey) * cos($ex);
795
-			$y = $A * cos($sy) * sin($sx) + $B * cos($ey) * sin($ex);
796
-			$z = $A * sin($sy) + $B * sin($ey);
792
+			$A = sin((1 - $step)*$g)/sin($g);
793
+			$B = sin($step*$g)/sin($g);
794
+			$x = $A*cos($sy)*cos($sx) + $B*cos($ey)*cos($ex);
795
+			$y = $A*cos($sy)*sin($sx) + $B*cos($ey)*sin($ex);
796
+			$z = $A*sin($sy) + $B*sin($ey);
797 797
 			$lat = rad2deg(atan2($z, sqrt(pow($x, 2) + pow($y, 2))));
798 798
 			$lon = rad2deg(atan2($y, $x));
799
-			$first_pass[] = array($lon,$lat);
799
+			$first_pass[] = array($lon, $lat);
800 800
 		}
801 801
 		$bHasBigDiff = false;
802 802
 		$dfMaxSmallDiffLong = 0;
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
 		// https://github.com/OSGeo/gdal/blob/7bfb9c452a59aac958bff0c8386b891edf8154ca/gdal/ogr/ogrgeometryfactory.cpp#L2342
812 812
 		$first_pass_ln = count($first_pass);
813 813
 		for ($j = 1; $j < $first_pass_ln; ++$j) {
814
-			$dfPrevX = $first_pass[$j-1][0];
814
+			$dfPrevX = $first_pass[$j - 1][0];
815 815
 			$dfX = $first_pass[$j][0];
816 816
 			$dfDiffLong = abs($dfX - $dfPrevX);
817 817
 			if ($dfDiffLong > $dfDiffSpace &&
@@ -829,14 +829,14 @@  discard block
 block discarded – undo
829 829
 			//$poMulti[] = $poNewLS;
830 830
 			for ($k = 0; $k < $first_pass_ln; ++$k) {
831 831
 				$dfX0 = floatval($first_pass[$k][0]);
832
-				if ($k > 0 &&  abs($dfX0 - $first_pass[$k-1][0]) > $dfDiffSpace) {
833
-					$dfX1 = floatval($first_pass[$k-1][0]);
834
-					$dfY1 = floatval($first_pass[$k-1][1]);
832
+				if ($k > 0 && abs($dfX0 - $first_pass[$k - 1][0]) > $dfDiffSpace) {
833
+					$dfX1 = floatval($first_pass[$k - 1][0]);
834
+					$dfY1 = floatval($first_pass[$k - 1][1]);
835 835
 					$dfX2 = floatval($first_pass[$k][0]);
836 836
 					$dfY2 = floatval($first_pass[$k][1]);
837 837
 					if ($dfX1 > -180 && $dfX1 < $dfRightBorderX && $dfX2 == 180 &&
838
-					    $k+1 < count($first_pass) &&
839
-					    $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
838
+					    $k + 1 < count($first_pass) &&
839
+					    $first_pass[$k - 1][0] > -180 && $first_pass[$k - 1][0] < $dfRightBorderX)
840 840
 					{
841 841
 						$poNewLS[] = array(-180, $first_pass[$k][1]);
842 842
 						$k++;
@@ -844,8 +844,8 @@  discard block
 block discarded – undo
844 844
 						$poNewLS[] = array($first_pass[$k][0], $first_pass[$k][1]);
845 845
 						continue;
846 846
 					} else if ($dfX1 > $dfLeftBorderX && $dfX1 < 180 && $dfX2 == -180 &&
847
-					    $k+1 < $first_pass_ln &&
848
-					    $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
847
+					    $k + 1 < $first_pass_ln &&
848
+					    $first_pass[$k - 1][0] > $dfLeftBorderX && $first_pass[$k - 1][0] < 180)
849 849
 					{
850 850
 						$poNewLS[] = array(180, $first_pass[$k][1]);
851 851
 						$k++;
@@ -868,12 +868,12 @@  discard block
 block discarded – undo
868 868
 					}
869 869
 					if ($dfX1 <= 180 && $dfX2 >= 180 && $dfX1 < $dfX2)
870 870
 					{
871
-						$dfRatio = (180 - $dfX1) / ($dfX2 - $dfX1);
872
-						$dfY = $dfRatio * $dfY2 + (1 - $dfRatio) * $dfY1;
873
-						$poNewLS[] = array($first_pass[$k-1][0] > $dfLeftBorderX ? 180 : -180, $dfY);
871
+						$dfRatio = (180 - $dfX1)/($dfX2 - $dfX1);
872
+						$dfY = $dfRatio*$dfY2 + (1 - $dfRatio)*$dfY1;
873
+						$poNewLS[] = array($first_pass[$k - 1][0] > $dfLeftBorderX ? 180 : -180, $dfY);
874 874
 						$poMulti[] = $poNewLS;
875 875
 						$poNewLS = array();
876
-						$poNewLS[] = array($first_pass[$k-1][0] > $dfLeftBorderX ? -180 : 180, $dfY);
876
+						$poNewLS[] = array($first_pass[$k - 1][0] > $dfLeftBorderX ? -180 : 180, $dfY);
877 877
 						//$poMulti[] = $poNewLS;
878 878
 					} else {
879 879
 						//$poNewLS[] = array();
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 			$poNewLS0 = array();
892 892
 			//$poMulti[] = $poNewLS0;
893 893
 			for ($l = 0; $l < $first_pass_ln; ++$l) {
894
-				$poNewLS0[] = array($first_pass[$l][0],$first_pass[$l][1]);
894
+				$poNewLS0[] = array($first_pass[$l][0], $first_pass[$l][1]);
895 895
 			}
896 896
 			$poMulti[] = $poNewLS0;
897 897
 		}
Please login to merge, or discard this patch.
Braces   +113 added lines, -49 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
30 30
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
31 31
 		curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
32
-		if ($getheaders) curl_setopt($ch, CURLOPT_HEADER, 1); 
32
+		if ($getheaders) {
33
+			curl_setopt($ch, CURLOPT_HEADER, 1);
34
+		}
33 35
 		curl_setopt($ch,CURLOPT_ENCODING , "gzip");
34 36
 		//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');
35 37
 //		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0');
@@ -38,8 +40,11 @@  discard block
 block discarded – undo
38 40
 		} else {
39 41
 			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
40 42
 		}
41
-		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
42
-		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
43
+		if ($timeout == '') {
44
+			curl_setopt($ch, CURLOPT_TIMEOUT, 10);
45
+		} else {
46
+			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
47
+		}
43 48
 		//curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
44 49
 		if ($type == 'post') {
45 50
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@@ -52,7 +57,9 @@  discard block
 block discarded – undo
52 57
 			} else {
53 58
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
54 59
 			}
55
-		} elseif ($type != 'get' && $type != '') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
60
+		} elseif ($type != 'get' && $type != '') {
61
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
62
+		}
56 63
 		if ($headers != '') {
57 64
 			curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
58 65
 		}
@@ -96,8 +103,9 @@  discard block
 block discarded – undo
96 103
 	private function curlResponseHeaderCallback($ch, $headerLine) {
97 104
 		global $curl_cookies;
98 105
 		$curl_cookies = array();
99
-		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
100
-			$curl_cookies[] = $cookie;
106
+		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
107
+					$curl_cookies[] = $cookie;
108
+		}
101 109
 		return strlen($headerLine); // Needed by curl
102 110
 	}
103 111
 
@@ -109,7 +117,9 @@  discard block
 block discarded – undo
109 117
 		curl_setopt($ch, CURLOPT_URL, $url);
110 118
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
111 119
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
112
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
120
+		if ($referer != '') {
121
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
122
+		}
113 123
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
114 124
 			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
115 125
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
@@ -121,7 +131,9 @@  discard block
 block discarded – undo
121 131
 		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');
122 132
 		curl_setopt($ch, CURLOPT_FILE, $fp);
123 133
 		curl_exec($ch);
124
-		if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch);
134
+		if (curl_errno($ch) && $globalDebug) {
135
+			echo 'Download error: '.curl_error($ch);
136
+		}
125 137
 		curl_close($ch);
126 138
 		fclose($fp);
127 139
 	}
@@ -129,12 +141,16 @@  discard block
 block discarded – undo
129 141
 	public static function gunzip($in_file,$out_file_name = '') {
130 142
 		//echo $in_file.' -> '.$out_file_name."\n";
131 143
 		$buffer_size = 4096; // read 4kb at a time
132
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
144
+		if ($out_file_name == '') {
145
+			$out_file_name = str_replace('.gz', '', $in_file);
146
+		}
133 147
 		if ($in_file != '' && file_exists($in_file)) {
134 148
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
135
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
136
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
137
-			else {
149
+			if (function_exists('gzopen')) {
150
+				$file = gzopen($in_file,'rb');
151
+			} elseif (function_exists('gzopen64')) {
152
+				$file = gzopen64($in_file,'rb');
153
+			} else {
138 154
 				echo 'gzopen not available';
139 155
 				die;
140 156
 			}
@@ -150,11 +166,14 @@  discard block
 block discarded – undo
150 166
 	public static function bunzip2($in_file,$out_file_name = '') {
151 167
 		//echo $in_file.' -> '.$out_file_name."\n";
152 168
 		$buffer_size = 4096; // read 4kb at a time
153
-		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
169
+		if ($out_file_name == '') {
170
+			$out_file_name = str_replace('.bz2', '', $in_file);
171
+		}
154 172
 		if ($in_file != '' && file_exists($in_file)) {
155 173
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
156
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
157
-			else {
174
+			if (function_exists('bzopen')) {
175
+				$file = bzopen($in_file,'rb');
176
+			} else {
158 177
 				echo 'bzopen not available';
159 178
 				die;
160 179
 			}
@@ -173,10 +192,16 @@  discard block
 block discarded – undo
173 192
 	* @return Array array of the tables in HTML page
174 193
 	*/
175 194
 	public function table2array($data) {
176
-		if (!is_string($data)) return array();
177
-		if ($data == '') return array();
195
+		if (!is_string($data)) {
196
+			return array();
197
+		}
198
+		if ($data == '') {
199
+			return array();
200
+		}
178 201
 		$html = str_get_html($data);
179
-		if ($html === false) return array();
202
+		if ($html === false) {
203
+			return array();
204
+		}
180 205
 		$tabledata=array();
181 206
 		foreach($html->find('tr') as $element)
182 207
 		{
@@ -211,7 +236,9 @@  discard block
 block discarded – undo
211 236
 	*/
212 237
 	public function text2array($data) {
213 238
 		$html = str_get_html($data);
214
-		if ($html === false) return array();
239
+		if ($html === false) {
240
+			return array();
241
+		}
215 242
 		$tabledata=array();
216 243
 		foreach($html->find('p') as $element)
217 244
 		{
@@ -232,7 +259,9 @@  discard block
 block discarded – undo
232 259
 	* @return Float Distance in $unit
233 260
 	*/
234 261
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
235
-		if ($lat == $latc && $lon == $lonc) return 0;
262
+		if ($lat == $latc && $lon == $lonc) {
263
+			return 0;
264
+		}
236 265
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
237 266
 		if ($unit == "km") {
238 267
 			return round($dist * 1.609344);
@@ -278,7 +307,9 @@  discard block
 block discarded – undo
278 307
 		$dX = $latc - $lat;
279 308
 		$dY = $lonc - $lon;
280 309
 		$azimuth = rad2deg(atan2($dY,$dX));
281
-		if ($azimuth < 0) return $azimuth+360;
310
+		if ($azimuth < 0) {
311
+			return $azimuth+360;
312
+		}
282 313
 		return $azimuth;
283 314
 	}
284 315
 	
@@ -292,10 +323,16 @@  discard block
 block discarded – undo
292 323
 	public function withinThreshold ($timeDifference, $distance) {
293 324
 		$x = abs($timeDifference);
294 325
 		$d = abs($distance);
295
-		if ($x == 0 || $d == 0) return true;
326
+		if ($x == 0 || $d == 0) {
327
+			return true;
328
+		}
296 329
 		// may be due to Internet jitter; distance is realistic
297
-		if ($x < 0.7 && $d < 2000) return true;
298
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
330
+		if ($x < 0.7 && $d < 2000) {
331
+			return true;
332
+		} else {
333
+			return $d/$x < 1500*0.27778;
334
+		}
335
+		// 1500 km/h max
299 336
 	}
300 337
 
301 338
 
@@ -347,11 +384,17 @@  discard block
 block discarded – undo
347 384
 	
348 385
 	public function convertDM($coord,$latlong) {
349 386
 		if ($latlong == 'latitude') {
350
-			if ($coord < 0) $NSEW = 'S';
351
-			else $NSEW = 'N';
387
+			if ($coord < 0) {
388
+				$NSEW = 'S';
389
+			} else {
390
+				$NSEW = 'N';
391
+			}
352 392
 		} else {
353
-			if ($coord < 0) $NSEW = 'W';
354
-			else $NSEW = 'E';
393
+			if ($coord < 0) {
394
+				$NSEW = 'W';
395
+			} else {
396
+				$NSEW = 'E';
397
+			}
355 398
 		}
356 399
 		$coord = abs($coord);
357 400
 		$deg = floor($coord);
@@ -394,7 +437,9 @@  discard block
 block discarded – undo
394 437
 	public function hex2str($hex) {
395 438
 		$str = '';
396 439
 		$hexln = strlen($hex);
397
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
440
+		for($i=0;$i<$hexln;$i+=2) {
441
+			$str .= chr(hexdec(substr($hex,$i,2)));
442
+		}
398 443
 		return $str;
399 444
 	}
400 445
 	
@@ -431,8 +476,11 @@  discard block
 block discarded – undo
431 476
 		$b = $lat2 - $lat1;
432 477
 		$c = -($a*$lat1+$b*$lon1);
433 478
 		$d = $a*$lat3+$b*$lon3+$c;
434
-		if ($d > -$approx && $d < $approx) return true;
435
-		else return false;
479
+		if ($d > -$approx && $d < $approx) {
480
+			return true;
481
+		} else {
482
+			return false;
483
+		}
436 484
 	}
437 485
 	
438 486
 	public function array_merge_noappend() {
@@ -491,7 +539,9 @@  discard block
 block discarded – undo
491 539
 			return $result;
492 540
 		}
493 541
 		$handle = @opendir('./locale');
494
-		if ($handle === false) return $result;
542
+		if ($handle === false) {
543
+			return $result;
544
+		}
495 545
 		while (false !== ($file = readdir($handle))) {
496 546
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
497 547
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -562,8 +612,9 @@  discard block
 block discarded – undo
562 612
 		$error = false; 
563 613
 		if ($fp_out = gzopen($dest, $mode)) { 
564 614
 			if ($fp_in = fopen($source,'rb')) { 
565
-				while (!feof($fp_in)) 
566
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
615
+				while (!feof($fp_in)) {
616
+									gzwrite($fp_out, fread($fp_in, 1024 * 512));
617
+				}
567 618
 				fclose($fp_in); 
568 619
 			} else {
569 620
 				$error = true; 
@@ -572,14 +623,17 @@  discard block
 block discarded – undo
572 623
 		} else {
573 624
 			$error = true; 
574 625
 		}
575
-		if ($error)
576
-			return false; 
577
-		else
578
-			return $dest; 
626
+		if ($error) {
627
+					return false;
628
+		} else {
629
+					return $dest;
630
+		}
579 631
 	} 
580 632
 	
581 633
 	public function remove_accents($string) {
582
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
634
+		if ( !preg_match('/[\x80-\xff]/', $string) ) {
635
+			return $string;
636
+		}
583 637
 		$chars = array(
584 638
 		    // Decompositions for Latin-1 Supplement
585 639
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -703,7 +757,9 @@  discard block
 block discarded – undo
703 757
 		$ip = gethostbyname($host);
704 758
 		$s = socket_create(AF_INET, SOCK_STREAM, 0);
705 759
 		$r = @socket_connect($s, $ip, $port);
706
-		if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
760
+		if (!socket_set_nonblock($s)) {
761
+			echo "Unable to set nonblock on socket\n";
762
+		}
707 763
 		if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
708 764
 			return $s;
709 765
 		}
@@ -748,18 +804,22 @@  discard block
 block discarded – undo
748 804
 		//NOTE: use a trailing slash for folders!!!
749 805
 		//see http://bugs.php.net/bug.php?id=27609
750 806
 		//see http://bugs.php.net/bug.php?id=30931
751
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
807
+		if ($path{strlen($path)-1}=='/') {
808
+			// recursively return a temporary file path
752 809
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
753
-		else if (is_dir($path))
754
-			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
810
+		} else if (is_dir($path)) {
811
+					return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
812
+		}
755 813
 		// check tmp file for read/write capabilities
756 814
 		$rm = file_exists($path);
757 815
 		$f = @fopen($path, 'a');
758
-		if ($f===false)
759
-			return false;
816
+		if ($f===false) {
817
+					return false;
818
+		}
760 819
 		fclose($f);
761
-		if (!$rm)
762
-			unlink($path);
820
+		if (!$rm) {
821
+					unlink($path);
822
+		}
763 823
 		return true;
764 824
 	}
765 825
 	
@@ -775,7 +835,9 @@  discard block
 block discarded – undo
775 835
 	 * @return Array Coordinate of the route
776 836
 	*/
777 837
 	public function greatcircle($begin_lat,$begin_lon,$end_lat,$end_lon,$nbpts = 20, $offset = 10) {
778
-		if ($nbpts <= 2) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
838
+		if ($nbpts <= 2) {
839
+			return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
840
+		}
779 841
 		$sx = deg2rad($begin_lon);
780 842
 		$sy = deg2rad($begin_lat);
781 843
 		$ex = deg2rad($end_lon);
@@ -784,7 +846,9 @@  discard block
 block discarded – undo
784 846
 		$h = $sy - $ey;
785 847
 		$z = pow(sin($h/2.0),2) + cos($sy)*cos($ey)*pow(sin($w/2.0),2);
786 848
 		$g = 2.0*asin(sqrt($z));
787
-		if ($g == M_PI || is_nan($g)) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
849
+		if ($g == M_PI || is_nan($g)) {
850
+			return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
851
+		}
788 852
 		$first_pass = array();
789 853
 		$delta = 1.0/($nbpts-1);
790 854
 		for ($i =0; $i < $nbpts; ++$i) {
Please login to merge, or discard this patch.
require/class.Connection.php 2 patches
Doc Comments   +20 added lines patch added patch discarded remove patch
@@ -6,6 +6,9 @@  discard block
 block discarded – undo
6 6
 	public $dbs = array();
7 7
 	public $latest_schema = 55;
8 8
 
9
+	/**
10
+	 * @param string $dbname
11
+	 */
9 12
 	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
10 13
 		global $globalNoDB;
11 14
 		if (isset($globalNoDB) && $globalNoDB === TRUE) {
@@ -142,6 +145,9 @@  discard block
 block discarded – undo
142 145
 		return true;
143 146
 	}
144 147
 
148
+	/**
149
+	 * @param string $table
150
+	 */
145 151
 	public function tableExists($table)
146 152
 	{
147 153
 		global $globalDBdriver, $globalDBname;
@@ -192,6 +198,11 @@  discard block
 block discarded – undo
192 198
 	/*
193 199
 	* Check if index exist
194 200
 	*/
201
+
202
+	/**
203
+	 * @param string $table
204
+	 * @param string $index
205
+	 */
195 206
 	public function indexExists($table,$index)
196 207
 	{
197 208
 		global $globalDBdriver, $globalDBname;
@@ -234,6 +245,10 @@  discard block
 block discarded – undo
234 245
 		return $columns;
235 246
 	}
236 247
 
248
+	/**
249
+	 * @param string $table
250
+	 * @param string $column
251
+	 */
237 252
 	public function getColumnType($table,$column) {
238 253
 		$select = $this->db->query('SELECT '.$column.' FROM '.$table);
239 254
 		$tomet = $select->getColumnMeta(0);
@@ -244,6 +259,11 @@  discard block
 block discarded – undo
244 259
 	* Check if a column name exist in a table
245 260
 	* @return Boolean column exist or not
246 261
 	*/
262
+
263
+	/**
264
+	 * @param string $table
265
+	 * @param string $name
266
+	 */
247 267
 	public function checkColumnName($table,$name)
248 268
 	{
249 269
 		global $globalDBdriver, $globalDBname;
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/settings.php');
3 3
 
4
-class Connection{
4
+class Connection {
5 5
 	public $db = null;
6 6
 	public $dbs = array();
7 7
 	public $latest_schema = 55;
8 8
 
9
-	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
9
+	public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) {
10 10
 		global $globalNoDB;
11 11
 		if (isset($globalNoDB) && $globalNoDB === TRUE) {
12 12
 			$this->db = null;
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 					if ($user === null && $pass === null) {
17 17
 						$this->createDBConnection();
18 18
 					} else {
19
-						$this->createDBConnection(null,$user,$pass);
19
+						$this->createDBConnection(null, $user, $pass);
20 20
 					}
21 21
 				} else {
22 22
 					$this->createDBConnection($dbname);
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 		while (true) {
101 101
 			try {
102 102
 				if ($globalDBSdriver == 'mysql') {
103
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser,  $globalDBSpass);
103
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass);
104 104
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
105 105
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
106
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
107
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
108
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
109
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
110
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
106
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
107
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500);
108
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
109
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
110
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
111 111
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
112 112
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
113 113
 					// Workaround against "ONLY_FULL_GROUP_BY" mode
@@ -117,19 +117,19 @@  discard block
 block discarded – undo
117 117
 					$this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"');
118 118
 					//$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"');
119 119
 				} else {
120
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser,  $globalDBSpass);
120
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass);
121 121
 					//$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
122 122
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
123
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
124
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
125
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
126
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
127
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
123
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
124
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200);
125
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
126
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
127
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
128 128
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
129 129
 					$this->dbs[$DBname]->exec('SET timezone="UTC"');
130 130
 				}
131 131
 				break;
132
-			} catch(PDOException $e) {
132
+			} catch (PDOException $e) {
133 133
 				$i++;
134 134
 				if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
135 135
 				//exit;
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
 		try {
155 155
 			//$Connection = new Connection();
156 156
 			$results = $this->db->query($query);
157
-		} catch(PDOException $e) {
157
+		} catch (PDOException $e) {
158 158
 			return false;
159 159
 		}
160
-		if($results->rowCount()>0) {
160
+		if ($results->rowCount() > 0) {
161 161
 		    return true; 
162 162
 		}
163 163
 		else return false;
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
 			     return false;
180 180
 			}
181 181
 			
182
-		} catch(PDOException $e) {
183
-			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
182
+		} catch (PDOException $e) {
183
+			if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
184 184
             			throw $e;
185 185
 	                }
186 186
 	                //echo 'error ! '.$e->getMessage();
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	/*
193 193
 	* Check if index exist
194 194
 	*/
195
-	public function indexExists($table,$index)
195
+	public function indexExists($table, $index)
196 196
 	{
197 197
 		global $globalDBdriver, $globalDBname;
198 198
 		if ($globalDBdriver == 'mysql') {
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
 		try {
204 204
 			//$Connection = new Connection();
205 205
 			$results = $this->db->query($query);
206
-		} catch(PDOException $e) {
206
+		} catch (PDOException $e) {
207 207
 			return false;
208 208
 		}
209 209
 		$nb = $results->fetchAll(PDO::FETCH_ASSOC);
210
-		if($nb[0]['nb'] > 0) {
210
+		if ($nb[0]['nb'] > 0) {
211 211
 			return true; 
212 212
 		}
213 213
 		else return false;
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		$query = "SELECT * FROM ".$table." LIMIT 0";
223 223
 		try {
224 224
 			$results = $this->db->query($query);
225
-		} catch(PDOException $e) {
225
+		} catch (PDOException $e) {
226 226
 			return "error : ".$e->getMessage()."\n";
227 227
 		}
228 228
 		$columns = array();
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		return $columns;
235 235
 	}
236 236
 
237
-	public function getColumnType($table,$column) {
237
+	public function getColumnType($table, $column) {
238 238
 		$select = $this->db->query('SELECT '.$column.' FROM '.$table);
239 239
 		$tomet = $select->getColumnMeta(0);
240 240
 		return $tomet['native_type'];
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 	* Check if a column name exist in a table
245 245
 	* @return Boolean column exist or not
246 246
 	*/
247
-	public function checkColumnName($table,$name)
247
+	public function checkColumnName($table, $name)
248 248
 	{
249 249
 		global $globalDBdriver, $globalDBname;
250 250
 		if ($globalDBdriver == 'mysql') {
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
 		}
255 255
 			try {
256 256
 				$sth = $this->db()->prepare($query);
257
-				$sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name));
258
-			} catch(PDOException $e) {
257
+				$sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name));
258
+			} catch (PDOException $e) {
259 259
 				echo "error : ".$e->getMessage()."\n";
260 260
 			}
261 261
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 				try {
295 295
 					$sth = $this->db->prepare($query);
296 296
 					$sth->execute();
297
-				} catch(PDOException $e) {
297
+				} catch (PDOException $e) {
298 298
 					return "error : ".$e->getMessage()."\n";
299 299
 				}
300 300
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
marine-data.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@  discard block
 block discarded – undo
63 63
 {
64 64
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
65 65
 		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
66
-	} else $image = $spotter_item['image_thumbnail'];
66
+	} else {
67
+		$image = $spotter_item['image_thumbnail'];
68
+	}
67 69
 
68 70
 }
69 71
 /* else {
@@ -73,7 +75,9 @@  discard block
 block discarded – undo
73 75
 print '<div class="top">';
74 76
 if (isset($image)) {
75 77
 	print '<div class="left"><img src="'.$image.'" alt="'.$spotter_item['mmsi'].' '.$spotter_item['ident'].'" title="'.$spotter_item['mmsi'].' '.$spotter_item['ident'].' Image &copy; '.$spotter_item['image_copyright'].'"/>';
76
-	if ($spotter_item['image_copyright'] != '') print '<br />Image &copy; '.$spotter_item['image_copyright'];
78
+	if ($spotter_item['image_copyright'] != '') {
79
+		print '<br />Image &copy; '.$spotter_item['image_copyright'];
80
+	}
77 81
 	print '</div>';
78 82
 }
79 83
 //print '<div class="right"><div class="callsign-details"><div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['famtrackid'].'" target="_blank">'.$spotter_item['ident'].'</a></div>';
Please login to merge, or discard this patch.
index.php 1 patch
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     <?php }; if (isset($globalSatellite) && $globalSatellite) { ?><td><div id="ibxsatellite"><h4><?php echo _("Satellites Displayed"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div></td><?php } ?>
56 56
 </tr></table></div>
57 57
 <?php
58
-    if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
58
+	if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
59 59
 ?>
60 60
 <script src="<?php echo $globalURL; ?>/js/map.3d.js.php<?php if (isset($tsk)) print '?tsk='.$tsk; ?>"></script>
61 61
 <?php
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script>
80 80
 <?php
81 81
 	}
82
-    }
82
+	}
83 83
 ?>
84 84
 
85 85
 <div id="sidebar" class="sidebar collapsed">
@@ -90,13 +90,13 @@  discard block
 block discarded – undo
90 90
 	<li><a href="" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li>
91 91
 	<li><a href="" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li>
92 92
 <?php
93
-    //if ((isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') || (isset($globalBeta) && $globalBeta === TRUE)) {
93
+	//if ((isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') || (isset($globalBeta) && $globalBeta === TRUE)) {
94 94
 	if (isset($globalArchive) && $globalArchive == TRUE && (!isset($globalAircraft) || $globalAircraft === TRUE)) {
95 95
 ?>
96 96
 	<li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li>
97 97
 <?php
98 98
 	}
99
-    //}
99
+	//}
100 100
 ?>
101 101
 	<li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li>
102 102
 	<li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li>
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 ?>
111 111
 
112 112
 <?php
113
-    if (isset($globalMap3D) && $globalMap3D) {
113
+	if (isset($globalMap3D) && $globalMap3D) {
114 114
 	if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
115 115
 ?>
116 116
 	<li><a href="" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li>
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	<li><a href="" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li>
121 121
 <?php
122 122
 	}
123
-    }
123
+	}
124 124
 ?>
125 125
     </ul>
126 126
 
@@ -294,15 +294,15 @@  discard block
 block discarded – undo
294 294
 		    </div>
295 295
 		</li>
296 296
 		<?php
297
-		    if (isset($globalDemo) && $globalDemo) {
297
+			if (isset($globalDemo) && $globalDemo) {
298 298
 		?>
299 299
 		<li><button type="button" class="btn btn-primary disabled"><?php echo _("Show archive"); ?></button> Disabled in Demo mode</li>
300 300
 		<?php
301
-		    } else {
301
+			} else {
302 302
 		?>
303 303
 		<li><button type="button" onclick="addarchive(begindate,enddate);" class="btn btn-primary"><?php echo _("Show archive"); ?></button></li>
304 304
 		<?php
305
-		    }
305
+			}
306 306
 		?>
307 307
 	    </ul>
308 308
 	    <ul>
@@ -321,83 +321,83 @@  discard block
 block discarded – undo
321 321
 				if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
322 322
 					if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
323 323
 					else $MapType = $_COOKIE['MapType'];
324
-			    ?>
324
+				?>
325 325
 			<select  class="selectpicker" onchange="mapType(this);">
326 326
 			    <?php
327 327
 				} else {
328 328
 					if (!isset($_COOKIE['MapType3D']) || $_COOKIE['MapType3D'] == '') $MapType = $globalMapProvider;
329 329
 					else $MapType = $_COOKIE['MapType3D'];
330
-			    ?>
330
+				?>
331 331
 			<select  class="selectpicker" onchange="mapType3D(this);">
332 332
 			    <?php
333 333
 				}
334
-			    ?>
334
+				?>
335 335
 			    <?php
336 336
 				if (isset($globalMapOffline) && $globalMapOffline === TRUE) {
337
-			    ?>
337
+				?>
338 338
 			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
339 339
 			    <?php
340 340
 				} else {
341
-				    if (file_exists(dirname(__FILE__).'/js/Cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml')) {
342
-			    ?>
341
+					if (file_exists(dirname(__FILE__).'/js/Cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml')) {
342
+				?>
343 343
 			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
344 344
 			    <?php
345
-				    }
346
-			    ?>
345
+					}
346
+				?>
347 347
 			    <option value="ArcGIS-Streetmap"<?php if ($MapType == 'ArcGIS-Streetmap') print ' selected'; ?>>ArcGIS Streetmap</option>
348 348
 			    <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Satellite') print ' selected'; ?>>ArcGIS Satellite</option>
349 349
 			    <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Ocean') print ' selected'; ?>>ArcGIS Ocean</option>
350 350
 			    <?php
351
-				    if (isset($globalBingMapKey) && $globalBingMapKey != '') {
352
-			    ?>
351
+					if (isset($globalBingMapKey) && $globalBingMapKey != '') {
352
+				?>
353 353
 			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
354 354
 			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
355 355
 			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
356 356
 			    <?php
357
-				    }
358
-			    ?>
357
+					}
358
+				?>
359 359
 			    <?php
360
-				    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
361
-			    ?>
360
+					if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
361
+				?>
362 362
 			    <?php
363 363
 					if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
364
-			    ?>
364
+				?>
365 365
 			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
366 366
 			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
367 367
 			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
368 368
 			    <?php
369 369
 					}
370
-			    ?>
370
+				?>
371 371
 			    <?php
372 372
 					if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
373
-			    ?>
373
+				?>
374 374
 			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
375 375
 			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
376 376
 			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
377 377
 			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
378 378
 			    <?php
379 379
 					}
380
-			    ?>
380
+				?>
381 381
 			    <?php
382 382
 					if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
383
-			    ?>
383
+				?>
384 384
 			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
385 385
 			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
386 386
 			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
387 387
 			    <?php
388 388
 					}
389
-			    ?>
389
+				?>
390 390
 			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
391 391
 			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth</option>
392 392
 			    <?php
393
-				    }
394
-			    ?>
393
+					}
394
+				?>
395 395
 			    <option value="NatGeo-Street"<?php if ($MapType == 'NatGeo-Street') print ' selected'; ?>>National Geographic Street</option>
396 396
 			    <?php
397
-				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
397
+					if (isset($globalMapboxToken) && $globalMapboxToken != '') {
398 398
 					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
399 399
 					else $MapBoxId = $_COOKIE['MapTypeId'];
400
-			    ?>
400
+				?>
401 401
 			    <option value="MapboxGL"<?php if ($MapType == 'MapboxGL') print ' selected'; ?>>Mapbox GL</option>
402 402
 			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
403 403
 			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
@@ -412,16 +412,16 @@  discard block
 block discarded – undo
412 412
 			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
413 413
 			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
414 414
 			    <?php
415
-				    }
416
-			    ?>
415
+					}
416
+				?>
417 417
 			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
418 418
 			    <?php
419 419
 				}
420
-			    ?>
420
+				?>
421 421
 			</select>
422 422
 		    </li>
423 423
 <?php
424
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d' && (!isset($globalMapOffline) || $globalMapOffline === FALSE)) {
424
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d' && (!isset($globalMapOffline) || $globalMapOffline === FALSE)) {
425 425
 ?>
426 426
 		    <li><?php echo _("Type of Terrain:"); ?>
427 427
 			<select  class="selectpicker" onchange="terrainType(this);">
@@ -432,18 +432,18 @@  discard block
 block discarded – undo
432 432
 			</select>
433 433
 		    </li>
434 434
 <?php
435
-    }
435
+	}
436 436
 ?>
437 437
 
438 438
 <?php
439
-    if (isset($globalMap3D) && $globalMap3D) {
439
+	if (isset($globalMap3D) && $globalMap3D) {
440 440
 ?>
441 441
 		    <li><div class="checkbox"><label><input type="checkbox" name="synchro2d3d" value="1" onclick="clickSyncMap2D3D(this)" <?php if (isset($_COOKIE['Map2D3DSync']) && $_COOKIE['Map2D3DSync'] == 'true') print 'checked'; ?> ><?php echo _("Use same type of map for 2D & 3D"); ?></label></div></li>
442 442
 <?php
443
-    }
443
+	}
444 444
 ?>
445 445
 <?php
446
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
446
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
447 447
 ?>
448 448
 		    <li><div class="checkbox"><label><input type="checkbox" name="display2dbuildings" value="1" onclick="clickDisplay2DBuildings(this)" <?php if (isset($_COOKIE['Map2DBuildings']) && $_COOKIE['Map2DBuildings'] == 'true') print 'checked'; ?> ><?php echo _("Display 2.5D buidings on map"); ?></label></div></li>
449 449
 
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 		    <li><div class="checkbox"><label><input type="checkbox" name="satelliteestimation" value="1" onclick="clickSatelliteEstimation(this)" <?php if ((isset($_COOKIE['satelliteestimation']) && $_COOKIE['satelliteestimation'] == 'true') || (!isset($_COOKIE['satelliteestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['satelliteestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Satellites animate between updates"); ?></label></div></li>
467 467
 <?php
468 468
 	}
469
-    }
469
+	}
470 470
 ?>
471 471
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true' || !isset($_COOKIE['displayairports'])) print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
472 472
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) print 'checked'; ?> ><?php echo _("Display ground station on map"); ?></label></div></li>
@@ -485,82 +485,82 @@  discard block
 block discarded – undo
485 485
 	}
486 486
 ?>
487 487
 <?php
488
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
488
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
489 489
 ?>
490 490
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
491 491
 		    <li><div class="checkbox"><label><input type="checkbox" name="shadows" value="1" onclick="clickShadows(this)" <?php if ((!isset($_COOKIE['map3dnoshadows']) && (!isset($globalMap3DShadows) || $globalMap3DShadows)) || (isset($_COOKIE['map3dnoshadows']) && $_COOKIE['map3dnoshadows'] == 'false')) print 'checked'; ?> ><?php echo _("Use shadows"); ?></label></div></li>
492 492
 		    <li><div class="checkbox"><label><input type="checkbox" name="one3dmodel" value="1" onclick="useOne3Dmodel(this)" <?php if ((isset($_COOKIE['one3dmodel']) && $_COOKIE['one3dmodel'] == 'true') || (!isset($_COOKIE['one3dmodel']) && isset($globalMap3DOneModel) && $globalMap3DOneModel)) print 'checked'; ?> ><?php echo _("Use same 3D model for all aircraft (use fewer resources)"); ?></label></div></li>
493 493
 		    <li><div class="checkbox"><label><input type="checkbox" name="updaterealtime" value="1" onclick="clickUpdateRealtime(this)" <?php if ((isset($_COOKIE['updaterealtime']) && $_COOKIE['updaterealtime'] == 'true') || !isset($_COOKIE['updaterealtime'])) print 'checked'; ?> ><?php echo _("Display realtime data in infobox"); ?></label></div></li>
494 494
 <?php
495
-    }
496
-    if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
495
+	}
496
+	if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
497 497
 ?>
498 498
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li>
499 499
 <?php
500
-    }
500
+	}
501 501
 ?>
502 502
 		    <?php
503 503
 			if (function_exists('array_column')) {
504
-			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
505
-		    ?>
504
+				if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
505
+			?>
506 506
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
507 507
 		    <?php
508
-			    }
508
+				}
509 509
 			} elseif (isset($globalSources)) {
510
-			    $dispolar = false;
511
-			    foreach ($globalSources as $testsource) {
512
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
513
-			    }
514
-			    if ($dispolar) {
515
-		    ?>
510
+				$dispolar = false;
511
+				foreach ($globalSources as $testsource) {
512
+					if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
513
+				}
514
+				if ($dispolar) {
515
+			?>
516 516
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
517 517
 		    <?php
518
-			    }
519
-		        }
520
-		    ?>
518
+				}
519
+				}
520
+			?>
521 521
 <?php
522
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
522
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
523 523
 ?>
524 524
 
525 525
 		    <?php
526 526
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
527
-		    	    if (extension_loaded('gd') && function_exists('gd_info')) {
528
-		    ?>
527
+					if (extension_loaded('gd') && function_exists('gd_info')) {
528
+			?>
529 529
 		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
530 530
 		    <?php 
531 531
 				if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
532
-		    ?>
532
+			?>
533 533
 			<li><?php echo _("Aircraft icon color:"); ?><input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>"></li>
534 534
 		    <?php
535 535
 				}
536
-			    }
537
-		        }
538
-		    ?>
536
+				}
537
+				}
538
+			?>
539 539
 		    <?php
540 540
 			if (isset($globalMarine) && $globalMarine === TRUE) {
541
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
542
-		    ?>
541
+				if (extension_loaded('gd') && function_exists('gd_info')) {
542
+			?>
543 543
 		    <li><?php echo _("Marine icon color:"); ?>
544 544
 			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>">
545 545
 		    </li>
546 546
 		    <?php
547
-			    }
548
-		        }
549
-		    ?>
547
+				}
548
+				}
549
+			?>
550 550
 		    <?php
551 551
 			if (isset($globalTracker) && $globalTracker === TRUE) {
552
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
553
-		    ?>
552
+				if (extension_loaded('gd') && function_exists('gd_info')) {
553
+			?>
554 554
 		    <li><?php echo _("Tracker icon color:"); ?>
555 555
 			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) print $_COOKIE['TrackerIconColor']; elseif (isset($globalTrackerIconColor)) print $globalTrackerIconColor; else print '1a3151'; ?>">
556 556
 		    </li>
557 557
 		    <?php
558
-			    }
559
-		        }
560
-		    ?>
558
+				}
559
+				}
560
+			?>
561 561
 		    <?php
562 562
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
563
-		    ?>
563
+			?>
564 564
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
565 565
 			<div class="range">
566 566
 			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
@@ -569,9 +569,9 @@  discard block
 block discarded – undo
569 569
 		    </li>
570 570
 		    <?php
571 571
 			}
572
-		    ?>
572
+			?>
573 573
 <?php
574
-    } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
574
+	} elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
575 575
 ?>
576 576
 		    <li><?php echo _("Set scaling factor for rendering resolution:"); ?>
577 577
 			<div class="range">
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
 		    </li>
610 610
 <?php
611 611
 	}
612
-    }
612
+	}
613 613
 ?>
614 614
 		    <li><?php echo _("Distance unit:"); ?>
615 615
 			<select class="selectpicker" onchange="unitdistance(this);">
@@ -642,19 +642,19 @@  discard block
 block discarded – undo
642 642
 		    <ul>
643 643
 		    <?php
644 644
 			if (!isset($globalAircraft) || $globalAircraft) {
645
-		    ?>
645
+			?>
646 646
 		    <?php
647 647
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
648
-		    ?>
648
+			?>
649 649
 			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
650 650
 			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
651 651
 			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
652 652
 		    <?php
653 653
 			}
654
-		    ?>
654
+			?>
655 655
 		    <?php
656 656
 			if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
657
-		    ?>
657
+			?>
658 658
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
659 659
 			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
660 660
 			<?php } ?>
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 			<?php } ?>
664 664
 		    <?php
665 665
 			}
666
-		    ?>
666
+			?>
667 667
 		    <li><?php echo _("Display airlines:"); ?>
668 668
 		    <br/>
669 669
 			<select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines">
@@ -683,14 +683,14 @@  discard block
 block discarded – undo
683 683
 						echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>';
684 684
 					}
685 685
 				}
686
-			    ?>
686
+				?>
687 687
 			</select>
688 688
 		    </li>
689 689
 		    <?php
690 690
 			$Spotter = new Spotter();
691 691
 			$allalliancenames = $Spotter->getAllAllianceNames();
692 692
 			if (!empty($allalliancenames)) {
693
-		    ?>
693
+			?>
694 694
 		    <li><?php echo _("Display alliance:"); ?>
695 695
 		    <br/>
696 696
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
@@ -704,18 +704,18 @@  discard block
 block discarded – undo
704 704
 						echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>';
705 705
 					}
706 706
 				}
707
-			    ?>
707
+				?>
708 708
 			</select>
709 709
 		    </li>
710 710
 		    <?php
711 711
 			}
712
-		    ?>
712
+			?>
713 713
 		    <?php
714 714
 			}
715
-		    ?>
715
+			?>
716 716
 		    <?php
717 717
 			if (isset($globalAPRS) && $globalAPRS) {
718
-		    ?>
718
+			?>
719 719
 		    <li><?php echo _("Display APRS sources name:"); ?>
720 720
 			<select class="selectpicker" multiple onchange="sources(this);">
721 721
 			    <?php
@@ -739,18 +739,18 @@  discard block
 block discarded – undo
739 739
 						echo '<option value="'.$src['name'].'">'.$src['name'].'</option>';
740 740
 					}
741 741
 				}
742
-			    ?>
742
+				?>
743 743
 			</select>
744 744
 		    </li>
745 745
 		    <?php
746 746
 			}
747
-		    ?>
747
+			?>
748 748
 		    <?php
749 749
 			if (!isset($globalAircraft) || $globalAircraft) {
750
-		    ?>
750
+			?>
751 751
 		    <?php
752
-			    if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) {
753
-		    ?>
752
+				if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) {
753
+			?>
754 754
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
755 755
 			<select class="selectpicker" onchange="airlinestype(this);">
756 756
 			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
@@ -760,14 +760,14 @@  discard block
 block discarded – undo
760 760
 			</select>
761 761
 		    </li>
762 762
 		    <?php
763
-			    }
764
-		    ?>
763
+				}
764
+			?>
765 765
 		    <?php
766 766
 			}
767
-		    ?>
767
+			?>
768 768
 		    <?php
769 769
 			if (isset($globalMarine) && $globalMarine) {
770
-		    ?>
770
+			?>
771 771
 		    <li>
772 772
 			<?php echo _("Display vessels with MMSI:"); ?>
773 773
 			<input type="text" name="mmsifilter" onchange="mmsifilter();" id="mmsifilter" value="<?php if (isset($_COOKIE['filter_mmsi'])) print $_COOKIE['filter_mmsi']; ?>" />
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 								print '<option value="'.$race['race_id'].'">'.$race['race_name'].'</option>';
791 791
 							}
792 792
 						}
793
-			    ?>
793
+				?>
794 794
 			</select>
795 795
 		    </li>
796 796
 
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 					}
799 799
 				}
800 800
 			}
801
-		    ?>
801
+			?>
802 802
 		    <li>
803 803
 			<?php echo _("Display with ident:"); ?>
804 804
 			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
 	    </form>
812 812
     	</div>
813 813
 <?php
814
-    if (isset($globalSatellite) && $globalSatellite) {
814
+	if (isset($globalSatellite) && $globalSatellite) {
815 815
 ?>
816 816
         <div class="sidebar-pane" id="satellites">
817 817
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -851,14 +851,14 @@  discard block
 block discarded – undo
851 851
 						print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>';
852 852
 					}
853 853
 				}
854
-			    ?>
854
+				?>
855 855
 			</select>
856 856
 		    </li>
857 857
 		</ul>
858 858
 	    </form>
859 859
 	</div>
860 860
 <?php
861
-    }
861
+	}
862 862
 ?>
863 863
     </div>
864 864
 </div>
Please login to merge, or discard this patch.
races-geojson.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,16 +8,16 @@
 block discarded – undo
8 8
 }
9 9
 header('Content-Type: text/javascript');
10 10
 
11
-$race_id = filter_input(INPUT_GET,'race_id',FILTER_SANITIZE_NUMBER_INT);
11
+$race_id = filter_input(INPUT_GET, 'race_id', FILTER_SANITIZE_NUMBER_INT);
12 12
 $race_array = $Marine->getRace($race_id);
13 13
       
14 14
 $output = '{"type": "FeatureCollection","features": [';
15 15
 if (!empty($race_array))
16 16
 {	
17
-	$course = json_decode($race_array['race_markers'],true);
17
+	$course = json_decode($race_array['race_markers'], true);
18 18
 	$i = 0;
19 19
 	$f = count($course);
20
-	foreach($course as $marker)
20
+	foreach ($course as $marker)
21 21
 	{
22 22
 		date_default_timezone_set('UTC');
23 23
 		$output .= '{"type": "Feature",';
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Indentation   +1119 added lines, -1119 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,46 +25,46 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->connectionExists() === false) {
28
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
-    exit();
28
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
+	exit();
30 30
 }
31 31
 if ($Connection->latest() === false) {
32
-    echo "You MUST update to latest schema. Run install/index.php";
33
-    exit();
32
+	echo "You MUST update to latest schema. Run install/index.php";
33
+	exit();
34 34
 }
35 35
 if (PHP_SAPI != 'cli') {
36
-    echo "This script MUST be called from console, not a web browser.";
36
+	echo "This script MUST be called from console, not a web browser.";
37 37
 //    exit();
38 38
 }
39 39
 
40 40
 // This is to be compatible with old version of settings.php
41 41
 if (!isset($globalSources)) {
42
-    if (isset($globalSBS1Hosts)) {
43
-        //$hosts = $globalSBS1Hosts;
44
-        foreach ($globalSBS1Hosts as $host) {
45
-	    $globalSources[] = array('host' => $host);
46
-    	}
47
-    } else {
48
-        if (!isset($globalSBS1Host)) {
49
-	    echo '$globalSources MUST be defined !';
50
-	    die;
42
+	if (isset($globalSBS1Hosts)) {
43
+		//$hosts = $globalSBS1Hosts;
44
+		foreach ($globalSBS1Hosts as $host) {
45
+		$globalSources[] = array('host' => $host);
46
+		}
47
+	} else {
48
+		if (!isset($globalSBS1Host)) {
49
+		echo '$globalSources MUST be defined !';
50
+		die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53 53
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
54
-    }
54
+	}
55 55
 }
56 56
 
57 57
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65
-    $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
65
+	$globalSources = array();
66
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
+	else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
70 70
 	$globalServerAPRS = TRUE;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 if (isset($options['idsource'])) $id_source = $options['idsource'];
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
106
+	if ($globalDebug) echo "Using Server Mode\n";
107
+	$SI=new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
117
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
117
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 119
 }
120 120
 
121 121
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
122 122
 if (isset($globalMarine) && $globalMarine) {
123
-    $AIS = new AIS();
124
-    $MI = new MarineImport($Connection->db);
123
+	$AIS = new AIS();
124
+	$MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127 127
 $SBS=new SBS();
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
138
-        global $sockets;
139
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
-        die("Bye!\n");
141
-    });
142
-    pcntl_signal_dispatch();
137
+	pcntl_signal(SIGINT,  function() {
138
+		global $sockets;
139
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
+		die("Bye!\n");
141
+	});
142
+	pcntl_signal_dispatch();
143 143
 }
144 144
 
145 145
 // let's try and connect
@@ -149,46 +149,46 @@  discard block
 block discarded – undo
149 149
 $reset = 0;
150 150
 
151 151
 function connect_all($hosts) {
152
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
-    $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
156
-    foreach ($hosts as $id => $value) {
152
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
+	$reset++;
155
+	if ($globalDebug) echo 'Connect to all...'."\n";
156
+	foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160 160
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
162
-        	//$formats[$id] = 'deltadbtxt';
163
-        	$globalSources[$id]['format'] = 'deltadbtxt';
164
-        	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
-        	//$formats[$id] = 'vatsimtxt';
168
-        	$globalSources[$id]['format'] = 'vatsimtxt';
169
-        	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172
-        	//$formats[$id] = 'aircraftlistjson';
173
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
174
-        	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
177
-        	//$formats[$id] = 'aircraftjson';
178
-        	$globalSources[$id]['format'] = 'aircraftjson';
179
-        	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraft$/i',$host)) {
182
-        	//$formats[$id] = 'planefinderclient';
183
-        	$globalSources[$id]['format'] = 'planefinderclient';
184
-        	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
186
-    	    } else if (preg_match('/opensky/i',$host)) {
187
-        	//$formats[$id] = 'aircraftlistjson';
188
-        	$globalSources[$id]['format'] = 'opensky';
189
-        	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
191
-    	    /*
161
+			if (preg_match('/deltadb.txt$/i',$host)) {
162
+			//$formats[$id] = 'deltadbtxt';
163
+			$globalSources[$id]['format'] = 'deltadbtxt';
164
+			//$last_exec['deltadbtxt'] = 0;
165
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
+			//$formats[$id] = 'vatsimtxt';
168
+			$globalSources[$id]['format'] = 'vatsimtxt';
169
+			//$last_exec['vatsimtxt'] = 0;
170
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
172
+			//$formats[$id] = 'aircraftlistjson';
173
+			$globalSources[$id]['format'] = 'aircraftlistjson';
174
+			//$last_exec['aircraftlistjson'] = 0;
175
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
+			} else if (preg_match('/aircraft.json$/i',$host)) {
177
+			//$formats[$id] = 'aircraftjson';
178
+			$globalSources[$id]['format'] = 'aircraftjson';
179
+			//$last_exec['aircraftlistjson'] = 0;
180
+			if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
181
+			} else if (preg_match('/aircraft$/i',$host)) {
182
+			//$formats[$id] = 'planefinderclient';
183
+			$globalSources[$id]['format'] = 'planefinderclient';
184
+			//$last_exec['aircraftlistjson'] = 0;
185
+			if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
186
+			} else if (preg_match('/opensky/i',$host)) {
187
+			//$formats[$id] = 'aircraftlistjson';
188
+			$globalSources[$id]['format'] = 'opensky';
189
+			//$last_exec['aircraftlistjson'] = 0;
190
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
191
+			/*
192 192
     	    // Disabled for now, site change source format
193 193
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
194 194
         	//$formats[$id] = 'radarvirtueljson';
@@ -200,128 +200,128 @@  discard block
 block discarded – undo
200 200
         	    exit(0);
201 201
         	}
202 202
     	    */
203
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
204
-        	//$formats[$id] = 'planeupdatefaa';
205
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
206
-        	//$last_exec['planeupdatefaa'] = 0;
207
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
208
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
-        	    exit(0);
211
-        	}
212
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
213
-        	//$formats[$id] = 'phpvmacars';
214
-        	$globalSources[$id]['format'] = 'phpvmacars';
215
-        	//$last_exec['phpvmacars'] = 0;
216
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
217
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218
-        	//$formats[$id] = 'phpvmacars';
219
-        	$globalSources[$id]['format'] = 'vaos';
220
-        	//$last_exec['phpvmacars'] = 0;
221
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
222
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
223
-        	//$formats[$id] = 'phpvmacars';
224
-        	$globalSources[$id]['format'] = 'vam';
225
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
226
-            } else if (preg_match('/whazzup/i',$host)) {
227
-        	//$formats[$id] = 'whazzup';
228
-        	$globalSources[$id]['format'] = 'whazzup';
229
-        	//$last_exec['whazzup'] = 0;
230
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
231
-            } else if (preg_match('/blitzortung/i',$host)) {
232
-        	$globalSources[$id]['format'] = 'blitzortung';
233
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
234
-            } else if (preg_match('/airwhere/i',$host)) {
235
-        	$globalSources[$id]['format'] = 'airwhere';
236
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
-            } else if (preg_match('/recentpireps/i',$host)) {
238
-        	//$formats[$id] = 'pirepsjson';
239
-        	$globalSources[$id]['format'] = 'pirepsjson';
240
-        	//$last_exec['pirepsjson'] = 0;
241
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
242
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243
-        	//$formats[$id] = 'fr24json';
244
-        	$globalSources[$id]['format'] = 'fr24json';
245
-        	//$last_exec['fr24json'] = 0;
246
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
247
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249
-        	    exit(0);
250
-        	}
251
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
252
-        	//$formats[$id] = 'fr24json';
253
-        	$globalSources[$id]['format'] = 'myshiptracking';
254
-        	//$last_exec['fr24json'] = 0;
255
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
256
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258
-        	    exit(0);
259
-        	}
260
-            //} else if (preg_match('/10001/',$host)) {
261
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262
-        	//$formats[$id] = 'tsv';
263
-        	$globalSources[$id]['format'] = 'tsv';
264
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
265
-            }
266
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) {
267
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
269
-    		    if ($idf !== false) {
270
-    			$httpfeeds[$id] = $idf;
271
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
274
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
275
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
276
-	    $hostport = explode(':',$host);
277
-	    if (isset($hostport[1])) {
203
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
204
+			//$formats[$id] = 'planeupdatefaa';
205
+			$globalSources[$id]['format'] = 'planeupdatefaa';
206
+			//$last_exec['planeupdatefaa'] = 0;
207
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
208
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
+				exit(0);
211
+			}
212
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
213
+			//$formats[$id] = 'phpvmacars';
214
+			$globalSources[$id]['format'] = 'phpvmacars';
215
+			//$last_exec['phpvmacars'] = 0;
216
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
217
+			} else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218
+			//$formats[$id] = 'phpvmacars';
219
+			$globalSources[$id]['format'] = 'vaos';
220
+			//$last_exec['phpvmacars'] = 0;
221
+			if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
222
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
223
+			//$formats[$id] = 'phpvmacars';
224
+			$globalSources[$id]['format'] = 'vam';
225
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
226
+			} else if (preg_match('/whazzup/i',$host)) {
227
+			//$formats[$id] = 'whazzup';
228
+			$globalSources[$id]['format'] = 'whazzup';
229
+			//$last_exec['whazzup'] = 0;
230
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
231
+			} else if (preg_match('/blitzortung/i',$host)) {
232
+			$globalSources[$id]['format'] = 'blitzortung';
233
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
234
+			} else if (preg_match('/airwhere/i',$host)) {
235
+			$globalSources[$id]['format'] = 'airwhere';
236
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
+			} else if (preg_match('/recentpireps/i',$host)) {
238
+			//$formats[$id] = 'pirepsjson';
239
+			$globalSources[$id]['format'] = 'pirepsjson';
240
+			//$last_exec['pirepsjson'] = 0;
241
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
242
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243
+			//$formats[$id] = 'fr24json';
244
+			$globalSources[$id]['format'] = 'fr24json';
245
+			//$last_exec['fr24json'] = 0;
246
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
247
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249
+				exit(0);
250
+			}
251
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
252
+			//$formats[$id] = 'fr24json';
253
+			$globalSources[$id]['format'] = 'myshiptracking';
254
+			//$last_exec['fr24json'] = 0;
255
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
256
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258
+				exit(0);
259
+			}
260
+			//} else if (preg_match('/10001/',$host)) {
261
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262
+			//$formats[$id] = 'tsv';
263
+			$globalSources[$id]['format'] = 'tsv';
264
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
265
+			}
266
+		} elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) {
267
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
269
+				if ($idf !== false) {
270
+				$httpfeeds[$id] = $idf;
271
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
+				} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
+			} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
274
+			elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
275
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
276
+		$hostport = explode(':',$host);
277
+		if (isset($hostport[1])) {
278 278
 		$port = $hostport[1];
279 279
 		$hostn = $hostport[0];
280
-	    } else {
280
+		} else {
281 281
 		$port = $globalSources[$id]['port'];
282 282
 		$hostn = $globalSources[$id]['host'];
283
-	    }
284
-	    $Common = new Common();
285
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
286
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
287
-    	    } else {
288
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
289
-	    }
290
-	    if ($s) {
291
-    	        $sockets[$id] = $s;
292
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
293
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
283
+		}
284
+		$Common = new Common();
285
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
286
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
287
+			} else {
288
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
289
+		}
290
+		if ($s) {
291
+				$sockets[$id] = $s;
292
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
293
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
294 294
 			//$formats[$id] = 'aprs';
295 295
 			$globalSources[$id]['format'] = 'aprs';
296 296
 			//$aprs_connect = 0;
297 297
 			//$use_aprs = true;
298
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
298
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
299 299
 			$globalSources[$id]['format'] = 'vrstcp';
300
-    		    } elseif ($port == '10001') {
301
-        		//$formats[$id] = 'tsv';
302
-        		$globalSources[$id]['format'] = 'tsv';
303
-		    } elseif ($port == '30002') {
304
-        		//$formats[$id] = 'raw';
305
-        		$globalSources[$id]['format'] = 'raw';
306
-		    } elseif ($port == '5001') {
307
-        		//$formats[$id] = 'raw';
308
-        		$globalSources[$id]['format'] = 'flightgearmp';
309
-		    } elseif ($port == '30005') {
300
+				} elseif ($port == '10001') {
301
+				//$formats[$id] = 'tsv';
302
+				$globalSources[$id]['format'] = 'tsv';
303
+			} elseif ($port == '30002') {
304
+				//$formats[$id] = 'raw';
305
+				$globalSources[$id]['format'] = 'raw';
306
+			} elseif ($port == '5001') {
307
+				//$formats[$id] = 'raw';
308
+				$globalSources[$id]['format'] = 'flightgearmp';
309
+			} elseif ($port == '30005') {
310 310
 			// Not yet supported
311
-        		//$formats[$id] = 'beast';
312
-        		$globalSources[$id]['format'] = 'beast';
313
-		    //} else $formats[$id] = 'sbs';
314
-		    } else $globalSources[$id]['format'] = 'sbs';
315
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
311
+				//$formats[$id] = 'beast';
312
+				$globalSources[$id]['format'] = 'beast';
313
+			//} else $formats[$id] = 'sbs';
314
+			} else $globalSources[$id]['format'] = 'sbs';
315
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
316 316
 		}
317 317
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
318
-            } else {
318
+			} else {
319 319
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
320 320
 		sleep(10);
321 321
 		connect_all($hosts);
322
-    	    }
323
-        }
324
-    }
322
+			}
323
+		}
324
+	}
325 325
 }
326 326
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
327 327
 
@@ -344,9 +344,9 @@  discard block
 block discarded – undo
344 344
 //connect_all($globalSources);
345 345
 
346 346
 if (isset($globalProxy) && $globalProxy) {
347
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
347
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
348 348
 } else {
349
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
349
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
350 350
 }
351 351
 
352 352
 // APRS Configuration
@@ -355,21 +355,21 @@  discard block
 block discarded – undo
355 355
 	die;
356 356
 }
357 357
 foreach ($globalSources as $key => $source) {
358
-    if (!isset($source['format'])) {
359
-        $globalSources[$key]['format'] = 'auto';
360
-    }
361
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
362
-        unset($globalSources[$key]);
363
-    }
358
+	if (!isset($source['format'])) {
359
+		$globalSources[$key]['format'] = 'auto';
360
+	}
361
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
362
+		unset($globalSources[$key]);
363
+	}
364 364
 }
365 365
 connect_all($globalSources);
366 366
 foreach ($globalSources as $key => $source) {
367
-    if (isset($source['format']) && $source['format'] == 'aprs') {
367
+	if (isset($source['format']) && $source['format'] == 'aprs') {
368 368
 	$aprs_connect = 0;
369 369
 	$use_aprs = true;
370 370
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
371 371
 	break;
372
-    }
372
+	}
373 373
 }
374 374
 
375 375
 if ($use_aprs) {
@@ -410,133 +410,133 @@  discard block
 block discarded – undo
410 410
 
411 411
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
412 412
 while ($i > 0) {
413
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
413
+	if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
414 414
 
415
-    if (!$globalDaemon) $i = $endtime-time();
416
-    // Delete old ATC
417
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
415
+	if (!$globalDaemon) $i = $endtime-time();
416
+	// Delete old ATC
417
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
418 418
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
419
-        $ATC->deleteOldATC();
420
-    }
419
+		$ATC->deleteOldATC();
420
+	}
421 421
     
422
-    if (count($last_exec) == count($globalSources)) {
422
+	if (count($last_exec) == count($globalSources)) {
423 423
 	$max = $globalMinFetch;
424 424
 	foreach ($last_exec as $last) {
425
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
425
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
426 426
 	}
427 427
 	if ($max < $globalMinFetch) {
428
-	    if ($globalDebug) echo 'Sleeping...'."\n";
429
-	    sleep($globalMinFetch-$max+2);
428
+		if ($globalDebug) echo 'Sleeping...'."\n";
429
+		sleep($globalMinFetch-$max+2);
430
+	}
430 431
 	}
431
-    }
432 432
 
433 433
     
434
-    //foreach ($formats as $id => $value) {
435
-    foreach ($globalSources as $id => $value) {
434
+	//foreach ($formats as $id => $value) {
435
+	foreach ($globalSources as $id => $value) {
436 436
 	date_default_timezone_set('UTC');
437 437
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
438 438
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
439 439
 	if ($value['format'] === 'deltadbtxt' && 
440
-	    (
440
+		(
441 441
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
442 442
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
443
-	    )
443
+		)
444 444
 	) {
445
-	    //$buffer = $Common->getData($hosts[$id]);
446
-	    $buffer = $Common->getData($value['host']);
447
-	    if ($buffer != '') $reset = 0;
448
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
449
-	    $buffer = explode('\n',$buffer);
450
-	    foreach ($buffer as $line) {
451
-    		if ($line != '' && count($line) > 7) {
452
-    		    $line = explode(',', $line);
453
-	            $data = array();
454
-	            $data['hex'] = $line[1]; // hex
455
-	            $data['ident'] = $line[2]; // ident
456
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
457
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
458
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
459
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
460
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
461
-	            $data['verticalrate'] = ''; // vertical rate
462
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
463
-	            $data['emergency'] = ''; // emergency
464
-		    $data['datetime'] = date('Y-m-d H:i:s');
465
-		    $data['format_source'] = 'deltadbtxt';
466
-    		    $data['id_source'] = $id_source;
467
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
468
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
469
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
470
-    		    $SI->add($data);
471
-		    unset($data);
472
-    		}
473
-    	    }
474
-    	    $last_exec[$id]['last'] = time();
445
+		//$buffer = $Common->getData($hosts[$id]);
446
+		$buffer = $Common->getData($value['host']);
447
+		if ($buffer != '') $reset = 0;
448
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
449
+		$buffer = explode('\n',$buffer);
450
+		foreach ($buffer as $line) {
451
+			if ($line != '' && count($line) > 7) {
452
+				$line = explode(',', $line);
453
+				$data = array();
454
+				$data['hex'] = $line[1]; // hex
455
+				$data['ident'] = $line[2]; // ident
456
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
457
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
458
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
459
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
460
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
461
+				$data['verticalrate'] = ''; // vertical rate
462
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
463
+				$data['emergency'] = ''; // emergency
464
+			$data['datetime'] = date('Y-m-d H:i:s');
465
+			$data['format_source'] = 'deltadbtxt';
466
+				$data['id_source'] = $id_source;
467
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
468
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
469
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
470
+				$SI->add($data);
471
+			unset($data);
472
+			}
473
+			}
474
+			$last_exec[$id]['last'] = time();
475 475
 	} elseif ($value['format'] === 'aisnmeatxt' && 
476
-	    (
476
+		(
477 477
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
478 478
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
479
-	    )
479
+		)
480 480
 	) {
481
-	    date_default_timezone_set('CET');
482
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
483
-	    date_default_timezone_set('UTC');
484
-	    if ($buffer != '') $reset = 0;
485
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
486
-	    $buffer = explode('\n',$buffer);
487
-	    foreach ($buffer as $line) {
481
+		date_default_timezone_set('CET');
482
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
483
+		date_default_timezone_set('UTC');
484
+		if ($buffer != '') $reset = 0;
485
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
486
+		$buffer = explode('\n',$buffer);
487
+		foreach ($buffer as $line) {
488 488
 		if ($line != '') {
489
-		    //echo "'".$line."'\n";
490
-		    $add = false;
491
-		    $ais_data = $AIS->parse_line(trim($line));
492
-		    $data = array();
493
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
494
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
495
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
496
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
497
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
498
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
499
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
500
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
501
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
502
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
503
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
504
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
505
-		    if (isset($ais_data['timestamp'])) {
489
+			//echo "'".$line."'\n";
490
+			$add = false;
491
+			$ais_data = $AIS->parse_line(trim($line));
492
+			$data = array();
493
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
494
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
495
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
496
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
497
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
498
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
499
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
500
+			if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
501
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
502
+			if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
503
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
504
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
505
+			if (isset($ais_data['timestamp'])) {
506 506
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
507 507
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
508
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
509
-			    $add = true;
508
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
509
+				$add = true;
510 510
 			}
511
-		    } else {
511
+			} else {
512 512
 			$data['datetime'] = date('Y-m-d H:i:s');
513 513
 			$add = true;
514
-		    }
515
-		    $data['format_source'] = 'aisnmeatxt';
516
-    		    $data['id_source'] = $id_source;
517
-		    //print_r($data);
518
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
519
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
520
-		    unset($data);
514
+			}
515
+			$data['format_source'] = 'aisnmeatxt';
516
+				$data['id_source'] = $id_source;
517
+			//print_r($data);
518
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
519
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
520
+			unset($data);
521 521
 		}
522
-    	    }
523
-    	    $last_exec[$id]['last'] = time();
522
+			}
523
+			$last_exec[$id]['last'] = time();
524 524
 	} elseif ($value['format'] === 'aisnmeahttp') {
525
-	    $arr = $httpfeeds;
526
-	    $w = $e = null;
525
+		$arr = $httpfeeds;
526
+		$w = $e = null;
527 527
 	    
528
-	    if (isset($arr[$id])) {
528
+		if (isset($arr[$id])) {
529 529
 		$nn = stream_select($arr,$w,$e,$timeout);
530 530
 		if ($nn > 0) {
531
-		    foreach ($httpfeeds as $feed) {
531
+			foreach ($httpfeeds as $feed) {
532 532
 			$buffer = stream_get_line($feed,2000,"\n");
533 533
 			if ($buffer === FALSE) {
534
-			    connect_all($globalSources);
534
+				connect_all($globalSources);
535 535
 			}
536 536
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
537 537
 			$buffer = explode('\n',$buffer);
538 538
 			foreach ($buffer as $line) {
539
-			    if ($line != '') {
539
+				if ($line != '') {
540 540
 				$ais_data = $AIS->parse_line(trim($line));
541 541
 				$data = array();
542 542
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -554,117 +554,117 @@  discard block
 block discarded – undo
554 554
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
555 555
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
556 556
 				if (isset($ais_data['timestamp'])) {
557
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
557
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
558 558
 				} else {
559
-				    $data['datetime'] = date('Y-m-d H:i:s');
559
+					$data['datetime'] = date('Y-m-d H:i:s');
560 560
 				}
561 561
 				$data['format_source'] = 'aisnmeahttp';
562 562
 				$data['id_source'] = $id_source;
563 563
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
564 564
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
565 565
 				unset($data);
566
-			    }
566
+				}
567
+			}
567 568
 			}
568
-		    }
569 569
 		} else {
570
-		    $format = $value['format'];
571
-		    if (isset($tt[$format])) $tt[$format]++;
572
-		    else $tt[$format] = 0;
573
-		    if ($tt[$format] > 30) {
570
+			$format = $value['format'];
571
+			if (isset($tt[$format])) $tt[$format]++;
572
+			else $tt[$format] = 0;
573
+			if ($tt[$format] > 30) {
574 574
 			if ($globalDebug) echo 'Reconnect...'."\n";
575 575
 			sleep(2);
576 576
 			//$sourceeen[] = $value;
577 577
 			//connect_all($sourceeen);
578 578
 			//$sourceeen = array();
579 579
 			connect_all($globalSources);
580
-		    }
580
+			}
581
+		}
581 582
 		}
582
-	    }
583 583
 	} elseif ($value['format'] === 'myshiptracking' && 
584
-	    (
584
+		(
585 585
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
586 586
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
587
-	    )
587
+		)
588 588
 	) {
589
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
590
-	    if ($buffer != '') {
589
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
590
+		if ($buffer != '') {
591 591
 		//echo $buffer;
592 592
 		$all_data = json_decode($buffer,true);
593 593
 		//print_r($all_data);
594 594
 		if (isset($all_data[0]['DATA'])) {
595
-		    foreach ($all_data[0]['DATA'] as $line) {
595
+			foreach ($all_data[0]['DATA'] as $line) {
596 596
 			if ($line != '') {
597
-			    $data = array();
598
-			    $data['ident'] = $line['NAME'];
599
-			    $data['mmsi'] = $line['MMSI'];
600
-			    if (strlen($data['mmsi']) > 9) {
597
+				$data = array();
598
+				$data['ident'] = $line['NAME'];
599
+				$data['mmsi'] = $line['MMSI'];
600
+				if (strlen($data['mmsi']) > 9) {
601 601
 				$data['mmsi'] = substr($data['mmsi'],-9);
602
-			    }
603
-			    $data['speed'] = $line['SOG'];
604
-			    $data['heading'] = $line['COG'];
605
-			    $data['latitude'] = $line['LAT'];
606
-			    $data['longitude'] = $line['LNG'];
607
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
608
-			    //$data['type_id'] = $line['TYPE'];
609
-			    $data['imo'] = $line['IMO'];
610
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
611
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
612
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
613
-			    $data['format_source'] = 'myshiptracking';
614
-			    $data['id_source'] = $id_source;
615
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
616
-			    $MI->add($data);
617
-			    unset($data);
602
+				}
603
+				$data['speed'] = $line['SOG'];
604
+				$data['heading'] = $line['COG'];
605
+				$data['latitude'] = $line['LAT'];
606
+				$data['longitude'] = $line['LNG'];
607
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
608
+				//$data['type_id'] = $line['TYPE'];
609
+				$data['imo'] = $line['IMO'];
610
+				if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
611
+				if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
612
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
613
+				$data['format_source'] = 'myshiptracking';
614
+				$data['id_source'] = $id_source;
615
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
616
+				$MI->add($data);
617
+				unset($data);
618 618
 			}
619
-		    }
619
+			}
620
+		}
620 621
 		}
621
-	    }
622
-	    $last_exec[$id]['last'] = time();
622
+		$last_exec[$id]['last'] = time();
623 623
 	} elseif ($value['format'] === 'boatbeaconapp' && 
624
-	    (
624
+		(
625 625
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
626 626
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
627
-	    )
627
+		)
628 628
 	) {
629
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
630
-	    if ($buffer != '') {
629
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
630
+		if ($buffer != '') {
631 631
 		$all_data = json_decode($buffer,true);
632 632
 		if (isset($all_data[0]['mmsi'])) {
633
-		    foreach ($all_data as $line) {
633
+			foreach ($all_data as $line) {
634 634
 			if ($line != '') {
635
-			    $data = array();
636
-			    $data['ident'] = $line['shipname'];
637
-			    $data['callsign'] = $line['callsign'];
638
-			    $data['mmsi'] = substr($line['mmsi'],-9);
639
-			    $data['speed'] = $line['sog'];
640
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
641
-			    $data['latitude'] = $line['latitude'];
642
-			    $data['longitude'] = $line['longitude'];
643
-			    $data['type_id'] = $line['shiptype'];
644
-			    $data['arrival_code'] = $line['destination'];
645
-			    $data['datetime'] = $line['time'];
646
-			    $data['format_source'] = 'boatbeaconapp';
647
-			    $data['id_source'] = $id_source;
648
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
649
-			    $MI->add($data);
650
-			    unset($data);
635
+				$data = array();
636
+				$data['ident'] = $line['shipname'];
637
+				$data['callsign'] = $line['callsign'];
638
+				$data['mmsi'] = substr($line['mmsi'],-9);
639
+				$data['speed'] = $line['sog'];
640
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
641
+				$data['latitude'] = $line['latitude'];
642
+				$data['longitude'] = $line['longitude'];
643
+				$data['type_id'] = $line['shiptype'];
644
+				$data['arrival_code'] = $line['destination'];
645
+				$data['datetime'] = $line['time'];
646
+				$data['format_source'] = 'boatbeaconapp';
647
+				$data['id_source'] = $id_source;
648
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
649
+				$MI->add($data);
650
+				unset($data);
651
+			}
651 652
 			}
652
-		    }
653 653
 		}
654 654
 		
655
-	    }
656
-    	    $last_exec[$id]['last'] = time();
655
+		}
656
+			$last_exec[$id]['last'] = time();
657 657
 	} elseif ($value['format'] === 'boatnerd' && 
658
-	    (
658
+		(
659 659
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
660 660
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
661
-	    )
661
+		)
662 662
 	) {
663
-	    $buffer = $Common->getData($value['host']);
664
-	    if ($buffer != '') {
663
+		$buffer = $Common->getData($value['host']);
664
+		if ($buffer != '') {
665 665
 		$all_data = json_decode($buffer,true);
666 666
 		if (isset($all_data['features'][0]['id'])) {
667
-		    foreach ($all_data['features'] as $line) {
667
+			foreach ($all_data['features'] as $line) {
668 668
 			print_r($line);
669 669
 			$data = array();
670 670
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
@@ -684,76 +684,76 @@  discard block
 block discarded – undo
684 684
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
685 685
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
686 686
 			unset($data);
687
-		    }
687
+			}
688 688
 		}
689 689
 		
690
-	    }
691
-    	    $last_exec[$id]['last'] = time();
690
+		}
691
+			$last_exec[$id]['last'] = time();
692 692
 	} elseif ($value['format'] === 'shipplotter' && 
693
-	    (
693
+		(
694 694
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
695 695
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
696
-	    )
696
+		)
697 697
 	) {
698
-	    if ($globalDebug) echo 'download...';
699
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
700
-	    if ($globalDebug) echo 'done !'."\n";
701
-	    // FIXME: Need more work
702
-	    if ($buffer != '') $reset = 0;
703
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
704
-	    $buffer = explode('\n',$buffer);
705
-	    foreach ($buffer as $line) {
698
+		if ($globalDebug) echo 'download...';
699
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
700
+		if ($globalDebug) echo 'done !'."\n";
701
+		// FIXME: Need more work
702
+		if ($buffer != '') $reset = 0;
703
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
704
+		$buffer = explode('\n',$buffer);
705
+		foreach ($buffer as $line) {
706 706
 		if ($line != '') {
707
-		    $data = array();
708
-		    //echo $line."\n";
709
-		    $data['mmsi'] = (int)substr($line,0,9);
710
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
711
-		    $data['status_id'] = substr($line,21,2);
712
-		    $data['type_id'] = substr($line,24,3);
713
-		    $data['latitude'] = substr($line,29,9);
714
-		    $data['longitude'] = substr($line,41,9);
715
-		    $data['speed'] = round(substr($line,51,5));
716
-		    //$data['course'] = substr($line,57,5);
717
-		    $data['heading'] = round(substr($line,63,3));
718
-		    //$data['draft'] = substr($line,67,4);
719
-		    //$data['length'] = substr($line,72,3);
720
-		    //$data['beam'] = substr($line,76,2);
721
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
722
-		    //$data['callsign'] = trim(substr($line,100,7);
723
-		    $data['arrival_code'] = substr($line,108,20);
724
-		    //$data['etaDate'] = substr($line,129,5);
725
-		    //$data['etaTime'] = substr($line,135,5);
726
-		    $data['format_source'] = 'shipplotter';
727
-    		    $data['id_source'] = $id_source;
728
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
729
-		    //print_r($data);
730
-		    //echo 'Add...'."\n";
731
-		    $MI->add($data);
732
-		    unset($data);
707
+			$data = array();
708
+			//echo $line."\n";
709
+			$data['mmsi'] = (int)substr($line,0,9);
710
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
711
+			$data['status_id'] = substr($line,21,2);
712
+			$data['type_id'] = substr($line,24,3);
713
+			$data['latitude'] = substr($line,29,9);
714
+			$data['longitude'] = substr($line,41,9);
715
+			$data['speed'] = round(substr($line,51,5));
716
+			//$data['course'] = substr($line,57,5);
717
+			$data['heading'] = round(substr($line,63,3));
718
+			//$data['draft'] = substr($line,67,4);
719
+			//$data['length'] = substr($line,72,3);
720
+			//$data['beam'] = substr($line,76,2);
721
+			$data['ident'] = trim(utf8_encode(substr($line,78,20)));
722
+			//$data['callsign'] = trim(substr($line,100,7);
723
+			$data['arrival_code'] = substr($line,108,20);
724
+			//$data['etaDate'] = substr($line,129,5);
725
+			//$data['etaTime'] = substr($line,135,5);
726
+			$data['format_source'] = 'shipplotter';
727
+				$data['id_source'] = $id_source;
728
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
729
+			//print_r($data);
730
+			//echo 'Add...'."\n";
731
+			$MI->add($data);
732
+			unset($data);
733 733
 		}
734
-    	    }
735
-    	    $last_exec[$id]['last'] = time();
734
+			}
735
+			$last_exec[$id]['last'] = time();
736 736
 	} elseif ($value['format'] === 'sailaway' && 
737
-	    (
737
+		(
738 738
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
739 739
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
740
-	    )
740
+		)
741 741
 	) {
742
-	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
742
+		if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
743 743
 		$authsailaway = $Common->getData('https://sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true);
744 744
 		//echo $authsailaway;
745 745
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
746 746
 		if (isset($setcookie[1][0])) {
747
-		    $sailaway_authcookie = $setcookie[1][0];
747
+			$sailaway_authcookie = $setcookie[1][0];
748
+		}
748 749
 		}
749
-	    }
750 750
 
751
-	    if ($globalDebug) echo '! Download... ';
752
-	    for ($i =0; $i <= 1; $i++) {
753
-		    if ($globalDebug) echo 'Racetype: '.$i.' ';
754
-	    $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
755
-	    if ($globalDebug) echo 'done'."\n";
756
-	    if ($buffer != '') {
751
+		if ($globalDebug) echo '! Download... ';
752
+		for ($i =0; $i <= 1; $i++) {
753
+			if ($globalDebug) echo 'Racetype: '.$i.' ';
754
+		$buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
755
+		if ($globalDebug) echo 'done'."\n";
756
+		if ($buffer != '') {
757 757
 		$all_data = json_decode($buffer,true);
758 758
 		if (isset($all_data['missions'])) {
759 759
 			foreach ($all_data['missions'] as $mission) {
@@ -772,19 +772,19 @@  discard block
 block discarded – undo
772 772
 					//print_r($race_data);
773 773
 					unset($racebuffer);
774 774
 					if (isset($race_data['mission'])) {
775
-					    $datar = array();
776
-					    $datar['id'] = $mission['misnr'];
777
-					    $datar['desc'] = $race_data['mission']['misdescr'];
778
-					    $datar['creator'] = $race_data['mission']['usrname'];
779
-					    $datar['name'] = $race_data['mission']['mistitle'];
780
-					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
781
-					    $markers = array();
782
-					    foreach ($race_data['mission']['course'] as $course) {
775
+						$datar = array();
776
+						$datar['id'] = $mission['misnr'];
777
+						$datar['desc'] = $race_data['mission']['misdescr'];
778
+						$datar['creator'] = $race_data['mission']['usrname'];
779
+						$datar['name'] = $race_data['mission']['mistitle'];
780
+						$datar['startdate'] = $race_data['mission']['misstartdatetime'];
781
+						$markers = array();
782
+						foreach ($race_data['mission']['course'] as $course) {
783 783
 						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
784
-					    }
785
-					    $datar['markers'] = json_encode($markers);
786
-					    //print_r($datar);
787
-					    $MI->race_add($datar);
784
+						}
785
+						$datar['markers'] = json_encode($markers);
786
+						//print_r($datar);
787
+						$MI->race_add($datar);
788 788
 					}
789 789
 				}
790 790
 				if ($bufferm != '') {
@@ -847,34 +847,34 @@  discard block
 block discarded – undo
847 847
 				}
848 848
 			}
849 849
 		}
850
-	    }
851
-	    }
852
-    	    $last_exec[$id]['last'] = time();
850
+		}
851
+		}
852
+			$last_exec[$id]['last'] = time();
853 853
 	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
854 854
 	} elseif (
855
-	    (
855
+		(
856 856
 		$value['format'] === 'whazzup' && 
857 857
 		(
858
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
859
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
858
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
859
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
860 860
 		)
861
-	    ) || (
861
+		) || (
862 862
 		$value['format'] === 'vatsimtxt' && 
863 863
 		(
864
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
865
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
864
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
865
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
866
+		)
866 867
 		)
867
-	    )
868 868
 	) {
869
-	    //$buffer = $Common->getData($hosts[$id]);
870
-	    $buffer = $Common->getData($value['host']);
871
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
872
-	    $buffer = explode('\n',$buffer);
873
-	    $reset = 0;
874
-	    foreach ($buffer as $line) {
875
-    		if ($line != '') {
876
-    		    $line = explode(':', $line);
877
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
869
+		//$buffer = $Common->getData($hosts[$id]);
870
+		$buffer = $Common->getData($value['host']);
871
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
872
+		$buffer = explode('\n',$buffer);
873
+		$reset = 0;
874
+		foreach ($buffer as $line) {
875
+			if ($line != '') {
876
+				$line = explode(':', $line);
877
+				if (count($line) > 30 && $line[0] != 'callsign') {
878 878
 			$data = array();
879 879
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
880 880
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -887,37 +887,37 @@  discard block
 block discarded – undo
887 887
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
888 888
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
889 889
 			$data['latitude'] = $line[5]; // lat
890
-	        	$data['longitude'] = $line[6]; // long
891
-	        	$data['verticalrate'] = ''; // vertical rate
892
-	        	$data['squawk'] = ''; // squawk
893
-	        	$data['emergency'] = ''; // emergency
894
-	        	$data['waypoints'] = $line[30];
890
+				$data['longitude'] = $line[6]; // long
891
+				$data['verticalrate'] = ''; // vertical rate
892
+				$data['squawk'] = ''; // squawk
893
+				$data['emergency'] = ''; // emergency
894
+				$data['waypoints'] = $line[30];
895 895
 			$data['datetime'] = date('Y-m-d H:i:s');
896 896
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
897 897
 			//if (isset($line[37])) $data['last_update'] = $line[37];
898
-		        $data['departure_airport_icao'] = $line[11];
899
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
900
-		        $data['arrival_airport_icao'] = $line[13];
898
+				$data['departure_airport_icao'] = $line[11];
899
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
900
+				$data['arrival_airport_icao'] = $line[13];
901 901
 			$data['frequency'] = $line[4];
902 902
 			$data['type'] = $line[18];
903 903
 			$data['range'] = $line[19];
904 904
 			if (isset($line[35])) $data['info'] = $line[35];
905
-    			$data['id_source'] = $id_source;
906
-	    		//$data['arrival_airport_time'] = ;
907
-	    		if ($line[9] != '') {
908
-	    		    $aircraft_data = explode('/',$line[9]);
909
-	    		    if (isset($aircraft_data[1])) {
910
-	    			$data['aircraft_icao'] = $aircraft_data[1];
911
-	    		    }
912
-        		}
913
-	    		/*
905
+				$data['id_source'] = $id_source;
906
+				//$data['arrival_airport_time'] = ;
907
+				if ($line[9] != '') {
908
+					$aircraft_data = explode('/',$line[9]);
909
+					if (isset($aircraft_data[1])) {
910
+					$data['aircraft_icao'] = $aircraft_data[1];
911
+					}
912
+				}
913
+				/*
914 914
 	    		if ($value === 'whazzup') $data['format_source'] = 'whazzup';
915 915
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
916 916
 	    		*/
917
-	    		$data['format_source'] = $value['format'];
917
+				$data['format_source'] = $value['format'];
918 918
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
919 919
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
920
-    			if ($line[3] === 'PILOT') $SI->add($data);
920
+				if ($line[3] === 'PILOT') $SI->add($data);
921 921
 			elseif ($line[3] === 'ATC') {
922 922
 				//print_r($data);
923 923
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -938,21 +938,21 @@  discard block
 block discarded – undo
938 938
 					else 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']);
939 939
 				}
940 940
 			}
941
-    			unset($data);
942
-    		    }
943
-    		}
944
-    	    }
945
-    	    //if ($value === 'whazzup') $last_exec['whazzup'] = time();
946
-    	    //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
947
-    	    $last_exec[$id]['last'] = time();
948
-    	} elseif ($value['format'] === 'airwhere' && 
949
-    	    (
950
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
951
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
952
-    	    )
953
-    	) {
954
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
955
-	    if ($buffer != '') {
941
+				unset($data);
942
+				}
943
+			}
944
+			}
945
+			//if ($value === 'whazzup') $last_exec['whazzup'] = time();
946
+			//elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
947
+			$last_exec[$id]['last'] = time();
948
+		} elseif ($value['format'] === 'airwhere' && 
949
+			(
950
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
951
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
952
+			)
953
+		) {
954
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
955
+		if ($buffer != '') {
956 956
 		$all_data = simplexml_load_string($buffer);
957 957
 		foreach($all_data->children() as $childdata) {
958 958
 			$data = array();
@@ -974,10 +974,10 @@  discard block
 block discarded – undo
974 974
 			$SI->add($data);
975 975
 			unset($data);
976 976
 		}
977
-	    }
978
-	    $Source->deleteOldLocationByType('gs');
979
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
980
-	    if ($buffer != '') {
977
+		}
978
+		$Source->deleteOldLocationByType('gs');
979
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
980
+		if ($buffer != '') {
981 981
 		$all_data = simplexml_load_string($buffer);
982 982
 		foreach($all_data->children() as $childdata) {
983 983
 			$data = array();
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
 			}
996 996
 			unset($data);
997 997
 		}
998
-	    }
999
-	    $last_exec[$id]['last'] = time();
998
+		}
999
+		$last_exec[$id]['last'] = time();
1000 1000
 	/*
1001 1001
 	} if ($value['format'] === 'aircraftlistjson') {
1002 1002
 	    print_r($globalSources);
@@ -1004,17 +1004,17 @@  discard block
 block discarded – undo
1004 1004
 	    echo $globalMinFetch;
1005 1005
 	*/
1006 1006
 	} elseif ($value['format'] === 'aircraftlistjson' && 
1007
-	    (
1007
+		(
1008 1008
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1009 1009
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1010
-	    )
1010
+		)
1011 1011
 	) {
1012
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1013
-	    if ($buffer != '') {
1014
-	        $all_data = json_decode($buffer,true);
1012
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
1013
+		if ($buffer != '') {
1014
+			$all_data = json_decode($buffer,true);
1015 1015
 		if (isset($all_data['acList'])) {
1016
-		    $reset = 0;
1017
-		    foreach ($all_data['acList'] as $line) {
1016
+			$reset = 0;
1017
+			foreach ($all_data['acList'] as $line) {
1018 1018
 			$data = array();
1019 1019
 			$data['hex'] = $line['Icao']; // hex
1020 1020
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1037,10 +1037,10 @@  discard block
 block discarded – undo
1037 1037
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1038 1038
 			if (isset($data['latitude'])) $SI->add($data);
1039 1039
 			unset($data);
1040
-		    }
1040
+			}
1041 1041
 		} elseif (is_array($all_data)) {
1042
-		    $reset = 0;
1043
-		    foreach ($all_data as $line) {
1042
+			$reset = 0;
1043
+			foreach ($all_data as $line) {
1044 1044
 			$data = array();
1045 1045
 			$data['hex'] = $line['hex']; // hex
1046 1046
 			$data['ident'] = $line['flight']; // ident
@@ -1060,291 +1060,291 @@  discard block
 block discarded – undo
1060 1060
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1061 1061
 			$SI->add($data);
1062 1062
 			unset($data);
1063
-		    }
1063
+			}
1064 1064
 		}
1065
-	    } elseif ($globalDebug) echo 'No data'."\n";
1066
-    	    //$last_exec['aircraftlistjson'] = time();
1067
-    	    $last_exec[$id]['last'] = time();
1068
-    	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1069
-    	} elseif ($value['format'] === 'planeupdatefaa' && 
1070
-    	    (
1071
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1072
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1073
-    	    )
1074
-    	) {
1075
-	    $buffer = $Common->getData($value['host']);
1076
-	    $all_data = json_decode($buffer,true);
1077
-	    if (isset($all_data['planes'])) {
1065
+		} elseif ($globalDebug) echo 'No data'."\n";
1066
+			//$last_exec['aircraftlistjson'] = time();
1067
+			$last_exec[$id]['last'] = time();
1068
+		//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1069
+		} elseif ($value['format'] === 'planeupdatefaa' && 
1070
+			(
1071
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1072
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1073
+			)
1074
+		) {
1075
+		$buffer = $Common->getData($value['host']);
1076
+		$all_data = json_decode($buffer,true);
1077
+		if (isset($all_data['planes'])) {
1078 1078
 		$reset = 0;
1079 1079
 		foreach ($all_data['planes'] as $key => $line) {
1080
-		    $data = array();
1081
-		    $data['hex'] = $key; // hex
1082
-		    $data['ident'] = $line[3]; // ident
1083
-		    $data['altitude'] = $line[6]; // altitude
1084
-		    $data['speed'] = $line[8]; // speed
1085
-		    $data['heading'] = $line[7]; // heading
1086
-		    $data['latitude'] = $line[4]; // lat
1087
-		    $data['longitude'] = $line[5]; // long
1088
-		    //$data['verticalrate'] = $line[]; // verticale rate
1089
-		    $data['squawk'] = $line[10]; // squawk
1090
-		    $data['emergency'] = ''; // emergency
1091
-		    $data['registration'] = $line[2];
1092
-		    $data['aircraft_icao'] = $line[0];
1093
-		    $deparr = explode('-',$line[1]);
1094
-		    if (count($deparr) === 2) {
1080
+			$data = array();
1081
+			$data['hex'] = $key; // hex
1082
+			$data['ident'] = $line[3]; // ident
1083
+			$data['altitude'] = $line[6]; // altitude
1084
+			$data['speed'] = $line[8]; // speed
1085
+			$data['heading'] = $line[7]; // heading
1086
+			$data['latitude'] = $line[4]; // lat
1087
+			$data['longitude'] = $line[5]; // long
1088
+			//$data['verticalrate'] = $line[]; // verticale rate
1089
+			$data['squawk'] = $line[10]; // squawk
1090
+			$data['emergency'] = ''; // emergency
1091
+			$data['registration'] = $line[2];
1092
+			$data['aircraft_icao'] = $line[0];
1093
+			$deparr = explode('-',$line[1]);
1094
+			if (count($deparr) === 2) {
1095 1095
 			$data['departure_airport_icao'] = $deparr[0];
1096 1096
 			$data['arrival_airport_icao'] = $deparr[1];
1097
-		    }
1098
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1099
-	    	    $data['format_source'] = 'planeupdatefaa';
1100
-    		    $data['id_source'] = $id_source;
1101
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1102
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1103
-		    $SI->add($data);
1104
-		    unset($data);
1097
+			}
1098
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1099
+				$data['format_source'] = 'planeupdatefaa';
1100
+				$data['id_source'] = $id_source;
1101
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1102
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1103
+			$SI->add($data);
1104
+			unset($data);
1105
+		}
1105 1106
 		}
1106
-	    }
1107
-	    //$last_exec['planeupdatefaa'] = time();
1108
-	    $last_exec[$id]['last'] = time();
1107
+		//$last_exec['planeupdatefaa'] = time();
1108
+		$last_exec[$id]['last'] = time();
1109 1109
 	} elseif ($value['format'] === 'opensky' && 
1110
-	    (
1110
+		(
1111 1111
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1112 1112
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1113
-	    )
1113
+		)
1114 1114
 	) {
1115
-	    $buffer = $Common->getData($value['host']);
1116
-	    $all_data = json_decode($buffer,true);
1117
-	    if (isset($all_data['states'])) {
1115
+		$buffer = $Common->getData($value['host']);
1116
+		$all_data = json_decode($buffer,true);
1117
+		if (isset($all_data['states'])) {
1118 1118
 		$reset = 0;
1119 1119
 		foreach ($all_data['states'] as $key => $line) {
1120
-		    $data = array();
1121
-		    $data['hex'] = $line[0]; // hex
1122
-		    $data['ident'] = trim($line[1]); // ident
1123
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
1124
-		    $data['speed'] = round($line[9]*1.94384); // speed
1125
-		    $data['heading'] = round($line[10]); // heading
1126
-		    $data['latitude'] = $line[6]; // lat
1127
-		    $data['longitude'] = $line[5]; // long
1128
-		    $data['verticalrate'] = $line[11]; // verticale rate
1129
-		    //$data['squawk'] = $line[10]; // squawk
1130
-		    //$data['emergency'] = ''; // emergency
1131
-		    //$data['registration'] = $line[2];
1132
-		    //$data['aircraft_icao'] = $line[0];
1133
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1134
-		    $data['format_source'] = 'opensky';
1135
-		    $data['id_source'] = $id_source;
1136
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1137
-		    $SI->add($data);
1138
-		    unset($data);
1120
+			$data = array();
1121
+			$data['hex'] = $line[0]; // hex
1122
+			$data['ident'] = trim($line[1]); // ident
1123
+			$data['altitude'] = round($line[7]*3.28084); // altitude
1124
+			$data['speed'] = round($line[9]*1.94384); // speed
1125
+			$data['heading'] = round($line[10]); // heading
1126
+			$data['latitude'] = $line[6]; // lat
1127
+			$data['longitude'] = $line[5]; // long
1128
+			$data['verticalrate'] = $line[11]; // verticale rate
1129
+			//$data['squawk'] = $line[10]; // squawk
1130
+			//$data['emergency'] = ''; // emergency
1131
+			//$data['registration'] = $line[2];
1132
+			//$data['aircraft_icao'] = $line[0];
1133
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1134
+			$data['format_source'] = 'opensky';
1135
+			$data['id_source'] = $id_source;
1136
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1137
+			$SI->add($data);
1138
+			unset($data);
1139 1139
 		}
1140
-	    }
1141
-	    //$last_exec['planeupdatefaa'] = time();
1142
-	    $last_exec[$id]['last'] = time();
1140
+		}
1141
+		//$last_exec['planeupdatefaa'] = time();
1142
+		$last_exec[$id]['last'] = time();
1143 1143
 	} elseif ($value['format'] === 'aircraftjson' && 
1144
-	    (
1144
+		(
1145 1145
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1146 1146
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1147
-	    )
1147
+		)
1148 1148
 	) {
1149
-	    $buffer = $Common->getData($value['host']);
1150
-	    $all_data = json_decode($buffer,true);
1151
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1149
+		$buffer = $Common->getData($value['host']);
1150
+		$all_data = json_decode($buffer,true);
1151
+		if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1152 1152
 		$reset = 0;
1153 1153
 		foreach ($all_data['aircraft'] as $key => $line) {
1154
-		    $data = array();
1155
-		    // add support for ground vehicule with ~ in front of hex
1156
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1157
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1158
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1159
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1160
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1161
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1162
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1163
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1164
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1165
-		    //$data['emergency'] = ''; // emergency
1166
-		    //$data['registration'] = $line[2];
1167
-		    //$data['aircraft_icao'] = $line[0];
1168
-		    $data['datetime'] = date('Y-m-d H:i:s');
1169
-		    $data['format_source'] = 'aircraftjson';
1170
-		    $data['id_source'] = $id_source;
1171
-		    if (isset($value['name']) && $value['name'] != '') {
1172
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1173
-			    else $data['source_name'] = $value['name'];
1174
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1175
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1176
-		    $SI->add($data);
1177
-		    unset($data);
1154
+			$data = array();
1155
+			// add support for ground vehicule with ~ in front of hex
1156
+			if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1157
+			if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1158
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1159
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1160
+			if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1161
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1162
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1163
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1164
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1165
+			//$data['emergency'] = ''; // emergency
1166
+			//$data['registration'] = $line[2];
1167
+			//$data['aircraft_icao'] = $line[0];
1168
+			$data['datetime'] = date('Y-m-d H:i:s');
1169
+			$data['format_source'] = 'aircraftjson';
1170
+			$data['id_source'] = $id_source;
1171
+			if (isset($value['name']) && $value['name'] != '') {
1172
+				if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1173
+				else $data['source_name'] = $value['name'];
1174
+			} elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1175
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1176
+			$SI->add($data);
1177
+			unset($data);
1178
+		}
1178 1179
 		}
1179
-	    }
1180
-	    //$last_exec['planeupdatefaa'] = time();
1181
-	    $last_exec[$id]['last'] = time();
1180
+		//$last_exec['planeupdatefaa'] = time();
1181
+		$last_exec[$id]['last'] = time();
1182 1182
 	} elseif ($value['format'] === 'planefinderclient' && 
1183
-	    (
1183
+		(
1184 1184
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1185 1185
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1186
-	    )
1186
+		)
1187 1187
 	) {
1188
-	    $buffer = $Common->getData($value['host']);
1189
-	    $all_data = json_decode($buffer,true);
1190
-	    if (isset($all_data['aircraft'])) {
1188
+		$buffer = $Common->getData($value['host']);
1189
+		$all_data = json_decode($buffer,true);
1190
+		if (isset($all_data['aircraft'])) {
1191 1191
 		$reset = 0;
1192 1192
 		foreach ($all_data['aircraft'] as $key => $line) {
1193
-		    $data = array();
1194
-		    $data['hex'] = $key; // hex
1195
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1196
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1197
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1198
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1199
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1200
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1201
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1202
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1203
-		    //$data['emergency'] = ''; // emergency
1204
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1205
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1206
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1207
-		    $data['format_source'] = 'planefinderclient';
1208
-		    $data['id_source'] = $id_source;
1209
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1210
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1211
-		    $SI->add($data);
1212
-		    unset($data);
1193
+			$data = array();
1194
+			$data['hex'] = $key; // hex
1195
+			if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1196
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1197
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1198
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1199
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1200
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1201
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1202
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1203
+			//$data['emergency'] = ''; // emergency
1204
+			if (isset($line['reg'])) $data['registration'] = $line['reg'];
1205
+			if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1206
+			$data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1207
+			$data['format_source'] = 'planefinderclient';
1208
+			$data['id_source'] = $id_source;
1209
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1210
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1211
+			$SI->add($data);
1212
+			unset($data);
1213 1213
 		}
1214
-	    }
1215
-	    $last_exec[$id]['last'] = time();
1214
+		}
1215
+		$last_exec[$id]['last'] = time();
1216 1216
 	//} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1217 1217
 	} elseif ($value['format'] === 'fr24json' && 
1218
-	    (
1218
+		(
1219 1219
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1220 1220
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1221
-	    )
1221
+		)
1222 1222
 	) {
1223
-	    //$buffer = $Common->getData($hosts[$id]);
1224
-	    $buffer = $Common->getData($value['host']);
1225
-	    $all_data = json_decode($buffer,true);
1226
-	    if (!empty($all_data)) $reset = 0;
1227
-	    foreach ($all_data as $key => $line) {
1223
+		//$buffer = $Common->getData($hosts[$id]);
1224
+		$buffer = $Common->getData($value['host']);
1225
+		$all_data = json_decode($buffer,true);
1226
+		if (!empty($all_data)) $reset = 0;
1227
+		foreach ($all_data as $key => $line) {
1228 1228
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1229
-		    $data = array();
1230
-		    $data['hex'] = $line[0];
1231
-		    $data['ident'] = $line[16]; //$line[13]
1232
-	    	    $data['altitude'] = $line[4]; // altitude
1233
-	    	    $data['speed'] = $line[5]; // speed
1234
-	    	    $data['heading'] = $line[3]; // heading
1235
-	    	    $data['latitude'] = $line[1]; // lat
1236
-	    	    $data['longitude'] = $line[2]; // long
1237
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1238
-	    	    $data['squawk'] = $line[6]; // squawk
1239
-	    	    $data['aircraft_icao'] = $line[8];
1240
-	    	    $data['registration'] = $line[9];
1241
-		    $data['departure_airport_iata'] = $line[11];
1242
-		    $data['arrival_airport_iata'] = $line[12];
1243
-	    	    $data['emergency'] = ''; // emergency
1244
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1245
-	    	    $data['format_source'] = 'fr24json';
1246
-    		    $data['id_source'] = $id_source;
1247
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1248
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1249
-		    $SI->add($data);
1250
-		    unset($data);
1229
+			$data = array();
1230
+			$data['hex'] = $line[0];
1231
+			$data['ident'] = $line[16]; //$line[13]
1232
+				$data['altitude'] = $line[4]; // altitude
1233
+				$data['speed'] = $line[5]; // speed
1234
+				$data['heading'] = $line[3]; // heading
1235
+				$data['latitude'] = $line[1]; // lat
1236
+				$data['longitude'] = $line[2]; // long
1237
+				$data['verticalrate'] = $line[15]; // verticale rate
1238
+				$data['squawk'] = $line[6]; // squawk
1239
+				$data['aircraft_icao'] = $line[8];
1240
+				$data['registration'] = $line[9];
1241
+			$data['departure_airport_iata'] = $line[11];
1242
+			$data['arrival_airport_iata'] = $line[12];
1243
+				$data['emergency'] = ''; // emergency
1244
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1245
+				$data['format_source'] = 'fr24json';
1246
+				$data['id_source'] = $id_source;
1247
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1248
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1249
+			$SI->add($data);
1250
+			unset($data);
1251
+		}
1251 1252
 		}
1252
-	    }
1253
-	    //$last_exec['fr24json'] = time();
1254
-	    $last_exec[$id]['last'] = time();
1253
+		//$last_exec['fr24json'] = time();
1254
+		$last_exec[$id]['last'] = time();
1255 1255
 	//} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1256 1256
 	} elseif ($value['format'] === 'radarvirtueljson' && 
1257
-	    (
1257
+		(
1258 1258
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1259 1259
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1260
-	    )
1260
+		)
1261 1261
 	) {
1262
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1263
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1264
-	    //echo $buffer;
1265
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1266
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1267
-	    $all_data = json_decode($buffer,true);
1268
-	    if (json_last_error() != JSON_ERROR_NONE) {
1262
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1263
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1264
+		//echo $buffer;
1265
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1266
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1267
+		$all_data = json_decode($buffer,true);
1268
+		if (json_last_error() != JSON_ERROR_NONE) {
1269 1269
 		die(json_last_error_msg());
1270
-	    }
1271
-	    if (isset($all_data['mrkrs'])) {
1270
+		}
1271
+		if (isset($all_data['mrkrs'])) {
1272 1272
 		$reset = 0;
1273 1273
 		foreach ($all_data['mrkrs'] as $key => $line) {
1274
-		    if (isset($line['inf'])) {
1274
+			if (isset($line['inf'])) {
1275 1275
 			$data = array();
1276 1276
 			$data['hex'] = $line['inf']['ia'];
1277 1277
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1278
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1279
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1280
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1281
-	    		$data['latitude'] = $line['pt'][0]; // lat
1282
-	    		$data['longitude'] = $line['pt'][1]; // long
1283
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1284
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1285
-	    		//$data['aircraft_icao'] = $line[8];
1286
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1278
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1279
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1280
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1281
+				$data['latitude'] = $line['pt'][0]; // lat
1282
+				$data['longitude'] = $line['pt'][1]; // long
1283
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1284
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1285
+				//$data['aircraft_icao'] = $line[8];
1286
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1287 1287
 			//$data['departure_airport_iata'] = $line[11];
1288 1288
 			//$data['arrival_airport_iata'] = $line[12];
1289
-	    		//$data['emergency'] = ''; // emergency
1289
+				//$data['emergency'] = ''; // emergency
1290 1290
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1291
-	    		$data['format_source'] = 'radarvirtueljson';
1292
-    			$data['id_source'] = $id_source;
1291
+				$data['format_source'] = 'radarvirtueljson';
1292
+				$data['id_source'] = $id_source;
1293 1293
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1294 1294
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1295 1295
 			$SI->add($data);
1296 1296
 			unset($data);
1297
-		    }
1297
+			}
1298 1298
 		}
1299
-	    }
1300
-	    //$last_exec['radarvirtueljson'] = time();
1301
-	    $last_exec[$id]['last'] = time();
1299
+		}
1300
+		//$last_exec['radarvirtueljson'] = time();
1301
+		$last_exec[$id]['last'] = time();
1302 1302
 	//} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1303 1303
 	} elseif ($value['format'] === 'pirepsjson' && 
1304
-	    (
1304
+		(
1305 1305
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1306 1306
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1307
-	    )
1307
+		)
1308 1308
 	) {
1309
-	    //$buffer = $Common->getData($hosts[$id]);
1310
-	    $buffer = $Common->getData($value['host'].'?'.time());
1311
-	    $all_data = json_decode(utf8_encode($buffer),true);
1309
+		//$buffer = $Common->getData($hosts[$id]);
1310
+		$buffer = $Common->getData($value['host'].'?'.time());
1311
+		$all_data = json_decode(utf8_encode($buffer),true);
1312 1312
 	    
1313
-	    if (isset($all_data['pireps'])) {
1313
+		if (isset($all_data['pireps'])) {
1314 1314
 		$reset = 0;
1315
-	        foreach ($all_data['pireps'] as $line) {
1316
-		    $data = array();
1317
-		    $data['id'] = $line['id'];
1318
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1319
-		    $data['ident'] = $line['callsign']; // ident
1320
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1321
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1322
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1323
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1324
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1325
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1326
-		    $data['latitude'] = $line['lat']; // lat
1327
-		    $data['longitude'] = $line['lon']; // long
1328
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1329
-		    //$data['squawk'] = $line['squawk']; // squawk
1330
-		    //$data['emergency'] = ''; // emergency
1331
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1332
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1333
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1334
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1335
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1336
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1337
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1338
-		    else $data['info'] = '';
1339
-		    $data['format_source'] = 'pireps';
1340
-    		    $data['id_source'] = $id_source;
1341
-		    $data['datetime'] = date('Y-m-d H:i:s');
1342
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1343
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1344
-		    if ($line['icon'] === 'plane') {
1315
+			foreach ($all_data['pireps'] as $line) {
1316
+			$data = array();
1317
+			$data['id'] = $line['id'];
1318
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1319
+			$data['ident'] = $line['callsign']; // ident
1320
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1321
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1322
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1323
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1324
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1325
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1326
+			$data['latitude'] = $line['lat']; // lat
1327
+			$data['longitude'] = $line['lon']; // long
1328
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1329
+			//$data['squawk'] = $line['squawk']; // squawk
1330
+			//$data['emergency'] = ''; // emergency
1331
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1332
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1333
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1334
+			//$data['arrival_airport_time'] = $line['arrtime'];
1335
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1336
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1337
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1338
+			else $data['info'] = '';
1339
+			$data['format_source'] = 'pireps';
1340
+				$data['id_source'] = $id_source;
1341
+			$data['datetime'] = date('Y-m-d H:i:s');
1342
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1343
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1344
+			if ($line['icon'] === 'plane') {
1345 1345
 			$SI->add($data);
1346
-		    //    print_r($data);
1347
-    		    } elseif ($line['icon'] === 'ct') {
1346
+			//    print_r($data);
1347
+				} elseif ($line['icon'] === 'ct') {
1348 1348
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1349 1349
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1350 1350
 			$typec = substr($data['ident'],-3);
@@ -1359,209 +1359,209 @@  discard block
 block discarded – undo
1359 1359
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1360 1360
 			else $data['type'] = 'Observer';
1361 1361
 			if (isset($ATC)) 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']);
1362
-		    }
1363
-		    unset($data);
1362
+			}
1363
+			unset($data);
1364 1364
 		}
1365
-	    }
1366
-	    //$last_exec['pirepsjson'] = time();
1367
-	    $last_exec[$id]['last'] = time();
1365
+		}
1366
+		//$last_exec['pirepsjson'] = time();
1367
+		$last_exec[$id]['last'] = time();
1368 1368
 	//} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1369 1369
 	} elseif ($value['format'] === 'phpvmacars' && 
1370
-	    (
1370
+		(
1371 1371
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1372 1372
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1373
-	    )
1373
+		)
1374 1374
 	) {
1375
-	    //$buffer = $Common->getData($hosts[$id]);
1376
-	    if ($globalDebug) echo 'Get Data...'."\n";
1377
-	    $buffer = $Common->getData($value['host']);
1378
-	    $all_data = json_decode($buffer,true);
1379
-	    if ($buffer != '' && is_array($all_data)) {
1375
+		//$buffer = $Common->getData($hosts[$id]);
1376
+		if ($globalDebug) echo 'Get Data...'."\n";
1377
+		$buffer = $Common->getData($value['host']);
1378
+		$all_data = json_decode($buffer,true);
1379
+		if ($buffer != '' && is_array($all_data)) {
1380 1380
 		$reset = 0;
1381 1381
 		foreach ($all_data as $line) {
1382
-	    	    $data = array();
1383
-	    	    //$data['id'] = $line['id']; // id not usable
1384
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1385
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1386
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1387
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1388
-	    	    $data['ident'] = $line['flightnum']; // ident
1389
-	    	    $data['altitude'] = $line['alt']; // altitude
1390
-	    	    $data['speed'] = $line['gs']; // speed
1391
-	    	    $data['heading'] = $line['heading']; // heading
1392
-	    	    $data['latitude'] = $line['lat']; // lat
1393
-	    	    $data['longitude'] = $line['lng']; // long
1394
-	    	    $data['verticalrate'] = ''; // verticale rate
1395
-	    	    $data['squawk'] = ''; // squawk
1396
-	    	    $data['emergency'] = ''; // emergency
1397
-	    	    //$data['datetime'] = $line['lastupdate'];
1398
-	    	    //$data['last_update'] = $line['lastupdate'];
1399
-	    	    if (isset($value['timezone'])) {
1400
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1401
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1402
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1403
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1404
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1405
-	    	    $data['departure_airport_time'] = $line['deptime'];
1406
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1407
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1408
-    		    if (isset($line['registration'])) {
1409
-    			$data['registration'] = $line['registration'];
1410
-    			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1411
-    		    } else $data['registration'] = $line['aircraft'];
1412
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1413
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1414
-		    if (isset($line['aircraftname'])) {
1382
+				$data = array();
1383
+				//$data['id'] = $line['id']; // id not usable
1384
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1385
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1386
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1387
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1388
+				$data['ident'] = $line['flightnum']; // ident
1389
+				$data['altitude'] = $line['alt']; // altitude
1390
+				$data['speed'] = $line['gs']; // speed
1391
+				$data['heading'] = $line['heading']; // heading
1392
+				$data['latitude'] = $line['lat']; // lat
1393
+				$data['longitude'] = $line['lng']; // long
1394
+				$data['verticalrate'] = ''; // verticale rate
1395
+				$data['squawk'] = ''; // squawk
1396
+				$data['emergency'] = ''; // emergency
1397
+				//$data['datetime'] = $line['lastupdate'];
1398
+				//$data['last_update'] = $line['lastupdate'];
1399
+				if (isset($value['timezone'])) {
1400
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1401
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1402
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1403
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1404
+				$data['departure_airport_icao'] = $line['depicao'];
1405
+				$data['departure_airport_time'] = $line['deptime'];
1406
+				$data['arrival_airport_icao'] = $line['arricao'];
1407
+				$data['arrival_airport_time'] = $line['arrtime'];
1408
+				if (isset($line['registration'])) {
1409
+				$data['registration'] = $line['registration'];
1410
+				//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1411
+				} else $data['registration'] = $line['aircraft'];
1412
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1413
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1414
+			if (isset($line['aircraftname'])) {
1415 1415
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1416 1416
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1417
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1418
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1419
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1420
-	    		else {
1421
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1422
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1423
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1424
-	    		}
1425
-	    	    }
1426
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1427
-    		    $data['id_source'] = $id_source;
1428
-	    	    $data['format_source'] = 'phpvmacars';
1429
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1430
-		    $SI->add($data);
1431
-		    unset($data);
1417
+				$aircraft_data = explode('-',$line['aircraftname']);
1418
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1419
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1420
+				else {
1421
+					$aircraft_data = explode(' ',$line['aircraftname']);
1422
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1423
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1424
+				}
1425
+				}
1426
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1427
+				$data['id_source'] = $id_source;
1428
+				$data['format_source'] = 'phpvmacars';
1429
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1430
+			$SI->add($data);
1431
+			unset($data);
1432 1432
 		}
1433 1433
 		if ($globalDebug) echo 'No more data...'."\n";
1434 1434
 		unset($buffer);
1435 1435
 		unset($all_data);
1436
-	    }
1437
-	    //$last_exec['phpvmacars'] = time();
1438
-	    $last_exec[$id]['last'] = time();
1436
+		}
1437
+		//$last_exec['phpvmacars'] = time();
1438
+		$last_exec[$id]['last'] = time();
1439 1439
 	} elseif ($value['format'] === 'vaos' && 
1440
-	    (
1440
+		(
1441 1441
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1442 1442
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1443
-	    )
1443
+		)
1444 1444
 	) {
1445
-	    //$buffer = $Common->getData($hosts[$id]);
1446
-	    if ($globalDebug) echo 'Get Data...'."\n";
1447
-	    $buffer = $Common->getData($value['host']);
1448
-	    $all_data = json_decode($buffer,true);
1449
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1445
+		//$buffer = $Common->getData($hosts[$id]);
1446
+		if ($globalDebug) echo 'Get Data...'."\n";
1447
+		$buffer = $Common->getData($value['host']);
1448
+		$all_data = json_decode($buffer,true);
1449
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1450 1450
 		$reset = 0;
1451 1451
 		foreach ($all_data['ACARSData'] as $line) {
1452
-		    //print_r($line);
1453
-	    	    $data = array();
1454
-	    	    //$data['id'] = $line['id']; // id not usable
1455
-	    	    $data['id'] = $line['id'];
1456
-	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1457
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1458
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1459
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1460
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1461
-	    	    $data['altitude'] = $line['altitude']; // altitude
1462
-	    	    $data['speed'] = $line['groundspeed']; // speed
1463
-	    	    $data['heading'] = $line['heading']; // heading
1464
-	    	    $data['latitude'] = $line['lat']; // lat
1465
-	    	    $data['longitude'] = $line['lon']; // long
1466
-	    	    //$data['verticalrate'] = ''; // verticale rate
1467
-	    	    //$data['squawk'] = ''; // squawk
1468
-	    	    //$data['emergency'] = ''; // emergency
1469
-	    	    if (isset($value['timezone'])) {
1470
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1471
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1472
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1473
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1452
+			//print_r($line);
1453
+				$data = array();
1454
+				//$data['id'] = $line['id']; // id not usable
1455
+				$data['id'] = $line['id'];
1456
+				//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1457
+				if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1458
+				if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1459
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1460
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1461
+				$data['altitude'] = $line['altitude']; // altitude
1462
+				$data['speed'] = $line['groundspeed']; // speed
1463
+				$data['heading'] = $line['heading']; // heading
1464
+				$data['latitude'] = $line['lat']; // lat
1465
+				$data['longitude'] = $line['lon']; // long
1466
+				//$data['verticalrate'] = ''; // verticale rate
1467
+				//$data['squawk'] = ''; // squawk
1468
+				//$data['emergency'] = ''; // emergency
1469
+				if (isset($value['timezone'])) {
1470
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1471
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1472
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1473
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1474 1474
 	    	    
1475
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1476
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1477
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1478
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1479
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1475
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1476
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1477
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1478
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1479
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1480 1480
 
1481
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1482
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1483
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1481
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1482
+			if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1483
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1484 1484
 
1485
-    		    $data['id_source'] = $id_source;
1486
-	    	    $data['format_source'] = 'vaos';
1487
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1488
-		    $SI->add($data);
1489
-		    unset($data);
1485
+				$data['id_source'] = $id_source;
1486
+				$data['format_source'] = 'vaos';
1487
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1488
+			$SI->add($data);
1489
+			unset($data);
1490 1490
 		}
1491 1491
 		if ($globalDebug) echo 'No more data...'."\n";
1492 1492
 		unset($buffer);
1493 1493
 		unset($all_data);
1494
-	    }
1495
-	    //$last_exec['phpvmacars'] = time();
1496
-	    $last_exec[$id]['last'] = time();
1494
+		}
1495
+		//$last_exec['phpvmacars'] = time();
1496
+		$last_exec[$id]['last'] = time();
1497 1497
 	} elseif ($value['format'] === 'vam' && 
1498
-	    (
1498
+		(
1499 1499
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1500 1500
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1501
-	    )
1501
+		)
1502 1502
 	) {
1503
-	    //$buffer = $Common->getData($hosts[$id]);
1504
-	    if ($globalDebug) echo 'Get Data...'."\n";
1505
-	    $buffer = $Common->getData($value['host']);
1506
-	    $all_data = json_decode($buffer,true);
1507
-	    if ($buffer != '' && is_array($all_data)) {
1503
+		//$buffer = $Common->getData($hosts[$id]);
1504
+		if ($globalDebug) echo 'Get Data...'."\n";
1505
+		$buffer = $Common->getData($value['host']);
1506
+		$all_data = json_decode($buffer,true);
1507
+		if ($buffer != '' && is_array($all_data)) {
1508 1508
 		$reset = 0;
1509 1509
 		foreach ($all_data as $line) {
1510
-	    	    $data = array();
1511
-	    	    //$data['id'] = $line['id']; // id not usable
1512
-	    	    $data['id'] = trim($line['flight_id']);
1513
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1514
-	    	    $data['pilot_name'] = $line['pilot_name'];
1515
-	    	    $data['pilot_id'] = $line['pilot_id'];
1516
-	    	    $data['ident'] = trim($line['callsign']); // ident
1517
-	    	    $data['altitude'] = $line['altitude']; // altitude
1518
-	    	    $data['speed'] = $line['gs']; // speed
1519
-	    	    $data['heading'] = $line['heading']; // heading
1520
-	    	    $data['latitude'] = $line['latitude']; // lat
1521
-	    	    $data['longitude'] = $line['longitude']; // long
1522
-	    	    $data['verticalrate'] = ''; // verticale rate
1523
-	    	    $data['squawk'] = ''; // squawk
1524
-	    	    $data['emergency'] = ''; // emergency
1525
-	    	    //$data['datetime'] = $line['lastupdate'];
1526
-	    	    $data['last_update'] = $line['last_update'];
1527
-		    $data['datetime'] = date('Y-m-d H:i:s');
1528
-	    	    $data['departure_airport_icao'] = $line['departure'];
1529
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1530
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1531
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1532
-    		    //$data['registration'] = $line['aircraft'];
1533
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1534
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1535
-    		    $data['id_source'] = $id_source;
1536
-	    	    $data['format_source'] = 'vam';
1537
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1538
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1539
-		    $SI->add($data);
1540
-		    unset($data);
1510
+				$data = array();
1511
+				//$data['id'] = $line['id']; // id not usable
1512
+				$data['id'] = trim($line['flight_id']);
1513
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1514
+				$data['pilot_name'] = $line['pilot_name'];
1515
+				$data['pilot_id'] = $line['pilot_id'];
1516
+				$data['ident'] = trim($line['callsign']); // ident
1517
+				$data['altitude'] = $line['altitude']; // altitude
1518
+				$data['speed'] = $line['gs']; // speed
1519
+				$data['heading'] = $line['heading']; // heading
1520
+				$data['latitude'] = $line['latitude']; // lat
1521
+				$data['longitude'] = $line['longitude']; // long
1522
+				$data['verticalrate'] = ''; // verticale rate
1523
+				$data['squawk'] = ''; // squawk
1524
+				$data['emergency'] = ''; // emergency
1525
+				//$data['datetime'] = $line['lastupdate'];
1526
+				$data['last_update'] = $line['last_update'];
1527
+			$data['datetime'] = date('Y-m-d H:i:s');
1528
+				$data['departure_airport_icao'] = $line['departure'];
1529
+				//$data['departure_airport_time'] = $line['departure_time'];
1530
+				$data['arrival_airport_icao'] = $line['arrival'];
1531
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1532
+				//$data['registration'] = $line['aircraft'];
1533
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1534
+				$data['aircraft_icao'] = $line['plane_type'];
1535
+				$data['id_source'] = $id_source;
1536
+				$data['format_source'] = 'vam';
1537
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1538
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1539
+			$SI->add($data);
1540
+			unset($data);
1541 1541
 		}
1542 1542
 		if ($globalDebug) echo 'No more data...'."\n";
1543 1543
 		unset($buffer);
1544 1544
 		unset($all_data);
1545
-	    }
1546
-	    //$last_exec['phpvmacars'] = time();
1547
-	    $last_exec[$id]['last'] = time();
1545
+		}
1546
+		//$last_exec['phpvmacars'] = time();
1547
+		$last_exec[$id]['last'] = time();
1548 1548
 	} elseif ($value['format'] === 'blitzortung' && 
1549
-	    (
1549
+		(
1550 1550
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1551 1551
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1552
-	    )
1552
+		)
1553 1553
 	) {
1554
-	    //$buffer = $Common->getData($hosts[$id]);
1555
-	    if ($globalDebug) echo 'Get Data...'."\n";
1556
-	    $buffer = $Common->getData($value['host']);
1557
-	    $all_data = json_decode($buffer,true);
1558
-	    if ($buffer != '') {
1554
+		//$buffer = $Common->getData($hosts[$id]);
1555
+		if ($globalDebug) echo 'Get Data...'."\n";
1556
+		$buffer = $Common->getData($value['host']);
1557
+		$all_data = json_decode($buffer,true);
1558
+		if ($buffer != '') {
1559 1559
 		$Source->deleteLocationBySource('blitzortung');
1560 1560
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1561 1561
 		$buffer = explode('\n',$buffer);
1562 1562
 		foreach ($buffer as $buffer_line) {
1563
-		    $line = json_decode($buffer_line,true);
1564
-		    if (isset($line['time'])) {
1563
+			$line = json_decode($buffer_line,true);
1564
+			if (isset($line['time'])) {
1565 1565
 			$data = array();
1566 1566
 			$data['altitude'] = $line['alt']; // altitude
1567 1567
 			$data['latitude'] = $line['lat']; // lat
@@ -1573,94 +1573,94 @@  discard block
 block discarded – undo
1573 1573
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1574 1574
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1575 1575
 			unset($data);
1576
-		    }
1576
+			}
1577 1577
 		}
1578 1578
 		if ($globalDebug) echo 'No more data...'."\n";
1579 1579
 		unset($buffer);
1580
-	    }
1581
-	    $last_exec[$id]['last'] = time();
1580
+		}
1581
+		$last_exec[$id]['last'] = time();
1582 1582
 	//} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') {
1583 1583
 	} elseif ($value['format'] === 'sbs' || $value['format'] === 'tsv' || $value['format'] === 'raw' || $value['format'] === 'aprs' || $value['format'] === 'famaprs' || $value['format'] === 'beast' || $value['format'] === 'flightgearmp' || $value['format'] === 'flightgearsp' || $value['format'] === 'acars' || $value['format'] === 'acarssbs3' || $value['format'] === 'ais' || $value['format'] === 'vrstcp') {
1584
-	    //$last_exec[$id]['last'] = time();
1585
-	    //$read = array( $sockets[$id] );
1586
-	    $read = $sockets;
1587
-	    $write = NULL;
1588
-	    $e = NULL;
1589
-	    $n = socket_select($read, $write, $e, $timeout);
1590
-	    if ($e != NULL) var_dump($e);
1591
-	    if ($n > 0) {
1584
+		//$last_exec[$id]['last'] = time();
1585
+		//$read = array( $sockets[$id] );
1586
+		$read = $sockets;
1587
+		$write = NULL;
1588
+		$e = NULL;
1589
+		$n = socket_select($read, $write, $e, $timeout);
1590
+		if ($e != NULL) var_dump($e);
1591
+		if ($n > 0) {
1592 1592
 		$reset = 0;
1593 1593
 		foreach ($read as $nb => $r) {
1594
-		    //$value = $formats[$nb];
1595
-		    $format = $globalSources[$nb]['format'];
1596
-		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1594
+			//$value = $formats[$nb];
1595
+			$format = $globalSources[$nb]['format'];
1596
+			if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1597 1597
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1598
-		    } elseif ($format === 'vrstcp') {
1598
+			} elseif ($format === 'vrstcp') {
1599 1599
 			$buffer = @socket_read($r, 6000);
1600
-		    } else {
1600
+			} else {
1601 1601
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1602
-		    }
1603
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1604
-		    //echo $buffer."\n";
1605
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1606
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1607
-		    $error = false;
1608
-		    //$SI::del();
1609
-		    if ($buffer !== FALSE) {
1602
+			}
1603
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1604
+			//echo $buffer."\n";
1605
+			// lets play nice and handle signals such as ctrl-c/kill properly
1606
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1607
+			$error = false;
1608
+			//$SI::del();
1609
+			if ($buffer !== FALSE) {
1610 1610
 			if ($format === 'vrstcp') {
1611
-			    $buffer = explode('},{',$buffer);
1611
+				$buffer = explode('},{',$buffer);
1612 1612
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1613
-		    }
1614
-		    // SBS format is CSV format
1615
-		    if ($buffer !== FALSE && $buffer !== '') {
1613
+			}
1614
+			// SBS format is CSV format
1615
+			if ($buffer !== FALSE && $buffer !== '') {
1616 1616
 			$tt[$format] = 0;
1617 1617
 			if ($format === 'acarssbs3') {
1618
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1619
-			    $ACARS->add(trim($buffer));
1620
-			    $ACARS->deleteLiveAcarsData();
1618
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1619
+				$ACARS->add(trim($buffer));
1620
+				$ACARS->deleteLiveAcarsData();
1621 1621
 			} elseif ($format === 'raw') {
1622
-			    // AVR format
1623
-			    $data = $SBS->parse($buffer);
1624
-			    if (is_array($data)) {
1622
+				// AVR format
1623
+				$data = $SBS->parse($buffer);
1624
+				if (is_array($data)) {
1625 1625
 				$data['datetime'] = date('Y-m-d H:i:s');
1626 1626
 				$data['format_source'] = 'raw';
1627 1627
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1628 1628
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1629 1629
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1630 1630
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1631
-			    }
1631
+				}
1632 1632
 			} elseif ($format === 'ais') {
1633
-			    $ais_data = $AIS->parse_line(trim($buffer));
1634
-			    $data = array();
1635
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1636
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1637
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1638
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1639
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1640
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1641
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1642
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1643
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1644
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1645
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1646
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1647
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1648
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1649
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1650
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1633
+				$ais_data = $AIS->parse_line(trim($buffer));
1634
+				$data = array();
1635
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1636
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1637
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1638
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1639
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1640
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1641
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1642
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1643
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1644
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1645
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1646
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1647
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1648
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1649
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1650
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1651 1651
 
1652
-			    if (isset($ais_data['timestamp'])) {
1652
+				if (isset($ais_data['timestamp'])) {
1653 1653
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1654
-			    } else {
1654
+				} else {
1655 1655
 				$data['datetime'] = date('Y-m-d H:i:s');
1656
-			    }
1657
-			    $data['format_source'] = 'aisnmea';
1658
-    			    $data['id_source'] = $id_source;
1659
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1660
-			    unset($data);
1661
-                        } elseif ($format === 'flightgearsp') {
1662
-                    	    //echo $buffer."\n";
1663
-                    	    if (strlen($buffer) > 5) {
1656
+				}
1657
+				$data['format_source'] = 'aisnmea';
1658
+					$data['id_source'] = $id_source;
1659
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1660
+				unset($data);
1661
+						} elseif ($format === 'flightgearsp') {
1662
+							//echo $buffer."\n";
1663
+							if (strlen($buffer) > 5) {
1664 1664
 				$line = explode(',',$buffer);
1665 1665
 				$data = array();
1666 1666
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1677,38 +1677,38 @@  discard block
 block discarded – undo
1677 1677
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1678 1678
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1679 1679
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1680
-			    }
1681
-                        } elseif ($format === 'acars') {
1682
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1683
-			    $ACARS->add(trim($buffer));
1684
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1685
-			    $ACARS->deleteLiveAcarsData();
1680
+				}
1681
+						} elseif ($format === 'acars') {
1682
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1683
+				$ACARS->add(trim($buffer));
1684
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1685
+				$ACARS->deleteLiveAcarsData();
1686 1686
 			} elseif ($format === 'flightgearmp') {
1687
-			    if (substr($buffer,0,1) != '#') {
1687
+				if (substr($buffer,0,1) != '#') {
1688 1688
 				$data = array();
1689 1689
 				//echo $buffer."\n";
1690 1690
 				$line = explode(' ',$buffer);
1691 1691
 				if (count($line) === 11) {
1692
-				    $userserver = explode('@',$line[0]);
1693
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1694
-				    $data['ident'] = $userserver[0];
1695
-				    $data['registration'] = $userserver[0];
1696
-				    $data['latitude'] = $line[4];
1697
-				    $data['longitude'] = $line[5];
1698
-				    $data['altitude'] = $line[6];
1699
-				    $data['datetime'] = date('Y-m-d H:i:s');
1700
-				    $aircraft_type = $line[10];
1701
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1702
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1703
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1704
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1692
+					$userserver = explode('@',$line[0]);
1693
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1694
+					$data['ident'] = $userserver[0];
1695
+					$data['registration'] = $userserver[0];
1696
+					$data['latitude'] = $line[4];
1697
+					$data['longitude'] = $line[5];
1698
+					$data['altitude'] = $line[6];
1699
+					$data['datetime'] = date('Y-m-d H:i:s');
1700
+					$aircraft_type = $line[10];
1701
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1702
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1703
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1704
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1705
+				}
1705 1706
 				}
1706
-			    }
1707 1707
 			} elseif ($format === 'beast') {
1708
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1709
-			    die;
1708
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1709
+				die;
1710 1710
 			} elseif ($format === 'vrstcp') {
1711
-			    foreach($buffer as $all_data) {
1711
+				foreach($buffer as $all_data) {
1712 1712
 				$line = json_decode('{'.$all_data.'}',true);
1713 1713
 				$data = array();
1714 1714
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1728,158 +1728,158 @@  discard block
 block discarded – undo
1728 1728
 				*/
1729 1729
 				$data['datetime'] = date('Y-m-d H:i:s');
1730 1730
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1731
-		    		$data['format_source'] = 'vrstcp';
1731
+					$data['format_source'] = 'vrstcp';
1732 1732
 				$data['id_source'] = $id_source;
1733 1733
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1734 1734
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1735 1735
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1736 1736
 				unset($data);
1737
-			    }
1737
+				}
1738 1738
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1739
-			    $line = explode("\t", $buffer);
1740
-			    for($k = 0; $k < count($line); $k=$k+2) {
1739
+				$line = explode("\t", $buffer);
1740
+				for($k = 0; $k < count($line); $k=$k+2) {
1741 1741
 				$key = $line[$k];
1742
-			        $lined[$key] = $line[$k+1];
1743
-			    }
1744
-    			    if (count($lined) > 3) {
1745
-    				$data['hex'] = $lined['hexid'];
1746
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1747
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1748
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1749
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1750
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1751
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1752
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1753
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1754
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1755
-    				$data['id_source'] = $id_source;
1756
-    				$data['format_source'] = 'tsv';
1757
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1758
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1742
+					$lined[$key] = $line[$k+1];
1743
+				}
1744
+					if (count($lined) > 3) {
1745
+					$data['hex'] = $lined['hexid'];
1746
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1747
+					$data['datetime'] = date('Y-m-d H:i:s');;
1748
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1749
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1750
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1751
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1752
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1753
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1754
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1755
+					$data['id_source'] = $id_source;
1756
+					$data['format_source'] = 'tsv';
1757
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1758
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1759 1759
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1760
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1761
-    				unset($lined);
1762
-    				unset($data);
1763
-    			    } else $error = true;
1760
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1761
+					unset($lined);
1762
+					unset($data);
1763
+					} else $error = true;
1764 1764
 			} elseif ($format === 'aprs' && $use_aprs) {
1765
-			    if ($aprs_connect === 0) {
1765
+				if ($aprs_connect === 0) {
1766 1766
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1767 1767
 				$aprs_connect = 1;
1768
-			    }
1768
+				}
1769 1769
 			    
1770
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1770
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1771 1771
 				$aprs_last_tx = time();
1772 1772
 				$data_aprs = "# Keep alive";
1773 1773
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1774
-			    }
1774
+				}
1775 1775
 			    
1776
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1777
-			    //echo 'APRS data : '.$buffer."\n";
1778
-			    $buffer = str_replace('APRS <- ','',$buffer);
1779
-			    $buffer = str_replace('APRS -> ','',$buffer);
1780
-			    //echo $buffer."\n";
1781
-			    date_default_timezone_set('UTC');
1782
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1776
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1777
+				//echo 'APRS data : '.$buffer."\n";
1778
+				$buffer = str_replace('APRS <- ','',$buffer);
1779
+				$buffer = str_replace('APRS -> ','',$buffer);
1780
+				//echo $buffer."\n";
1781
+				date_default_timezone_set('UTC');
1782
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1783 1783
 				$line = $APRS->parse($buffer);
1784 1784
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1785 1785
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1786
-				    $aprs_last_tx = time();
1787
-				    $data = array();
1788
-				    //print_r($line);
1789
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1790
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1791
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1792
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1793
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1794
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1795
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1796
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1797
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1798
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1799
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1800
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1801
-				    $data['latitude'] = $line['latitude'];
1802
-				    $data['longitude'] = $line['longitude'];
1803
-				    //$data['verticalrate'] = $line[16];
1804
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1805
-				    //else $data['speed'] = 0;
1806
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1807
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1808
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1809
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1786
+					$aprs_last_tx = time();
1787
+					$data = array();
1788
+					//print_r($line);
1789
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1790
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1791
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1792
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1793
+					if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1794
+					if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1795
+					if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1796
+					if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1797
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1798
+					else $data['datetime'] = date('Y-m-d H:i:s');
1799
+					//$data['datetime'] = date('Y-m-d H:i:s');
1800
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1801
+					$data['latitude'] = $line['latitude'];
1802
+					$data['longitude'] = $line['longitude'];
1803
+					//$data['verticalrate'] = $line[16];
1804
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1805
+					//else $data['speed'] = 0;
1806
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1807
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1808
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1809
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1810 1810
 				    
1811
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1812
-				    //else echo 'No heading...'."\n";
1813
-				    //else $data['heading'] = 0;
1814
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1815
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1816
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1817
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1818
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1819
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1820
-    				    $data['id_source'] = $id_source;
1821
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1822
-				    else $data['format_source'] = 'aprs';
1823
-				    $data['source_name'] = $line['source'];
1824
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1825
-				    else $data['source_type'] = 'flarm';
1826
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1827
-				    $currentdate = date('Y-m-d H:i:s');
1828
-				    $aprsdate = strtotime($data['datetime']);
1829
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1830
-				    // Accept data if time <= system time + 20s
1831
-				    //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1832
-				    if (
1811
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1812
+					//else echo 'No heading...'."\n";
1813
+					//else $data['heading'] = 0;
1814
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1815
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1816
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1817
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1818
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1819
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1820
+						$data['id_source'] = $id_source;
1821
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1822
+					else $data['format_source'] = 'aprs';
1823
+					$data['source_name'] = $line['source'];
1824
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1825
+					else $data['source_type'] = 'flarm';
1826
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1827
+					$currentdate = date('Y-m-d H:i:s');
1828
+					$aprsdate = strtotime($data['datetime']);
1829
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1830
+					// Accept data if time <= system time + 20s
1831
+					//if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1832
+					if (
1833 1833
 					($data['source_type'] === 'modes') || 
1834 1834
 					isset($line['stealth']) && 
1835 1835
 					(!isset($data['hex']) || $data['hex'] != 'FFFFFF') && 
1836 1836
 					 ($line['stealth'] === 0 || $line['stealth'] == '') && 
1837 1837
 					 (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1838 1838
 					$send = $SI->add($data);
1839
-				    } elseif ($data['source_type'] === 'ais') {
1839
+					} elseif ($data['source_type'] === 'ais') {
1840 1840
 					$data['type'] = '';
1841 1841
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1842
-				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1842
+					} elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1843 1843
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1844
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1845
-					    //$line['symbol'] === 'Balloon' ||
1846
-					    $line['symbol'] === 'Glider' || 
1847
-					    $line['symbol'] === 'No. Plane' || 
1848
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1849
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1850
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1851
-					    $send = $SI->add($data);
1852
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1853
-					    $line['symbol'] === 'Yacht (Sail)' || 
1854
-					    $line['symbol'] === 'Ship (Power Boat)')) {
1855
-					    $send = $MI->add($data);
1856
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1857
-					    $line['symbol'] === 'Car' || 
1858
-					    $line['symbol'] === 'Ambulance' || 
1859
-					    $line['symbol'] === 'Van' || 
1860
-					    $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1861
-					    $line['symbol'] === 'Motorcycle' || 
1862
-					    $line['symbol'] === 'Tractor' || 
1863
-					    $line['symbol'] === 'Police' || 
1864
-					    $line['symbol'] === 'Bike' || 
1865
-					    $line['symbol'] === 'Jogger' || 
1866
-					    $line['symbol'] === 'Horse' || 
1867
-					    $line['symbol'] === 'Bus' || 
1868
-					    $line['symbol'] === 'Jeep' || 
1869
-					    $line['symbol'] === 'Recreational Vehicle' || 
1870
-					    $line['symbol'] === 'Yacht (Sail)' || 
1871
-					    $line['symbol'] === 'Ship (Power Boat)' || 
1872
-					    $line['symbol'] === 'Firetruck' || 
1873
-					    $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1874
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1875
-					    $line['symbol'] === 'SUV' ||
1876
-					    $line['symbol'] === 'Snowmobile' ||
1877
-					    $line['symbol'] === 'Mobile Satellite Station')) {
1878
-				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1844
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1845
+						//$line['symbol'] === 'Balloon' ||
1846
+						$line['symbol'] === 'Glider' || 
1847
+						$line['symbol'] === 'No. Plane' || 
1848
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1849
+						if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1850
+						if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1851
+						$send = $SI->add($data);
1852
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1853
+						$line['symbol'] === 'Yacht (Sail)' || 
1854
+						$line['symbol'] === 'Ship (Power Boat)')) {
1855
+						$send = $MI->add($data);
1856
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1857
+						$line['symbol'] === 'Car' || 
1858
+						$line['symbol'] === 'Ambulance' || 
1859
+						$line['symbol'] === 'Van' || 
1860
+						$line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1861
+						$line['symbol'] === 'Motorcycle' || 
1862
+						$line['symbol'] === 'Tractor' || 
1863
+						$line['symbol'] === 'Police' || 
1864
+						$line['symbol'] === 'Bike' || 
1865
+						$line['symbol'] === 'Jogger' || 
1866
+						$line['symbol'] === 'Horse' || 
1867
+						$line['symbol'] === 'Bus' || 
1868
+						$line['symbol'] === 'Jeep' || 
1869
+						$line['symbol'] === 'Recreational Vehicle' || 
1870
+						$line['symbol'] === 'Yacht (Sail)' || 
1871
+						$line['symbol'] === 'Ship (Power Boat)' || 
1872
+						$line['symbol'] === 'Firetruck' || 
1873
+						$line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1874
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1875
+						$line['symbol'] === 'SUV' ||
1876
+						$line['symbol'] === 'Snowmobile' ||
1877
+						$line['symbol'] === 'Mobile Satellite Station')) {
1878
+					//} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1879 1879
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1880 1880
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1881 1881
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1882
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1882
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1883 1883
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1884 1884
 					$Source->deleteOldLocationByType('gs');
1885 1885
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1887,7 +1887,7 @@  discard block
 block discarded – undo
1887 1887
 					} else {
1888 1888
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1889 1889
 					}
1890
-				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1890
+					} elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1891 1891
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1892 1892
 					if ($globalDebug) echo '# Weather Station added'."\n";
1893 1893
 					$Source->deleteOldLocationByType('wx');
@@ -1897,7 +1897,7 @@  discard block
 block discarded – undo
1897 1897
 					} else {
1898 1898
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1899 1899
 					}
1900
-				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1900
+					} elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1901 1901
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1902 1902
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1903 1903
 					$Source->deleteOldLocationByType('lightning');
@@ -1906,11 +1906,11 @@  discard block
 block discarded – undo
1906 1906
 					} else {
1907 1907
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1908 1908
 					}
1909
-				    } elseif ($globalDebug) {
1910
-				    	echo '/!\ Not added: '.$buffer."\n";
1911
-				    	print_r($line);
1912
-				    }
1913
-				    unset($data);
1909
+					} elseif ($globalDebug) {
1910
+						echo '/!\ Not added: '.$buffer."\n";
1911
+						print_r($line);
1912
+					}
1913
+					unset($data);
1914 1914
 				}
1915 1915
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1916 1916
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1929,12 +1929,12 @@  discard block
 block discarded – undo
1929 1929
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1930 1930
 					$globalSources[$nb]['last_weather_clean'] = time();
1931 1931
 				}
1932
-			    }
1932
+				}
1933 1933
 			} else {
1934
-			    $line = explode(',', $buffer);
1935
-    			    if (count($line) > 20) {
1936
-    			    	$data['hex'] = $line[4];
1937
-    				/*
1934
+				$line = explode(',', $buffer);
1935
+					if (count($line) > 20) {
1936
+						$data['hex'] = $line[4];
1937
+					/*
1938 1938
     				$data['datetime'] = $line[6].' '.$line[7];
1939 1939
     					date_default_timezone_set($globalTimezone);
1940 1940
     					$datetime = new DateTime($data['datetime']);
@@ -1942,31 +1942,31 @@  discard block
 block discarded – undo
1942 1942
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1943 1943
     					date_default_timezone_set('UTC');
1944 1944
     				*/
1945
-    				// Force datetime to current UTC datetime
1946
-    				date_default_timezone_set('UTC');
1947
-    				$data['datetime'] = date('Y-m-d H:i:s');
1948
-    				$data['ident'] = trim($line[10]);
1949
-    				$data['latitude'] = $line[14];
1950
-    				$data['longitude'] = $line[15];
1951
-    				$data['verticalrate'] = $line[16];
1952
-    				$data['emergency'] = $line[20];
1953
-    				$data['speed'] = $line[12];
1954
-    				$data['squawk'] = $line[17];
1955
-    				$data['altitude'] = $line[11];
1956
-    				$data['heading'] = $line[13];
1957
-    				$data['ground'] = $line[21];
1958
-    				$data['emergency'] = $line[19];
1959
-    				$data['format_source'] = 'sbs';
1945
+					// Force datetime to current UTC datetime
1946
+					date_default_timezone_set('UTC');
1947
+					$data['datetime'] = date('Y-m-d H:i:s');
1948
+					$data['ident'] = trim($line[10]);
1949
+					$data['latitude'] = $line[14];
1950
+					$data['longitude'] = $line[15];
1951
+					$data['verticalrate'] = $line[16];
1952
+					$data['emergency'] = $line[20];
1953
+					$data['speed'] = $line[12];
1954
+					$data['squawk'] = $line[17];
1955
+					$data['altitude'] = $line[11];
1956
+					$data['heading'] = $line[13];
1957
+					$data['ground'] = $line[21];
1958
+					$data['emergency'] = $line[19];
1959
+					$data['format_source'] = 'sbs';
1960 1960
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1961 1961
 				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
1962
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1962
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1963 1963
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1964
-    				$data['id_source'] = $id_source;
1965
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1966
-    				else $error = true;
1967
-    				unset($data);
1968
-    			    } else $error = true;
1969
-			    if ($error) {
1964
+					$data['id_source'] = $id_source;
1965
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1966
+					else $error = true;
1967
+					unset($data);
1968
+					} else $error = true;
1969
+				if ($error) {
1970 1970
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1971 1971
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1972 1972
 				} else {
@@ -1982,13 +1982,13 @@  discard block
 block discarded – undo
1982 1982
 					connect_all($sourceer);
1983 1983
 					$sourceer = array();
1984 1984
 				}
1985
-			    }
1985
+				}
1986 1986
 			}
1987 1987
 			// Sleep for xxx microseconds
1988 1988
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1989
-		    } else {
1989
+			} else {
1990 1990
 			if ($format === 'flightgearmp') {
1991
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1991
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1992 1992
 				//@socket_close($r);
1993 1993
 				sleep($globalMinFetch);
1994 1994
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1997,9 +1997,9 @@  discard block
 block discarded – undo
1997 1997
 				break;
1998 1998
 				
1999 1999
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2000
-			    if (isset($tt[$format])) $tt[$format]++;
2001
-			    else $tt[$format] = 0;
2002
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
2000
+				if (isset($tt[$format])) $tt[$format]++;
2001
+				else $tt[$format] = 0;
2002
+				if ($tt[$format] > 30 || $buffer === FALSE) {
2003 2003
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2004 2004
 				//@socket_close($r);
2005 2005
 				sleep(2);
@@ -2010,24 +2010,24 @@  discard block
 block discarded – undo
2010 2010
 				//connect_all($globalSources);
2011 2011
 				$tt[$format]=0;
2012 2012
 				break;
2013
-			    } 
2014
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2013
+				} 
2014
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2015
+			}
2015 2016
 			}
2016
-		    }
2017 2017
 		}
2018
-	    } else {
2018
+		} else {
2019 2019
 		$error = socket_strerror(socket_last_error());
2020 2020
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2021 2021
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2022 2022
 			if (isset($globalDebug)) echo "Restarting...\n";
2023 2023
 			// Restart the script if possible
2024 2024
 			if (is_array($sockets)) {
2025
-			    if ($globalDebug) echo "Shutdown all sockets...";
2025
+				if ($globalDebug) echo "Shutdown all sockets...";
2026 2026
 			    
2027
-			    foreach ($sockets as $sock) {
2027
+				foreach ($sockets as $sock) {
2028 2028
 				@socket_shutdown($sock,2);
2029 2029
 				@socket_close($sock);
2030
-			    }
2030
+				}
2031 2031
 			    
2032 2032
 			}
2033 2033
 			if ($globalDebug) echo "Waiting...";
@@ -2042,15 +2042,15 @@  discard block
 block discarded – undo
2042 2042
 			if ($globalDebug) echo "Restart all connections...";
2043 2043
 			connect_all($globalSources);
2044 2044
 		}
2045
-	    }
2045
+		}
2046 2046
 	}
2047 2047
 	if ($globalDaemon === false) {
2048
-	    if ($globalDebug) echo 'Check all...'."\n";
2049
-	    if (isset($SI)) $SI->checkAll();
2050
-	    if (isset($TI)) $TI->checkAll();
2051
-	    if (isset($MI)) $MI->checkAll();
2048
+		if ($globalDebug) echo 'Check all...'."\n";
2049
+		if (isset($SI)) $SI->checkAll();
2050
+		if (isset($TI)) $TI->checkAll();
2051
+		if (isset($MI)) $MI->checkAll();
2052
+	}
2052 2053
 	}
2053
-    }
2054 2054
 }
2055 2055
 
2056 2056
 ?>
Please login to merge, or discard this patch.
Spacing   +217 added lines, -217 removed lines patch added patch discarded remove patch
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
 	    die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
53
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
54 54
     }
55 55
 }
56 56
 
57
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
57
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61 61
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
62
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
63 63
     else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65 65
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
66
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
67 67
     else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106 106
     if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
107
+    $SI = new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
111 111
     $SI->connect();
112 112
 */
113
-} else $SI=new SpotterImport($Connection->db);
113
+} else $SI = new SpotterImport($Connection->db);
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
     $MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127
-$SBS=new SBS();
127
+$SBS = new SBS();
128 128
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
129
-	$ACARS=new ACARS($Connection->db,true);
130
-	$Source=new Source($Connection->db);
129
+	$ACARS = new ACARS($Connection->db, true);
130
+	$Source = new Source($Connection->db);
131 131
 }
132
-$Common=new Common();
132
+$Common = new Common();
133 133
 date_default_timezone_set('UTC');
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
137
+    pcntl_signal(SIGINT, function() {
138 138
         global $sockets;
139 139
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140 140
         die("Bye!\n");
@@ -150,40 +150,40 @@  discard block
 block discarded – undo
150 150
 
151 151
 function connect_all($hosts) {
152 152
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
153
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
154 154
     $reset++;
155 155
     if ($globalDebug) echo 'Connect to all...'."\n";
156 156
     foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
160
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
+            if (preg_match('/deltadb.txt$/i', $host)) {
162 162
         	//$formats[$id] = 'deltadbtxt';
163 163
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 164
         	//$last_exec['deltadbtxt'] = 0;
165 165
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
166
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
167 167
         	//$formats[$id] = 'vatsimtxt';
168 168
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 169
         	//$last_exec['vatsimtxt'] = 0;
170 170
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
171
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
172 172
         	//$formats[$id] = 'aircraftlistjson';
173 173
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 174
         	//$last_exec['aircraftlistjson'] = 0;
175 175
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
176
+    	    } else if (preg_match('/aircraft.json$/i', $host)) {
177 177
         	//$formats[$id] = 'aircraftjson';
178 178
         	$globalSources[$id]['format'] = 'aircraftjson';
179 179
         	//$last_exec['aircraftlistjson'] = 0;
180 180
         	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraft$/i',$host)) {
181
+    	    } else if (preg_match('/aircraft$/i', $host)) {
182 182
         	//$formats[$id] = 'planefinderclient';
183 183
         	$globalSources[$id]['format'] = 'planefinderclient';
184 184
         	//$last_exec['aircraftlistjson'] = 0;
185 185
         	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
186
-    	    } else if (preg_match('/opensky/i',$host)) {
186
+    	    } else if (preg_match('/opensky/i', $host)) {
187 187
         	//$formats[$id] = 'aircraftlistjson';
188 188
         	$globalSources[$id]['format'] = 'opensky';
189 189
         	//$last_exec['aircraftlistjson'] = 0;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
         	    exit(0);
201 201
         	}
202 202
     	    */
203
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
203
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
204 204
         	//$formats[$id] = 'planeupdatefaa';
205 205
         	$globalSources[$id]['format'] = 'planeupdatefaa';
206 206
         	//$last_exec['planeupdatefaa'] = 0;
@@ -209,37 +209,37 @@  discard block
 block discarded – undo
209 209
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210 210
         	    exit(0);
211 211
         	}
212
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
212
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
213 213
         	//$formats[$id] = 'phpvmacars';
214 214
         	$globalSources[$id]['format'] = 'phpvmacars';
215 215
         	//$last_exec['phpvmacars'] = 0;
216 216
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
217
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
217
+            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) {
218 218
         	//$formats[$id] = 'phpvmacars';
219 219
         	$globalSources[$id]['format'] = 'vaos';
220 220
         	//$last_exec['phpvmacars'] = 0;
221 221
         	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
222
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
222
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
223 223
         	//$formats[$id] = 'phpvmacars';
224 224
         	$globalSources[$id]['format'] = 'vam';
225 225
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
226
-            } else if (preg_match('/whazzup/i',$host)) {
226
+            } else if (preg_match('/whazzup/i', $host)) {
227 227
         	//$formats[$id] = 'whazzup';
228 228
         	$globalSources[$id]['format'] = 'whazzup';
229 229
         	//$last_exec['whazzup'] = 0;
230 230
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
231
-            } else if (preg_match('/blitzortung/i',$host)) {
231
+            } else if (preg_match('/blitzortung/i', $host)) {
232 232
         	$globalSources[$id]['format'] = 'blitzortung';
233 233
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
234
-            } else if (preg_match('/airwhere/i',$host)) {
234
+            } else if (preg_match('/airwhere/i', $host)) {
235 235
         	$globalSources[$id]['format'] = 'airwhere';
236 236
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
-            } else if (preg_match('/recentpireps/i',$host)) {
237
+            } else if (preg_match('/recentpireps/i', $host)) {
238 238
         	//$formats[$id] = 'pirepsjson';
239 239
         	$globalSources[$id]['format'] = 'pirepsjson';
240 240
         	//$last_exec['pirepsjson'] = 0;
241 241
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
242
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
242
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
243 243
         	//$formats[$id] = 'fr24json';
244 244
         	$globalSources[$id]['format'] = 'fr24json';
245 245
         	//$last_exec['fr24json'] = 0;
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249 249
         	    exit(0);
250 250
         	}
251
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
251
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
252 252
         	//$formats[$id] = 'fr24json';
253 253
         	$globalSources[$id]['format'] = 'myshiptracking';
254 254
         	//$last_exec['fr24json'] = 0;
@@ -258,22 +258,22 @@  discard block
 block discarded – undo
258 258
         	    exit(0);
259 259
         	}
260 260
             //} else if (preg_match('/10001/',$host)) {
261
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
261
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262 262
         	//$formats[$id] = 'tsv';
263 263
         	$globalSources[$id]['format'] = 'tsv';
264 264
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
265 265
             }
266
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) {
266
+        } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) {
267 267
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
268
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
269 269
     		    if ($idf !== false) {
270 270
     			$httpfeeds[$id] = $idf;
271 271
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272 272
     		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273 273
     		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
274 274
     		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
275
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
276
-	    $hostport = explode(':',$host);
275
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
276
+	    $hostport = explode(':', $host);
277 277
 	    if (isset($hostport[1])) {
278 278
 		$port = $hostport[1];
279 279
 		$hostn = $hostport[0];
@@ -283,19 +283,19 @@  discard block
 block discarded – undo
283 283
 	    }
284 284
 	    $Common = new Common();
285 285
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
286
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
286
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
287 287
     	    } else {
288
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
288
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
289 289
 	    }
290 290
 	    if ($s) {
291 291
     	        $sockets[$id] = $s;
292 292
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
293
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
293
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
294 294
 			//$formats[$id] = 'aprs';
295 295
 			$globalSources[$id]['format'] = 'aprs';
296 296
 			//$aprs_connect = 0;
297 297
 			//$use_aprs = true;
298
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
298
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
299 299
 			$globalSources[$id]['format'] = 'vrstcp';
300 300
     		    } elseif ($port == '10001') {
301 301
         		//$formats[$id] = 'tsv';
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
337 337
 else $timeout = 20;
338 338
 $errno = '';
339
-$errstr='';
339
+$errstr = '';
340 340
 
341 341
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
342 342
 /* Initiate connections to all the hosts simultaneously */
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 //connect_all($globalSources);
345 345
 
346 346
 if (isset($globalProxy) && $globalProxy) {
347
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
347
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
348 348
 } else {
349 349
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
350 350
 }
@@ -374,16 +374,16 @@  discard block
 block discarded – undo
374 374
 
375 375
 if ($use_aprs) {
376 376
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
377
-	$APRS=new APRS();
377
+	$APRS = new APRS();
378 378
 	$aprs_connect = 0;
379 379
 	$aprs_keep = 120;
380 380
 	$aprs_last_tx = time();
381 381
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
382
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
382
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
383 383
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
384
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
384
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
385 385
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
386
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
386
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
387 387
 	if ($aprs_full) $aprs_filter = '';
388 388
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
389 389
 	else $aprs_pass = '-1';
@@ -397,12 +397,12 @@  discard block
 block discarded – undo
397 397
 sleep(1);
398 398
 if ($globalDebug) echo "SCAN MODE \n\n";
399 399
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
400
-$endtime = time()+$globalCronEnd;
400
+$endtime = time() + $globalCronEnd;
401 401
 $i = 1;
402 402
 $tt = array();
403 403
 // Delete all ATC
404 404
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
405
-	$ATC=new ATC($Connection->db);
405
+	$ATC = new ATC($Connection->db);
406 406
 }
407 407
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
408 408
 	$ATC->deleteAll();
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 while ($i > 0) {
413 413
     if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
414 414
 
415
-    if (!$globalDaemon) $i = $endtime-time();
415
+    if (!$globalDaemon) $i = $endtime - time();
416 416
     // Delete old ATC
417 417
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
418 418
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 	}
427 427
 	if ($max < $globalMinFetch) {
428 428
 	    if ($globalDebug) echo 'Sleeping...'."\n";
429
-	    sleep($globalMinFetch-$max+2);
429
+	    sleep($globalMinFetch - $max + 2);
430 430
 	}
431 431
     }
432 432
 
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 	    //$buffer = $Common->getData($hosts[$id]);
446 446
 	    $buffer = $Common->getData($value['host']);
447 447
 	    if ($buffer != '') $reset = 0;
448
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
449
-	    $buffer = explode('\n',$buffer);
448
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
449
+	    $buffer = explode('\n', $buffer);
450 450
 	    foreach ($buffer as $line) {
451 451
     		if ($line != '' && count($line) > 7) {
452 452
     		    $line = explode(',', $line);
@@ -479,11 +479,11 @@  discard block
 block discarded – undo
479 479
 	    )
480 480
 	) {
481 481
 	    date_default_timezone_set('CET');
482
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
482
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
483 483
 	    date_default_timezone_set('UTC');
484 484
 	    if ($buffer != '') $reset = 0;
485
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
486
-	    $buffer = explode('\n',$buffer);
485
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
486
+	    $buffer = explode('\n', $buffer);
487 487
 	    foreach ($buffer as $line) {
488 488
 		if ($line != '') {
489 489
 		    //echo "'".$line."'\n";
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 		    $ais_data = $AIS->parse_line(trim($line));
492 492
 		    $data = array();
493 493
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
494
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
494
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
495 495
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
496 496
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
497 497
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
504 504
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
505 505
 		    if (isset($ais_data['timestamp'])) {
506
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
506
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
507 507
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
508 508
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
509 509
 			    $add = true;
@@ -526,21 +526,21 @@  discard block
 block discarded – undo
526 526
 	    $w = $e = null;
527 527
 	    
528 528
 	    if (isset($arr[$id])) {
529
-		$nn = stream_select($arr,$w,$e,$timeout);
529
+		$nn = stream_select($arr, $w, $e, $timeout);
530 530
 		if ($nn > 0) {
531 531
 		    foreach ($httpfeeds as $feed) {
532
-			$buffer = stream_get_line($feed,2000,"\n");
532
+			$buffer = stream_get_line($feed, 2000, "\n");
533 533
 			if ($buffer === FALSE) {
534 534
 			    connect_all($globalSources);
535 535
 			}
536
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
537
-			$buffer = explode('\n',$buffer);
536
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
537
+			$buffer = explode('\n', $buffer);
538 538
 			foreach ($buffer as $line) {
539 539
 			    if ($line != '') {
540 540
 				$ais_data = $AIS->parse_line(trim($line));
541 541
 				$data = array();
542 542
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
543
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
543
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
544 544
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
545 545
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
546 546
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -552,9 +552,9 @@  discard block
 block discarded – undo
552 552
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
553 553
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
554 554
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
555
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
555
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
556 556
 				if (isset($ais_data['timestamp'])) {
557
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
557
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
558 558
 				} else {
559 559
 				    $data['datetime'] = date('Y-m-d H:i:s');
560 560
 				}
@@ -586,10 +586,10 @@  discard block
 block discarded – undo
586 586
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
587 587
 	    )
588 588
 	) {
589
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
589
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
590 590
 	    if ($buffer != '') {
591 591
 		//echo $buffer;
592
-		$all_data = json_decode($buffer,true);
592
+		$all_data = json_decode($buffer, true);
593 593
 		//print_r($all_data);
594 594
 		if (isset($all_data[0]['DATA'])) {
595 595
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 			    $data['ident'] = $line['NAME'];
599 599
 			    $data['mmsi'] = $line['MMSI'];
600 600
 			    if (strlen($data['mmsi']) > 9) {
601
-				$data['mmsi'] = substr($data['mmsi'],-9);
601
+				$data['mmsi'] = substr($data['mmsi'], -9);
602 602
 			    }
603 603
 			    $data['speed'] = $line['SOG'];
604 604
 			    $data['heading'] = $line['COG'];
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
 			    //$data['type_id'] = $line['TYPE'];
609 609
 			    $data['imo'] = $line['IMO'];
610 610
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
611
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
612
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
611
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
612
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
613 613
 			    $data['format_source'] = 'myshiptracking';
614 614
 			    $data['id_source'] = $id_source;
615 615
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -626,16 +626,16 @@  discard block
 block discarded – undo
626 626
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
627 627
 	    )
628 628
 	) {
629
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
629
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
630 630
 	    if ($buffer != '') {
631
-		$all_data = json_decode($buffer,true);
631
+		$all_data = json_decode($buffer, true);
632 632
 		if (isset($all_data[0]['mmsi'])) {
633 633
 		    foreach ($all_data as $line) {
634 634
 			if ($line != '') {
635 635
 			    $data = array();
636 636
 			    $data['ident'] = $line['shipname'];
637 637
 			    $data['callsign'] = $line['callsign'];
638
-			    $data['mmsi'] = substr($line['mmsi'],-9);
638
+			    $data['mmsi'] = substr($line['mmsi'], -9);
639 639
 			    $data['speed'] = $line['sog'];
640 640
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
641 641
 			    $data['latitude'] = $line['latitude'];
@@ -662,14 +662,14 @@  discard block
 block discarded – undo
662 662
 	) {
663 663
 	    $buffer = $Common->getData($value['host']);
664 664
 	    if ($buffer != '') {
665
-		$all_data = json_decode($buffer,true);
665
+		$all_data = json_decode($buffer, true);
666 666
 		if (isset($all_data['features'][0]['id'])) {
667 667
 		    foreach ($all_data['features'] as $line) {
668 668
 			print_r($line);
669 669
 			$data = array();
670 670
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
671 671
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
672
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
672
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
673 673
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
674 674
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
675 675
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -696,31 +696,31 @@  discard block
 block discarded – undo
696 696
 	    )
697 697
 	) {
698 698
 	    if ($globalDebug) echo 'download...';
699
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
699
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
700 700
 	    if ($globalDebug) echo 'done !'."\n";
701 701
 	    // FIXME: Need more work
702 702
 	    if ($buffer != '') $reset = 0;
703
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
704
-	    $buffer = explode('\n',$buffer);
703
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
704
+	    $buffer = explode('\n', $buffer);
705 705
 	    foreach ($buffer as $line) {
706 706
 		if ($line != '') {
707 707
 		    $data = array();
708 708
 		    //echo $line."\n";
709
-		    $data['mmsi'] = (int)substr($line,0,9);
710
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
711
-		    $data['status_id'] = substr($line,21,2);
712
-		    $data['type_id'] = substr($line,24,3);
713
-		    $data['latitude'] = substr($line,29,9);
714
-		    $data['longitude'] = substr($line,41,9);
715
-		    $data['speed'] = round(substr($line,51,5));
709
+		    $data['mmsi'] = (int) substr($line, 0, 9);
710
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
711
+		    $data['status_id'] = substr($line, 21, 2);
712
+		    $data['type_id'] = substr($line, 24, 3);
713
+		    $data['latitude'] = substr($line, 29, 9);
714
+		    $data['longitude'] = substr($line, 41, 9);
715
+		    $data['speed'] = round(substr($line, 51, 5));
716 716
 		    //$data['course'] = substr($line,57,5);
717
-		    $data['heading'] = round(substr($line,63,3));
717
+		    $data['heading'] = round(substr($line, 63, 3));
718 718
 		    //$data['draft'] = substr($line,67,4);
719 719
 		    //$data['length'] = substr($line,72,3);
720 720
 		    //$data['beam'] = substr($line,76,2);
721
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
721
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
722 722
 		    //$data['callsign'] = trim(substr($line,100,7);
723
-		    $data['arrival_code'] = substr($line,108,20);
723
+		    $data['arrival_code'] = substr($line, 108, 20);
724 724
 		    //$data['etaDate'] = substr($line,129,5);
725 725
 		    //$data['etaTime'] = substr($line,135,5);
726 726
 		    $data['format_source'] = 'shipplotter';
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
 	    )
741 741
 	) {
742 742
 	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
743
-		$authsailaway = $Common->getData('https://sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true);
743
+		$authsailaway = $Common->getData('https://sailaway.world/cgi-bin/sailaway/weblogin.pl', 'post', array('submitlogin' => 'Login', 'email' => $globalSailaway['email'], 'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'), '', '', '', '', '', false, false, true);
744 744
 		//echo $authsailaway;
745 745
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
746 746
 		if (isset($setcookie[1][0])) {
@@ -749,18 +749,18 @@  discard block
 block discarded – undo
749 749
 	    }
750 750
 
751 751
 	    if ($globalDebug) echo '! Download... ';
752
-	    for ($i =0; $i <= 1; $i++) {
752
+	    for ($i = 0; $i <= 1; $i++) {
753 753
 		    if ($globalDebug) echo 'Racetype: '.$i.' ';
754 754
 	    $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
755 755
 	    if ($globalDebug) echo 'done'."\n";
756 756
 	    if ($buffer != '') {
757
-		$all_data = json_decode($buffer,true);
757
+		$all_data = json_decode($buffer, true);
758 758
 		if (isset($all_data['missions'])) {
759 759
 			foreach ($all_data['missions'] as $mission) {
760 760
 				$mission_user = $mission['usrname'];
761
-				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
762
-				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
763
-					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
761
+				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle']));
762
+				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) {
763
+					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'], 'get', '', '', $sailaway_authcookie);
764 764
 					else $racebuffer = '';
765 765
 					$bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
766 766
 				} else {
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
 					$racebuffer = '';
769 769
 				}
770 770
 				if ($racebuffer != '') {
771
-					$race_data = json_decode($racebuffer,true);
771
+					$race_data = json_decode($racebuffer, true);
772 772
 					//print_r($race_data);
773 773
 					unset($racebuffer);
774 774
 					if (isset($race_data['mission'])) {
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
781 781
 					    $markers = array();
782 782
 					    foreach ($race_data['mission']['course'] as $course) {
783
-						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
783
+						$markers[] = array('lat' => $course['miclat'], 'lon' => $course['miclon'], 'name' => $course['micname'], 'type' => $course['mictype']);
784 784
 					    }
785 785
 					    $datar['markers'] = json_encode($markers);
786 786
 					    //print_r($datar);
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 					}
789 789
 				}
790 790
 				if ($bufferm != '') {
791
-					$mission_data = json_decode($bufferm,true);
791
+					$mission_data = json_decode($bufferm, true);
792 792
 					unset($bufferm);
793 793
 					if (isset($mission_data['leaderboard'][0]['results'])) {
794 794
 						foreach ($mission_data['leaderboard'][0]['results'] as $sail) {
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
 								//$data['id'] = $sail['misnr'].'-'.$sail['usrnr'].'-'.$sail['ubtnr'];
802 802
 								$data['id'] = $sail['misnr'].'-'.$sail['usrnr'];
803 803
 								$data['datetime'] = date('Y-m-d H:i:s');
804
-								$data['race_begin'] = date('Y-m-d H:i:s',strtotime($mission_data['leaderboard'][0]['misstart']));
804
+								$data['race_begin'] = date('Y-m-d H:i:s', strtotime($mission_data['leaderboard'][0]['misstart']));
805 805
 								$data['last_update'] = date('Y-m-d H:i:s');
806 806
 								$data['status'] = $sail['status'];
807 807
 								$data['type'] = $sail['btptype'];
@@ -812,16 +812,16 @@  discard block
 block discarded – undo
812 812
 									$data['longitude'] = $pos['longitude'];
813 813
 								}
814 814
 								if ($sail['status'] == 'Racing' && $sail['resultdescr'] != '-') {
815
-									$resultdescr = explode(',',$sail['resultdescr']);
815
+									$resultdescr = explode(',', $sail['resultdescr']);
816 816
 									if (count($resultdescr) > 2) {
817
-										$data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*1.852,2);
818
-										$data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1]));
817
+										$data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*1.852, 2);
818
+										$data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1]));
819 819
 										if (isset($resultdescr[3])) {
820
-											$data['distance'] = round(str_replace('nm.','',trim(explode(' ',$resultdescr[3])[1]))*1.852,3);
820
+											$data['distance'] = round(str_replace('nm.', '', trim(explode(' ', $resultdescr[3])[1]))*1.852, 3);
821 821
 										}
822 822
 									}
823 823
 								}
824
-								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
824
+								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
825 825
 								$data['captain_id'] = $sail['usrnr'];
826 826
 								$data['captain_name'] = $sail['usrname'];
827 827
 								$data['race_id'] = $sail['misnr'];
@@ -868,8 +868,8 @@  discard block
 block discarded – undo
868 868
 	) {
869 869
 	    //$buffer = $Common->getData($hosts[$id]);
870 870
 	    $buffer = $Common->getData($value['host']);
871
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
872
-	    $buffer = explode('\n',$buffer);
871
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
872
+	    $buffer = explode('\n', $buffer);
873 873
 	    $reset = 0;
874 874
 	    foreach ($buffer as $line) {
875 875
     		if ($line != '') {
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
881 881
 			$data['pilot_id'] = $line[1];
882 882
 			$data['pilot_name'] = $line[2];
883
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
883
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
884 884
 			$data['ident'] = $line[0]; // ident
885 885
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
886 886
 			$data['speed'] = $line[8]; // speed
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
897 897
 			//if (isset($line[37])) $data['last_update'] = $line[37];
898 898
 		        $data['departure_airport_icao'] = $line[11];
899
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
899
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
900 900
 		        $data['arrival_airport_icao'] = $line[13];
901 901
 			$data['frequency'] = $line[4];
902 902
 			$data['type'] = $line[18];
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
     			$data['id_source'] = $id_source;
906 906
 	    		//$data['arrival_airport_time'] = ;
907 907
 	    		if ($line[9] != '') {
908
-	    		    $aircraft_data = explode('/',$line[9]);
908
+	    		    $aircraft_data = explode('/', $line[9]);
909 909
 	    		    if (isset($aircraft_data[1])) {
910 910
 	    			$data['aircraft_icao'] = $aircraft_data[1];
911 911
 	    		    }
@@ -920,9 +920,9 @@  discard block
 block discarded – undo
920 920
     			if ($line[3] === 'PILOT') $SI->add($data);
921 921
 			elseif ($line[3] === 'ATC') {
922 922
 				//print_r($data);
923
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
924
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
925
-				$typec = substr($data['ident'],-3);
923
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
924
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
925
+				$typec = substr($data['ident'], -3);
926 926
 				if ($typec === 'APP') $data['type'] = 'Approach';
927 927
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
928 928
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -934,8 +934,8 @@  discard block
 block discarded – undo
934 934
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
935 935
 				if (!isset($data['source_name'])) $data['source_name'] = '';
936 936
 				if (isset($ATC)) {
937
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($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']);
938
-					else 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']);
937
+					if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($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']);
938
+					else 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']);
939 939
 				}
940 940
 			}
941 941
     			unset($data);
@@ -951,24 +951,24 @@  discard block
 block discarded – undo
951 951
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
952 952
     	    )
953 953
     	) {
954
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
954
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
955 955
 	    if ($buffer != '') {
956 956
 		$all_data = simplexml_load_string($buffer);
957
-		foreach($all_data->children() as $childdata) {
957
+		foreach ($all_data->children() as $childdata) {
958 958
 			$data = array();
959 959
 			$line = $childdata;
960 960
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
961
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
962
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
963
-			$data['latitude'] = (float)$line['pktLatitude'];
964
-			$data['longitude'] = (float)$line['pktLongitude'];
965
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
966
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
967
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
961
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
962
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
963
+			$data['latitude'] = (float) $line['pktLatitude'];
964
+			$data['longitude'] = (float) $line['pktLongitude'];
965
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
966
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
967
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
968 968
 			$data['altitude_relative'] = 'AMSL';
969
-			$data['pilot_id'] = (int)$line['pktPilotID'];
969
+			$data['pilot_id'] = (int) $line['pktPilotID'];
970 970
 			$data['aircraft_icao'] = 'PARAGLIDER';
971
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
971
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
972 972
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
973 973
 			$data['format_source'] = $value['format'];
974 974
 			$SI->add($data);
@@ -976,22 +976,22 @@  discard block
 block discarded – undo
976 976
 		}
977 977
 	    }
978 978
 	    $Source->deleteOldLocationByType('gs');
979
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
979
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
980 980
 	    if ($buffer != '') {
981 981
 		$all_data = simplexml_load_string($buffer);
982
-		foreach($all_data->children() as $childdata) {
982
+		foreach ($all_data->children() as $childdata) {
983 983
 			$data = array();
984 984
 			$line = $childdata;
985
-			$data['id'] = (int)$line['gsID'];
986
-			$data['latitude'] = (float)$line['gsLatitude'];
987
-			$data['longitude'] = (float)$line['gsLongitude'];
988
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
985
+			$data['id'] = (int) $line['gsID'];
986
+			$data['latitude'] = (float) $line['gsLatitude'];
987
+			$data['longitude'] = (float) $line['gsLongitude'];
988
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
989 989
 			$data['altitude_relative'] = 'AMSL';
990
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
990
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
991 991
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
992
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
992
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
993 993
 			} else {
994
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
994
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
995 995
 			}
996 996
 			unset($data);
997 997
 		}
@@ -1009,9 +1009,9 @@  discard block
 block discarded – undo
1009 1009
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1010 1010
 	    )
1011 1011
 	) {
1012
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1012
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
1013 1013
 	    if ($buffer != '') {
1014
-	        $all_data = json_decode($buffer,true);
1014
+	        $all_data = json_decode($buffer, true);
1015 1015
 		if (isset($all_data['acList'])) {
1016 1016
 		    $reset = 0;
1017 1017
 		    foreach ($all_data['acList'] as $line) {
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1028 1028
 			$data['emergency'] = ''; // emergency
1029 1029
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1030
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1030
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1031 1031
 			else $data['datetime'] = date('Y-m-d H:i:s');
1032 1032
 			//$data['datetime'] = date('Y-m-d H:i:s');
1033 1033
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1053 1053
 			$data['squawk'] = $line['squawk']; // squawk
1054 1054
 			$data['emergency'] = ''; // emergency
1055
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1055
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1056 1056
 			else $data['datetime'] = date('Y-m-d H:i:s');
1057 1057
 			$data['format_source'] = 'aircraftlistjson';
1058 1058
 			$data['id_source'] = $id_source;
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
     	    )
1074 1074
     	) {
1075 1075
 	    $buffer = $Common->getData($value['host']);
1076
-	    $all_data = json_decode($buffer,true);
1076
+	    $all_data = json_decode($buffer, true);
1077 1077
 	    if (isset($all_data['planes'])) {
1078 1078
 		$reset = 0;
1079 1079
 		foreach ($all_data['planes'] as $key => $line) {
@@ -1090,12 +1090,12 @@  discard block
 block discarded – undo
1090 1090
 		    $data['emergency'] = ''; // emergency
1091 1091
 		    $data['registration'] = $line[2];
1092 1092
 		    $data['aircraft_icao'] = $line[0];
1093
-		    $deparr = explode('-',$line[1]);
1093
+		    $deparr = explode('-', $line[1]);
1094 1094
 		    if (count($deparr) === 2) {
1095 1095
 			$data['departure_airport_icao'] = $deparr[0];
1096 1096
 			$data['arrival_airport_icao'] = $deparr[1];
1097 1097
 		    }
1098
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1098
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
1099 1099
 	    	    $data['format_source'] = 'planeupdatefaa';
1100 1100
     		    $data['id_source'] = $id_source;
1101 1101
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 	    )
1114 1114
 	) {
1115 1115
 	    $buffer = $Common->getData($value['host']);
1116
-	    $all_data = json_decode($buffer,true);
1116
+	    $all_data = json_decode($buffer, true);
1117 1117
 	    if (isset($all_data['states'])) {
1118 1118
 		$reset = 0;
1119 1119
 		foreach ($all_data['states'] as $key => $line) {
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 		    //$data['emergency'] = ''; // emergency
1131 1131
 		    //$data['registration'] = $line[2];
1132 1132
 		    //$data['aircraft_icao'] = $line[0];
1133
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1133
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1134 1134
 		    $data['format_source'] = 'opensky';
1135 1135
 		    $data['id_source'] = $id_source;
1136 1136
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1147,8 +1147,8 @@  discard block
 block discarded – undo
1147 1147
 	    )
1148 1148
 	) {
1149 1149
 	    $buffer = $Common->getData($value['host']);
1150
-	    $all_data = json_decode($buffer,true);
1151
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1150
+	    $all_data = json_decode($buffer, true);
1151
+	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) {
1152 1152
 		$reset = 0;
1153 1153
 		foreach ($all_data['aircraft'] as $key => $line) {
1154 1154
 		    $data = array();
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 	    )
1187 1187
 	) {
1188 1188
 	    $buffer = $Common->getData($value['host']);
1189
-	    $all_data = json_decode($buffer,true);
1189
+	    $all_data = json_decode($buffer, true);
1190 1190
 	    if (isset($all_data['aircraft'])) {
1191 1191
 		$reset = 0;
1192 1192
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1203,7 +1203,7 @@  discard block
 block discarded – undo
1203 1203
 		    //$data['emergency'] = ''; // emergency
1204 1204
 		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1205 1205
 		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1206
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1206
+		    $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']);
1207 1207
 		    $data['format_source'] = 'planefinderclient';
1208 1208
 		    $data['id_source'] = $id_source;
1209 1209
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 	) {
1223 1223
 	    //$buffer = $Common->getData($hosts[$id]);
1224 1224
 	    $buffer = $Common->getData($value['host']);
1225
-	    $all_data = json_decode($buffer,true);
1225
+	    $all_data = json_decode($buffer, true);
1226 1226
 	    if (!empty($all_data)) $reset = 0;
1227 1227
 	    foreach ($all_data as $key => $line) {
1228 1228
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1260,11 +1260,11 @@  discard block
 block discarded – undo
1260 1260
 	    )
1261 1261
 	) {
1262 1262
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1263
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1263
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1264 1264
 	    //echo $buffer;
1265
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1266
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1267
-	    $all_data = json_decode($buffer,true);
1265
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1266
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1267
+	    $all_data = json_decode($buffer, true);
1268 1268
 	    if (json_last_error() != JSON_ERROR_NONE) {
1269 1269
 		die(json_last_error_msg());
1270 1270
 	    }
@@ -1287,7 +1287,7 @@  discard block
 block discarded – undo
1287 1287
 			//$data['departure_airport_iata'] = $line[11];
1288 1288
 			//$data['arrival_airport_iata'] = $line[12];
1289 1289
 	    		//$data['emergency'] = ''; // emergency
1290
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1290
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1291 1291
 	    		$data['format_source'] = 'radarvirtueljson';
1292 1292
     			$data['id_source'] = $id_source;
1293 1293
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1308,14 +1308,14 @@  discard block
 block discarded – undo
1308 1308
 	) {
1309 1309
 	    //$buffer = $Common->getData($hosts[$id]);
1310 1310
 	    $buffer = $Common->getData($value['host'].'?'.time());
1311
-	    $all_data = json_decode(utf8_encode($buffer),true);
1311
+	    $all_data = json_decode(utf8_encode($buffer), true);
1312 1312
 	    
1313 1313
 	    if (isset($all_data['pireps'])) {
1314 1314
 		$reset = 0;
1315 1315
 	        foreach ($all_data['pireps'] as $line) {
1316 1316
 		    $data = array();
1317 1317
 		    $data['id'] = $line['id'];
1318
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1318
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1319 1319
 		    $data['ident'] = $line['callsign']; // ident
1320 1320
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1321 1321
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1345,9 +1345,9 @@  discard block
 block discarded – undo
1345 1345
 			$SI->add($data);
1346 1346
 		    //    print_r($data);
1347 1347
     		    } elseif ($line['icon'] === 'ct') {
1348
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1349
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1350
-			$typec = substr($data['ident'],-3);
1348
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1349
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1350
+			$typec = substr($data['ident'], -3);
1351 1351
 			$data['type'] = '';
1352 1352
 			if ($typec === 'APP') $data['type'] = 'Approach';
1353 1353
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1358,7 +1358,7 @@  discard block
 block discarded – undo
1358 1358
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1359 1359
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1360 1360
 			else $data['type'] = 'Observer';
1361
-			if (isset($ATC)) 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']);
1361
+			if (isset($ATC)) 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']);
1362 1362
 		    }
1363 1363
 		    unset($data);
1364 1364
 		}
@@ -1375,14 +1375,14 @@  discard block
 block discarded – undo
1375 1375
 	    //$buffer = $Common->getData($hosts[$id]);
1376 1376
 	    if ($globalDebug) echo 'Get Data...'."\n";
1377 1377
 	    $buffer = $Common->getData($value['host']);
1378
-	    $all_data = json_decode($buffer,true);
1378
+	    $all_data = json_decode($buffer, true);
1379 1379
 	    if ($buffer != '' && is_array($all_data)) {
1380 1380
 		$reset = 0;
1381 1381
 		foreach ($all_data as $line) {
1382 1382
 	    	    $data = array();
1383 1383
 	    	    //$data['id'] = $line['id']; // id not usable
1384 1384
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1385
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1385
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1386 1386
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1387 1387
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1388 1388
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1397,7 +1397,7 @@  discard block
 block discarded – undo
1397 1397
 	    	    //$data['datetime'] = $line['lastupdate'];
1398 1398
 	    	    //$data['last_update'] = $line['lastupdate'];
1399 1399
 	    	    if (isset($value['timezone'])) {
1400
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1400
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1401 1401
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1402 1402
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1403 1403
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1413,14 +1413,14 @@  discard block
 block discarded – undo
1413 1413
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1414 1414
 		    if (isset($line['aircraftname'])) {
1415 1415
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1416
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1417
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1416
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1417
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1418 1418
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1419 1419
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1420 1420
 	    		else {
1421
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1422
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1423
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1421
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1422
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1423
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1424 1424
 	    		}
1425 1425
 	    	    }
1426 1426
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1445,7 +1445,7 @@  discard block
 block discarded – undo
1445 1445
 	    //$buffer = $Common->getData($hosts[$id]);
1446 1446
 	    if ($globalDebug) echo 'Get Data...'."\n";
1447 1447
 	    $buffer = $Common->getData($value['host']);
1448
-	    $all_data = json_decode($buffer,true);
1448
+	    $all_data = json_decode($buffer, true);
1449 1449
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1450 1450
 		$reset = 0;
1451 1451
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1456,7 +1456,7 @@  discard block
 block discarded – undo
1456 1456
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1457 1457
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1458 1458
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1459
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1459
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1460 1460
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1461 1461
 	    	    $data['altitude'] = $line['altitude']; // altitude
1462 1462
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1467,7 +1467,7 @@  discard block
 block discarded – undo
1467 1467
 	    	    //$data['squawk'] = ''; // squawk
1468 1468
 	    	    //$data['emergency'] = ''; // emergency
1469 1469
 	    	    if (isset($value['timezone'])) {
1470
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1470
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1471 1471
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1472 1472
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1473 1473
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1503,14 +1503,14 @@  discard block
 block discarded – undo
1503 1503
 	    //$buffer = $Common->getData($hosts[$id]);
1504 1504
 	    if ($globalDebug) echo 'Get Data...'."\n";
1505 1505
 	    $buffer = $Common->getData($value['host']);
1506
-	    $all_data = json_decode($buffer,true);
1506
+	    $all_data = json_decode($buffer, true);
1507 1507
 	    if ($buffer != '' && is_array($all_data)) {
1508 1508
 		$reset = 0;
1509 1509
 		foreach ($all_data as $line) {
1510 1510
 	    	    $data = array();
1511 1511
 	    	    //$data['id'] = $line['id']; // id not usable
1512 1512
 	    	    $data['id'] = trim($line['flight_id']);
1513
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1513
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1514 1514
 	    	    $data['pilot_name'] = $line['pilot_name'];
1515 1515
 	    	    $data['pilot_id'] = $line['pilot_id'];
1516 1516
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1554,24 +1554,24 @@  discard block
 block discarded – undo
1554 1554
 	    //$buffer = $Common->getData($hosts[$id]);
1555 1555
 	    if ($globalDebug) echo 'Get Data...'."\n";
1556 1556
 	    $buffer = $Common->getData($value['host']);
1557
-	    $all_data = json_decode($buffer,true);
1557
+	    $all_data = json_decode($buffer, true);
1558 1558
 	    if ($buffer != '') {
1559 1559
 		$Source->deleteLocationBySource('blitzortung');
1560
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1561
-		$buffer = explode('\n',$buffer);
1560
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1561
+		$buffer = explode('\n', $buffer);
1562 1562
 		foreach ($buffer as $buffer_line) {
1563
-		    $line = json_decode($buffer_line,true);
1563
+		    $line = json_decode($buffer_line, true);
1564 1564
 		    if (isset($line['time'])) {
1565 1565
 			$data = array();
1566 1566
 			$data['altitude'] = $line['alt']; // altitude
1567 1567
 			$data['latitude'] = $line['lat']; // lat
1568 1568
 			$data['longitude'] = $line['lon']; // long
1569
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1569
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1570 1570
 			$data['id_source'] = $id_source;
1571 1571
 			$data['format_source'] = 'blitzortung';
1572 1572
 			$SI->add($data);
1573 1573
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1574
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1574
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1575 1575
 			unset($data);
1576 1576
 		    }
1577 1577
 		}
@@ -1594,11 +1594,11 @@  discard block
 block discarded – undo
1594 1594
 		    //$value = $formats[$nb];
1595 1595
 		    $format = $globalSources[$nb]['format'];
1596 1596
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1597
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1597
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1598 1598
 		    } elseif ($format === 'vrstcp') {
1599 1599
 			$buffer = @socket_read($r, 6000);
1600 1600
 		    } else {
1601
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1601
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1602 1602
 		    }
1603 1603
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1604 1604
 		    //echo $buffer."\n";
@@ -1608,8 +1608,8 @@  discard block
 block discarded – undo
1608 1608
 		    //$SI::del();
1609 1609
 		    if ($buffer !== FALSE) {
1610 1610
 			if ($format === 'vrstcp') {
1611
-			    $buffer = explode('},{',$buffer);
1612
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1611
+			    $buffer = explode('},{', $buffer);
1612
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1613 1613
 		    }
1614 1614
 		    // SBS format is CSV format
1615 1615
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1633,7 +1633,7 @@  discard block
 block discarded – undo
1633 1633
 			    $ais_data = $AIS->parse_line(trim($buffer));
1634 1634
 			    $data = array();
1635 1635
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1636
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1636
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1637 1637
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1638 1638
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1639 1639
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1644,13 +1644,13 @@  discard block
 block discarded – undo
1644 1644
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1645 1645
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1646 1646
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1647
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1647
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1648 1648
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1649 1649
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1650 1650
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1651 1651
 
1652 1652
 			    if (isset($ais_data['timestamp'])) {
1653
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1653
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1654 1654
 			    } else {
1655 1655
 				$data['datetime'] = date('Y-m-d H:i:s');
1656 1656
 			    }
@@ -1661,10 +1661,10 @@  discard block
 block discarded – undo
1661 1661
                         } elseif ($format === 'flightgearsp') {
1662 1662
                     	    //echo $buffer."\n";
1663 1663
                     	    if (strlen($buffer) > 5) {
1664
-				$line = explode(',',$buffer);
1664
+				$line = explode(',', $buffer);
1665 1665
 				$data = array();
1666 1666
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1667
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1667
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1668 1668
 				$data['ident'] = $line[6];
1669 1669
 				$data['aircraft_name'] = $line[7];
1670 1670
 				$data['longitude'] = $line[1];
@@ -1681,16 +1681,16 @@  discard block
 block discarded – undo
1681 1681
                         } elseif ($format === 'acars') {
1682 1682
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1683 1683
 			    $ACARS->add(trim($buffer));
1684
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1684
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1685 1685
 			    $ACARS->deleteLiveAcarsData();
1686 1686
 			} elseif ($format === 'flightgearmp') {
1687
-			    if (substr($buffer,0,1) != '#') {
1687
+			    if (substr($buffer, 0, 1) != '#') {
1688 1688
 				$data = array();
1689 1689
 				//echo $buffer."\n";
1690
-				$line = explode(' ',$buffer);
1690
+				$line = explode(' ', $buffer);
1691 1691
 				if (count($line) === 11) {
1692
-				    $userserver = explode('@',$line[0]);
1693
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1692
+				    $userserver = explode('@', $line[0]);
1693
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1694 1694
 				    $data['ident'] = $userserver[0];
1695 1695
 				    $data['registration'] = $userserver[0];
1696 1696
 				    $data['latitude'] = $line[4];
@@ -1698,8 +1698,8 @@  discard block
 block discarded – undo
1698 1698
 				    $data['altitude'] = $line[6];
1699 1699
 				    $data['datetime'] = date('Y-m-d H:i:s');
1700 1700
 				    $aircraft_type = $line[10];
1701
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1702
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1701
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1702
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1703 1703
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1704 1704
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1705 1705
 				}
@@ -1708,8 +1708,8 @@  discard block
 block discarded – undo
1708 1708
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1709 1709
 			    die;
1710 1710
 			} elseif ($format === 'vrstcp') {
1711
-			    foreach($buffer as $all_data) {
1712
-				$line = json_decode('{'.$all_data.'}',true);
1711
+			    foreach ($buffer as $all_data) {
1712
+				$line = json_decode('{'.$all_data.'}', true);
1713 1713
 				$data = array();
1714 1714
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1715 1715
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1735,16 +1735,16 @@  discard block
 block discarded – undo
1735 1735
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1736 1736
 				unset($data);
1737 1737
 			    }
1738
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1738
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1739 1739
 			    $line = explode("\t", $buffer);
1740
-			    for($k = 0; $k < count($line); $k=$k+2) {
1740
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1741 1741
 				$key = $line[$k];
1742
-			        $lined[$key] = $line[$k+1];
1742
+			        $lined[$key] = $line[$k + 1];
1743 1743
 			    }
1744 1744
     			    if (count($lined) > 3) {
1745 1745
     				$data['hex'] = $lined['hexid'];
1746 1746
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1747
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1747
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1748 1748
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1749 1749
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1750 1750
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1763,23 +1763,23 @@  discard block
 block discarded – undo
1763 1763
     			    } else $error = true;
1764 1764
 			} elseif ($format === 'aprs' && $use_aprs) {
1765 1765
 			    if ($aprs_connect === 0) {
1766
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1766
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1767 1767
 				$aprs_connect = 1;
1768 1768
 			    }
1769 1769
 			    
1770
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1770
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1771 1771
 				$aprs_last_tx = time();
1772 1772
 				$data_aprs = "# Keep alive";
1773
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1773
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1774 1774
 			    }
1775 1775
 			    
1776 1776
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1777 1777
 			    //echo 'APRS data : '.$buffer."\n";
1778
-			    $buffer = str_replace('APRS <- ','',$buffer);
1779
-			    $buffer = str_replace('APRS -> ','',$buffer);
1778
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1779
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1780 1780
 			    //echo $buffer."\n";
1781 1781
 			    date_default_timezone_set('UTC');
1782
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1782
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1783 1783
 				$line = $APRS->parse($buffer);
1784 1784
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1785 1785
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1794,7 +1794,7 @@  discard block
 block discarded – undo
1794 1794
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1795 1795
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1796 1796
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1797
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1797
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1798 1798
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1799 1799
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1800 1800
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1882,29 +1882,29 @@  discard block
 block discarded – undo
1882 1882
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1883 1883
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1884 1884
 					$Source->deleteOldLocationByType('gs');
1885
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1886
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1885
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1886
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1887 1887
 					} else {
1888
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1888
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1889 1889
 					}
1890 1890
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1891 1891
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1892 1892
 					if ($globalDebug) echo '# Weather Station added'."\n";
1893 1893
 					$Source->deleteOldLocationByType('wx');
1894 1894
 					$weather_data = json_encode($line);
1895
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1896
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1895
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1896
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1897 1897
 					} else {
1898
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1898
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1899 1899
 					}
1900 1900
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1901 1901
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1902 1902
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1903 1903
 					$Source->deleteOldLocationByType('lightning');
1904
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1905
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1904
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1905
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1906 1906
 					} else {
1907
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1907
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1908 1908
 					}
1909 1909
 				    } elseif ($globalDebug) {
1910 1910
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1913,7 +1913,7 @@  discard block
 block discarded – undo
1913 1913
 				    unset($data);
1914 1914
 				}
1915 1915
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1916
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1916
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1917 1917
 				}
1918 1918
 				/*
1919 1919
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] === 'Car' || $line['symbol'] === 'Ambulance' || $line['symbol'] === 'Van' || $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || $line['symbol'] === 'Motorcycle')) {
@@ -1922,7 +1922,7 @@  discard block
 block discarded – undo
1922 1922
 				*/
1923 1923
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1924 1924
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1925
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1925
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1926 1926
 					$Source->deleteOldLocationByType('lightning');
1927 1927
 					$Source->deleteOldLocationByType('wx');
1928 1928
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -2008,7 +2008,7 @@  discard block
 block discarded – undo
2008 2008
 				connect_all($sourceee);
2009 2009
 				$sourceee = array();
2010 2010
 				//connect_all($globalSources);
2011
-				$tt[$format]=0;
2011
+				$tt[$format] = 0;
2012 2012
 				break;
2013 2013
 			    } 
2014 2014
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -2018,14 +2018,14 @@  discard block
 block discarded – undo
2018 2018
 	    } else {
2019 2019
 		$error = socket_strerror(socket_last_error());
2020 2020
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2021
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2021
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
2022 2022
 			if (isset($globalDebug)) echo "Restarting...\n";
2023 2023
 			// Restart the script if possible
2024 2024
 			if (is_array($sockets)) {
2025 2025
 			    if ($globalDebug) echo "Shutdown all sockets...";
2026 2026
 			    
2027 2027
 			    foreach ($sockets as $sock) {
2028
-				@socket_shutdown($sock,2);
2028
+				@socket_shutdown($sock, 2);
2029 2029
 				@socket_close($sock);
2030 2030
 			    }
2031 2031
 			    
Please login to merge, or discard this patch.
Braces   +1215 added lines, -408 removed lines patch added patch discarded remove patch
@@ -14,13 +14,17 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Source.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17
+if (isset($globalTracker) && $globalTracker) {
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19
+}
18 20
 if (isset($globalMarine) && $globalMarine) {
19 21
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
20 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 23
 }
22 24
 
23
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
24 28
 
25 29
 // Check if schema is at latest version
26 30
 $Connection = new Connection();
@@ -59,66 +63,107 @@  discard block
 block discarded – undo
59 63
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 64
 if (isset($options['s'])) {
61 65
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
64
-} elseif (isset($options['source'])) {
66
+    if (isset($options['format'])) {
67
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
68
+    } else {
69
+    	$globalSources[] = array('host' => $options['s']);
70
+    }
71
+    } elseif (isset($options['source'])) {
65 72
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
68
-}
73
+    if (isset($options['format'])) {
74
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    } else {
76
+    	$globalSources[] = array('host' => $options['source']);
77
+    }
78
+    }
69 79
 if (isset($options['aprsserverhost'])) {
70 80
 	$globalServerAPRS = TRUE;
71 81
 	$globalServerAPRShost = $options['aprsserverhost'];
72 82
 }
73
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
74
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
75
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
76
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
83
+if (isset($options['aprsserverport'])) {
84
+	$globalServerAPRSport = $options['aprsserverport'];
85
+}
86
+if (isset($options['aprsserverssid'])) {
87
+	$globalServerAPRSssid = $options['aprsserverssid'];
88
+}
89
+if (isset($options['aprsserverpass'])) {
90
+	$globalServerAPRSpass = $options['aprsserverpass'];
91
+}
92
+if (isset($options['noaprsserver'])) {
93
+	$globalServerAPRS = FALSE;
94
+}
77 95
 if (isset($options['enable-aircraft'])) {
78
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
96
+	if ($globalDebug) {
97
+		echo 'Enable Aircraft mode'."\n";
98
+	}
79 99
 	$globalAircraft = TRUE; 
80 100
 }
81 101
 if (isset($options['disable-aircraft'])) {
82
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
102
+	if ($globalDebug) {
103
+		echo 'Disable Aircraft mode'."\n";
104
+	}
83 105
 	$globalAircraft = FALSE;
84 106
 }
85 107
 if (isset($options['enable-tracker'])) {
86
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
108
+	if ($globalDebug) {
109
+		echo 'Enable Tracker mode'."\n";
110
+	}
87 111
 	$globalTracker = TRUE; 
88 112
 }
89 113
 if (isset($options['disable-tracker'])) {
90
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
114
+	if ($globalDebug) {
115
+		echo 'Disable Tracker mode'."\n";
116
+	}
91 117
 	$globalTracker = FALSE;
92 118
 }
93 119
 if (isset($options['enable-marine'])) {
94
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
120
+	if ($globalDebug) {
121
+		echo 'Enable Marine mode'."\n";
122
+	}
95 123
 	$globalMarine = TRUE;
96 124
 }
97 125
 if (isset($options['disable-marine'])) {
98
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
126
+	if ($globalDebug) {
127
+		echo 'Disable Marine mode'."\n";
128
+	}
99 129
 	$globalMarine = FALSE;
100 130
 }
101
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
102
-if (isset($options['server'])) $globalServer = TRUE;
103
-if (isset($options['idsource'])) $id_source = $options['idsource'];
104
-else $id_source = 1;
131
+if (isset($options['nodaemon'])) {
132
+	$globalDaemon = FALSE;
133
+}
134
+if (isset($options['server'])) {
135
+	$globalServer = TRUE;
136
+}
137
+if (isset($options['idsource'])) {
138
+	$id_source = $options['idsource'];
139
+} else {
140
+	$id_source = 1;
141
+}
105 142
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
143
+    if ($globalDebug) {
144
+    	echo "Using Server Mode\n";
145
+    }
107 146
     $SI=new SpotterServer();
108 147
 /*
109 148
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 149
     $SI = new adsb2aprs();
111 150
     $SI->connect();
112 151
 */
113
-} else $SI=new SpotterImport($Connection->db);
152
+} else {
153
+	$SI=new SpotterImport($Connection->db);
154
+}
114 155
 
115
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
156
+if (isset($globalTracker) && $globalTracker) {
157
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
158
+}
116 159
 if (isset($globalMarine) && $globalMarine) {
117 160
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
118 161
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 162
 }
120 163
 
121
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
164
+if (isset($globalTracker) && $globalTracker) {
165
+	$TI = new TrackerImport($Connection->db);
166
+}
122 167
 if (isset($globalMarine) && $globalMarine) {
123 168
     $AIS = new AIS();
124 169
     $MI = new MarineImport($Connection->db);
@@ -143,7 +188,9 @@  discard block
 block discarded – undo
143 188
 }
144 189
 
145 190
 // let's try and connect
146
-if ($globalDebug) echo "Connecting...\n";
191
+if ($globalDebug) {
192
+	echo "Connecting...\n";
193
+}
147 194
 $use_aprs = false;
148 195
 $aprs_full = false;
149 196
 $reset = 0;
@@ -152,7 +199,9 @@  discard block
 block discarded – undo
152 199
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153 200
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154 201
     $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
202
+    if ($globalDebug) {
203
+    	echo 'Connect to all...'."\n";
204
+    }
156 205
     foreach ($hosts as $id => $value) {
157 206
 	$host = $value['host'];
158 207
 	$globalSources[$id]['last_exec'] = 0;
@@ -162,32 +211,44 @@  discard block
 block discarded – undo
162 211
         	//$formats[$id] = 'deltadbtxt';
163 212
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 213
         	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
214
+        	if ($globalDebug) {
215
+        		echo "Connect to deltadb source (".$host.")...\n";
216
+        	}
166 217
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167 218
         	//$formats[$id] = 'vatsimtxt';
168 219
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 220
         	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
221
+        	if ($globalDebug) {
222
+        		echo "Connect to vatsim source (".$host.")...\n";
223
+        	}
171 224
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172 225
         	//$formats[$id] = 'aircraftlistjson';
173 226
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 227
         	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
228
+        	if ($globalDebug) {
229
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
230
+        	}
176 231
     	    } else if (preg_match('/aircraft.json$/i',$host)) {
177 232
         	//$formats[$id] = 'aircraftjson';
178 233
         	$globalSources[$id]['format'] = 'aircraftjson';
179 234
         	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
235
+        	if ($globalDebug) {
236
+        		echo "Connect to aircraft.json source (".$host.")...\n";
237
+        	}
181 238
     	    } else if (preg_match('/aircraft$/i',$host)) {
182 239
         	//$formats[$id] = 'planefinderclient';
183 240
         	$globalSources[$id]['format'] = 'planefinderclient';
184 241
         	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
242
+        	if ($globalDebug) {
243
+        		echo "Connect to planefinderclient source (".$host.")...\n";
244
+        	}
186 245
     	    } else if (preg_match('/opensky/i',$host)) {
187 246
         	//$formats[$id] = 'aircraftlistjson';
188 247
         	$globalSources[$id]['format'] = 'opensky';
189 248
         	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
249
+        	if ($globalDebug) {
250
+        		echo "Connect to opensky source (".$host.")...\n";
251
+        	}
191 252
     	    /*
192 253
     	    // Disabled for now, site change source format
193 254
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -204,7 +265,9 @@  discard block
 block discarded – undo
204 265
         	//$formats[$id] = 'planeupdatefaa';
205 266
         	$globalSources[$id]['format'] = 'planeupdatefaa';
206 267
         	//$last_exec['planeupdatefaa'] = 0;
207
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
268
+        	if ($globalDebug) {
269
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
270
+        	}
208 271
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209 272
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210 273
         	    exit(0);
@@ -213,37 +276,53 @@  discard block
 block discarded – undo
213 276
         	//$formats[$id] = 'phpvmacars';
214 277
         	$globalSources[$id]['format'] = 'phpvmacars';
215 278
         	//$last_exec['phpvmacars'] = 0;
216
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
279
+        	if ($globalDebug) {
280
+        		echo "Connect to phpvmacars source (".$host.")...\n";
281
+        	}
217 282
             } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218 283
         	//$formats[$id] = 'phpvmacars';
219 284
         	$globalSources[$id]['format'] = 'vaos';
220 285
         	//$last_exec['phpvmacars'] = 0;
221
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
286
+        	if ($globalDebug) {
287
+        		echo "Connect to vaos source (".$host.")...\n";
288
+        	}
222 289
             } else if (preg_match('/VAM-json.php$/i',$host)) {
223 290
         	//$formats[$id] = 'phpvmacars';
224 291
         	$globalSources[$id]['format'] = 'vam';
225
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
292
+        	if ($globalDebug) {
293
+        		echo "Connect to Vam source (".$host.")...\n";
294
+        	}
226 295
             } else if (preg_match('/whazzup/i',$host)) {
227 296
         	//$formats[$id] = 'whazzup';
228 297
         	$globalSources[$id]['format'] = 'whazzup';
229 298
         	//$last_exec['whazzup'] = 0;
230
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
299
+        	if ($globalDebug) {
300
+        		echo "Connect to whazzup source (".$host.")...\n";
301
+        	}
231 302
             } else if (preg_match('/blitzortung/i',$host)) {
232 303
         	$globalSources[$id]['format'] = 'blitzortung';
233
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
304
+        	if ($globalDebug) {
305
+        		echo "Connect to blitzortung source (".$host.")...\n";
306
+        	}
234 307
             } else if (preg_match('/airwhere/i',$host)) {
235 308
         	$globalSources[$id]['format'] = 'airwhere';
236
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
309
+        	if ($globalDebug) {
310
+        		echo "Connect to airwhere source (".$host.")...\n";
311
+        	}
237 312
             } else if (preg_match('/recentpireps/i',$host)) {
238 313
         	//$formats[$id] = 'pirepsjson';
239 314
         	$globalSources[$id]['format'] = 'pirepsjson';
240 315
         	//$last_exec['pirepsjson'] = 0;
241
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
316
+        	if ($globalDebug) {
317
+        		echo "Connect to pirepsjson source (".$host.")...\n";
318
+        	}
242 319
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243 320
         	//$formats[$id] = 'fr24json';
244 321
         	$globalSources[$id]['format'] = 'fr24json';
245 322
         	//$last_exec['fr24json'] = 0;
246
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
323
+        	if ($globalDebug) {
324
+        		echo "Connect to fr24 source (".$host.")...\n";
325
+        	}
247 326
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248 327
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249 328
         	    exit(0);
@@ -252,7 +331,9 @@  discard block
 block discarded – undo
252 331
         	//$formats[$id] = 'fr24json';
253 332
         	$globalSources[$id]['format'] = 'myshiptracking';
254 333
         	//$last_exec['fr24json'] = 0;
255
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
334
+        	if ($globalDebug) {
335
+        		echo "Connect to myshiptracking source (".$host.")...\n";
336
+        	}
256 337
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257 338
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258 339
         	    exit(0);
@@ -261,17 +342,26 @@  discard block
 block discarded – undo
261 342
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262 343
         	//$formats[$id] = 'tsv';
263 344
         	$globalSources[$id]['format'] = 'tsv';
264
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
345
+        	if ($globalDebug) {
346
+        		echo "Connect to tsv source (".$host.")...\n";
347
+        	}
265 348
             }
266 349
         } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) {
267 350
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268 351
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
269 352
     		    if ($idf !== false) {
270 353
     			$httpfeeds[$id] = $idf;
271
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
274
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
354
+        		if ($globalDebug) {
355
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
356
+        		}
357
+    		    } elseif ($globalDebug) {
358
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
359
+    		    }
360
+    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') {
361
+    			echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
362
+    		} elseif ($globalDebug) {
363
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
364
+    		}
275 365
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
276 366
 	    $hostport = explode(':',$host);
277 367
 	    if (isset($hostport[1])) {
@@ -311,19 +401,27 @@  discard block
 block discarded – undo
311 401
         		//$formats[$id] = 'beast';
312 402
         		$globalSources[$id]['format'] = 'beast';
313 403
 		    //} else $formats[$id] = 'sbs';
314
-		    } else $globalSources[$id]['format'] = 'sbs';
404
+		    } else {
405
+		    	$globalSources[$id]['format'] = 'sbs';
406
+		    }
315 407
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
316 408
 		}
317
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
409
+		if ($globalDebug) {
410
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
411
+		}
318 412
             } else {
319
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
413
+		if ($globalDebug) {
414
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
415
+		}
320 416
 		sleep(10);
321 417
 		connect_all($hosts);
322 418
     	    }
323 419
         }
324 420
     }
325 421
 }
326
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
422
+if (!isset($globalMinFetch)) {
423
+	$globalMinFetch = 15;
424
+}
327 425
 
328 426
 // Initialize all
329 427
 $status = array();
@@ -332,13 +430,19 @@  discard block
 block discarded – undo
332 430
 $formats = array();
333 431
 $last_exec = array();
334 432
 $time = time();
335
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
336
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
337
-else $timeout = 20;
433
+if (isset($globalSourcesTimeout)) {
434
+	$timeout = $globalSourcesTimeOut;
435
+} else if (isset($globalSBS1TimeOut)) {
436
+	$timeout = $globalSBS1TimeOut;
437
+} else {
438
+	$timeout = 20;
439
+}
338 440
 $errno = '';
339 441
 $errstr='';
340 442
 
341
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
443
+if (!isset($globalDaemon)) {
444
+	$globalDaemon = TRUE;
445
+}
342 446
 /* Initiate connections to all the hosts simultaneously */
343 447
 //connect_all($hosts);
344 448
 //connect_all($globalSources);
@@ -367,7 +471,9 @@  discard block
 block discarded – undo
367 471
     if (isset($source['format']) && $source['format'] == 'aprs') {
368 472
 	$aprs_connect = 0;
369 473
 	$use_aprs = true;
370
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
474
+	if (isset($source['port']) && $source['port'] == '10152') {
475
+		$aprs_full = true;
476
+	}
371 477
 	break;
372 478
     }
373 479
 }
@@ -378,25 +484,46 @@  discard block
 block discarded – undo
378 484
 	$aprs_connect = 0;
379 485
 	$aprs_keep = 120;
380 486
 	$aprs_last_tx = time();
381
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
382
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
383
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
384
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
385
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
386
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
387
-	if ($aprs_full) $aprs_filter = '';
388
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
389
-	else $aprs_pass = '-1';
487
+	if (isset($globalAPRSversion)) {
488
+		$aprs_version = $globalAPRSversion;
489
+	} else {
490
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
491
+	}
492
+	if (isset($globalAPRSssid)) {
493
+		$aprs_ssid = $globalAPRSssid;
494
+	} else {
495
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
496
+	}
497
+	if (isset($globalAPRSfilter)) {
498
+		$aprs_filter = $globalAPRSfilter;
499
+	} else {
500
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
501
+	}
502
+	if ($aprs_full) {
503
+		$aprs_filter = '';
504
+	}
505
+	if (isset($globalAPRSpass)) {
506
+		$aprs_pass = $globalAPRSpass;
507
+	} else {
508
+		$aprs_pass = '-1';
509
+	}
390 510
 
391
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
392
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
393
-}
511
+	if ($aprs_filter != '') {
512
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
513
+	} else {
514
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
515
+	}
516
+	}
394 517
 
395 518
 // connected - lets do some work
396 519
 //if ($globalDebug) echo "Connected!\n";
397 520
 sleep(1);
398
-if ($globalDebug) echo "SCAN MODE \n\n";
399
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
521
+if ($globalDebug) {
522
+	echo "SCAN MODE \n\n";
523
+}
524
+if (!isset($globalCronEnd)) {
525
+	$globalCronEnd = 60;
526
+}
400 527
 $endtime = time()+$globalCronEnd;
401 528
 $i = 1;
402 529
 $tt = array();
@@ -410,22 +537,32 @@  discard block
 block discarded – undo
410 537
 
411 538
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
412 539
 while ($i > 0) {
413
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
540
+    if (function_exists('pcntl_fork')) {
541
+    	pcntl_signal_dispatch();
542
+    }
414 543
 
415
-    if (!$globalDaemon) $i = $endtime-time();
544
+    if (!$globalDaemon) {
545
+    	$i = $endtime-time();
546
+    }
416 547
     // Delete old ATC
417 548
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
418
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
549
+	if ($globalDebug) {
550
+		echo 'Delete old ATC...'."\n";
551
+	}
419 552
         $ATC->deleteOldATC();
420 553
     }
421 554
     
422 555
     if (count($last_exec) == count($globalSources)) {
423 556
 	$max = $globalMinFetch;
424 557
 	foreach ($last_exec as $last) {
425
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
558
+	    if ((time() - $last['last']) < $max) {
559
+	    	$max = time() - $last['last'];
560
+	    }
426 561
 	}
427 562
 	if ($max < $globalMinFetch) {
428
-	    if ($globalDebug) echo 'Sleeping...'."\n";
563
+	    if ($globalDebug) {
564
+	    	echo 'Sleeping...'."\n";
565
+	    }
429 566
 	    sleep($globalMinFetch-$max+2);
430 567
 	}
431 568
     }
@@ -435,7 +572,9 @@  discard block
 block discarded – undo
435 572
     foreach ($globalSources as $id => $value) {
436 573
 	date_default_timezone_set('UTC');
437 574
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
438
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
575
+	if (!isset($last_exec[$id]['last'])) {
576
+		$last_exec[$id]['last'] = 0;
577
+	}
439 578
 	if ($value['format'] === 'deltadbtxt' && 
440 579
 	    (
441 580
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -444,7 +583,9 @@  discard block
 block discarded – undo
444 583
 	) {
445 584
 	    //$buffer = $Common->getData($hosts[$id]);
446 585
 	    $buffer = $Common->getData($value['host']);
447
-	    if ($buffer != '') $reset = 0;
586
+	    if ($buffer != '') {
587
+	    	$reset = 0;
588
+	    }
448 589
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
449 590
 	    $buffer = explode('\n',$buffer);
450 591
 	    foreach ($buffer as $line) {
@@ -453,20 +594,41 @@  discard block
 block discarded – undo
453 594
 	            $data = array();
454 595
 	            $data['hex'] = $line[1]; // hex
455 596
 	            $data['ident'] = $line[2]; // ident
456
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
457
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
458
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
459
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
460
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
597
+	            if (isset($line[3])) {
598
+	            	$data['altitude'] = $line[3];
599
+	            }
600
+	            // altitude
601
+	            if (isset($line[4])) {
602
+	            	$data['speed'] = $line[4];
603
+	            }
604
+	            // speed
605
+	            if (isset($line[5])) {
606
+	            	$data['heading'] = $line[5];
607
+	            }
608
+	            // heading
609
+	            if (isset($line[6])) {
610
+	            	$data['latitude'] = $line[6];
611
+	            }
612
+	            // lat
613
+	            if (isset($line[7])) {
614
+	            	$data['longitude'] = $line[7];
615
+	            }
616
+	            // long
461 617
 	            $data['verticalrate'] = ''; // vertical rate
462 618
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
463 619
 	            $data['emergency'] = ''; // emergency
464 620
 		    $data['datetime'] = date('Y-m-d H:i:s');
465 621
 		    $data['format_source'] = 'deltadbtxt';
466 622
     		    $data['id_source'] = $id_source;
467
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
468
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
469
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
623
+		    if (isset($value['name']) && $value['name'] != '') {
624
+		    	$data['source_name'] = $value['name'];
625
+		    }
626
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
627
+		    	$data['noarchive'] = true;
628
+		    }
629
+		    if (isset($value['sourcestats'])) {
630
+		    	$data['sourcestats'] = $value['sourcestats'];
631
+		    }
470 632
     		    $SI->add($data);
471 633
 		    unset($data);
472 634
     		}
@@ -481,7 +643,9 @@  discard block
 block discarded – undo
481 643
 	    date_default_timezone_set('CET');
482 644
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
483 645
 	    date_default_timezone_set('UTC');
484
-	    if ($buffer != '') $reset = 0;
646
+	    if ($buffer != '') {
647
+	    	$reset = 0;
648
+	    }
485 649
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
486 650
 	    $buffer = explode('\n',$buffer);
487 651
 	    foreach ($buffer as $line) {
@@ -490,18 +654,42 @@  discard block
 block discarded – undo
490 654
 		    $add = false;
491 655
 		    $ais_data = $AIS->parse_line(trim($line));
492 656
 		    $data = array();
493
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
494
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
495
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
496
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
497
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
498
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
499
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
500
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
501
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
502
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
503
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
504
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
657
+		    if (isset($ais_data['ident'])) {
658
+		    	$data['ident'] = $ais_data['ident'];
659
+		    }
660
+		    if (isset($ais_data['mmsi'])) {
661
+		    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
662
+		    }
663
+		    if (isset($ais_data['speed'])) {
664
+		    	$data['speed'] = $ais_data['speed'];
665
+		    }
666
+		    if (isset($ais_data['heading'])) {
667
+		    	$data['heading'] = $ais_data['heading'];
668
+		    }
669
+		    if (isset($ais_data['latitude'])) {
670
+		    	$data['latitude'] = $ais_data['latitude'];
671
+		    }
672
+		    if (isset($ais_data['longitude'])) {
673
+		    	$data['longitude'] = $ais_data['longitude'];
674
+		    }
675
+		    if (isset($ais_data['status'])) {
676
+		    	$data['status'] = $ais_data['status'];
677
+		    }
678
+		    if (isset($ais_data['statusid'])) {
679
+		    	$data['status_id'] = $ais_data['statusid'];
680
+		    }
681
+		    if (isset($ais_data['type'])) {
682
+		    	$data['type'] = $ais_data['type'];
683
+		    }
684
+		    if (isset($ais_data['typeid'])) {
685
+		    	$data['type_id'] = $ais_data['typeid'];
686
+		    }
687
+		    if (isset($ais_data['imo'])) {
688
+		    	$data['imo'] = $ais_data['imo'];
689
+		    }
690
+		    if (isset($ais_data['callsign'])) {
691
+		    	$data['callsign'] = $ais_data['callsign'];
692
+		    }
505 693
 		    if (isset($ais_data['timestamp'])) {
506 694
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
507 695
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -515,8 +703,12 @@  discard block
 block discarded – undo
515 703
 		    $data['format_source'] = 'aisnmeatxt';
516 704
     		    $data['id_source'] = $id_source;
517 705
 		    //print_r($data);
518
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
519
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
706
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
707
+		    	$data['noarchive'] = true;
708
+		    }
709
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
710
+		    	$MI->add($data);
711
+		    }
520 712
 		    unset($data);
521 713
 		}
522 714
     	    }
@@ -539,20 +731,48 @@  discard block
 block discarded – undo
539 731
 			    if ($line != '') {
540 732
 				$ais_data = $AIS->parse_line(trim($line));
541 733
 				$data = array();
542
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
543
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
544
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
545
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
546
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
547
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
548
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
549
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
550
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
551
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
552
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
553
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
554
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
555
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
734
+				if (isset($ais_data['ident'])) {
735
+					$data['ident'] = $ais_data['ident'];
736
+				}
737
+				if (isset($ais_data['mmsi'])) {
738
+					$data['mmsi'] = substr($ais_data['mmsi'],-9);
739
+				}
740
+				if (isset($ais_data['speed'])) {
741
+					$data['speed'] = $ais_data['speed'];
742
+				}
743
+				if (isset($ais_data['heading'])) {
744
+					$data['heading'] = $ais_data['heading'];
745
+				}
746
+				if (isset($ais_data['latitude'])) {
747
+					$data['latitude'] = $ais_data['latitude'];
748
+				}
749
+				if (isset($ais_data['longitude'])) {
750
+					$data['longitude'] = $ais_data['longitude'];
751
+				}
752
+				if (isset($ais_data['status'])) {
753
+					$data['status'] = $ais_data['status'];
754
+				}
755
+				if (isset($ais_data['statusid'])) {
756
+					$data['status_id'] = $ais_data['statusid'];
757
+				}
758
+				if (isset($ais_data['type'])) {
759
+					$data['type'] = $ais_data['type'];
760
+				}
761
+				if (isset($ais_data['typeid'])) {
762
+					$data['type_id'] = $ais_data['typeid'];
763
+				}
764
+				if (isset($ais_data['imo'])) {
765
+					$data['imo'] = $ais_data['imo'];
766
+				}
767
+				if (isset($ais_data['callsign'])) {
768
+					$data['callsign'] = $ais_data['callsign'];
769
+				}
770
+				if (isset($ais_data['destination'])) {
771
+					$data['arrival_code'] = $ais_data['destination'];
772
+				}
773
+				if (isset($ais_data['eta_ts'])) {
774
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
775
+				}
556 776
 				if (isset($ais_data['timestamp'])) {
557 777
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
558 778
 				} else {
@@ -560,18 +780,27 @@  discard block
 block discarded – undo
560 780
 				}
561 781
 				$data['format_source'] = 'aisnmeahttp';
562 782
 				$data['id_source'] = $id_source;
563
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
564
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
783
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
784
+					$data['noarchive'] = true;
785
+				}
786
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
787
+					$MI->add($data);
788
+				}
565 789
 				unset($data);
566 790
 			    }
567 791
 			}
568 792
 		    }
569 793
 		} else {
570 794
 		    $format = $value['format'];
571
-		    if (isset($tt[$format])) $tt[$format]++;
572
-		    else $tt[$format] = 0;
795
+		    if (isset($tt[$format])) {
796
+		    	$tt[$format]++;
797
+		    } else {
798
+		    	$tt[$format] = 0;
799
+		    }
573 800
 		    if ($tt[$format] > 30) {
574
-			if ($globalDebug) echo 'Reconnect...'."\n";
801
+			if ($globalDebug) {
802
+				echo 'Reconnect...'."\n";
803
+			}
575 804
 			sleep(2);
576 805
 			//$sourceeen[] = $value;
577 806
 			//connect_all($sourceeen);
@@ -607,12 +836,18 @@  discard block
 block discarded – undo
607 836
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
608 837
 			    //$data['type_id'] = $line['TYPE'];
609 838
 			    $data['imo'] = $line['IMO'];
610
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
611
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
839
+			    if ($line['DEST'] != '') {
840
+			    	$data['arrival_code'] = $line['DEST'];
841
+			    }
842
+			    if ($line['ARV'] != '') {
843
+			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
844
+			    }
612 845
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
613 846
 			    $data['format_source'] = 'myshiptracking';
614 847
 			    $data['id_source'] = $id_source;
615
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
848
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
849
+			    	$data['noarchive'] = true;
850
+			    }
616 851
 			    $MI->add($data);
617 852
 			    unset($data);
618 853
 			}
@@ -637,7 +872,9 @@  discard block
 block discarded – undo
637 872
 			    $data['callsign'] = $line['callsign'];
638 873
 			    $data['mmsi'] = substr($line['mmsi'],-9);
639 874
 			    $data['speed'] = $line['sog'];
640
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
875
+			    if ($line['heading'] != '511') {
876
+			    	$data['heading'] = $line['heading'];
877
+			    }
641 878
 			    $data['latitude'] = $line['latitude'];
642 879
 			    $data['longitude'] = $line['longitude'];
643 880
 			    $data['type_id'] = $line['shiptype'];
@@ -645,7 +882,9 @@  discard block
 block discarded – undo
645 882
 			    $data['datetime'] = $line['time'];
646 883
 			    $data['format_source'] = 'boatbeaconapp';
647 884
 			    $data['id_source'] = $id_source;
648
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
885
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
886
+			    	$data['noarchive'] = true;
887
+			    }
649 888
 			    $MI->add($data);
650 889
 			    unset($data);
651 890
 			}
@@ -667,22 +906,44 @@  discard block
 block discarded – undo
667 906
 		    foreach ($all_data['features'] as $line) {
668 907
 			print_r($line);
669 908
 			$data = array();
670
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
671
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
672
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
673
-			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
674
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
675
-			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
909
+			if (isset($line['properties']['name'])) {
910
+				$data['ident'] = $line['properties']['name'];
911
+			}
912
+			if (isset($line['properties']['callsign'])) {
913
+				$data['callsign'] = $line['properties']['callsign'];
914
+			}
915
+			if (isset($line['properties']['mmsi'])) {
916
+				$data['mmsi'] = substr($line['properties']['mmsi'],-9);
917
+			}
918
+			if (isset($line['properties']['imo'])) {
919
+				$data['imo'] = $line['properties']['imo'];
920
+			}
921
+			if (isset($line['properties']['speed'])) {
922
+				$data['speed'] = $line['properties']['speed'];
923
+			}
924
+			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) {
925
+				$data['heading'] = $line['properties']['heading'];
926
+			}
676 927
 			$data['latitude'] = $line['geometry']['coordinates'][1];
677 928
 			$data['longitude'] = $line['geometry']['coordinates'][0];
678
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
679
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
680
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
929
+			if (isset($line['properties']['vesselType'])) {
930
+				$data['type'] = $line['properties']['vesselType'];
931
+			}
932
+			if (isset($line['properties']['destination'])) {
933
+				$data['arrival_code'] = $line['properties']['destination'];
934
+			}
935
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
936
+				$data['arrival_date'] = $line['properties']['eta'];
937
+			}
681 938
 			$data['format_source'] = 'boatnerd';
682 939
 			$data['id_source'] = $id_source;
683 940
 			$data['datetime'] = date('Y-m-d H:i:s');
684
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
685
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
941
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
942
+				$data['noarchive'] = true;
943
+			}
944
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
945
+				$MI->add($data);
946
+			}
686 947
 			unset($data);
687 948
 		    }
688 949
 		}
@@ -695,11 +956,17 @@  discard block
 block discarded – undo
695 956
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
696 957
 	    )
697 958
 	) {
698
-	    if ($globalDebug) echo 'download...';
959
+	    if ($globalDebug) {
960
+	    	echo 'download...';
961
+	    }
699 962
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
700
-	    if ($globalDebug) echo 'done !'."\n";
963
+	    if ($globalDebug) {
964
+	    	echo 'done !'."\n";
965
+	    }
701 966
 	    // FIXME: Need more work
702
-	    if ($buffer != '') $reset = 0;
967
+	    if ($buffer != '') {
968
+	    	$reset = 0;
969
+	    }
703 970
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
704 971
 	    $buffer = explode('\n',$buffer);
705 972
 	    foreach ($buffer as $line) {
@@ -725,7 +992,9 @@  discard block
 block discarded – undo
725 992
 		    //$data['etaTime'] = substr($line,135,5);
726 993
 		    $data['format_source'] = 'shipplotter';
727 994
     		    $data['id_source'] = $id_source;
728
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
995
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
996
+		    	$data['noarchive'] = true;
997
+		    }
729 998
 		    //print_r($data);
730 999
 		    //echo 'Add...'."\n";
731 1000
 		    $MI->add($data);
@@ -748,11 +1017,17 @@  discard block
 block discarded – undo
748 1017
 		}
749 1018
 	    }
750 1019
 
751
-	    if ($globalDebug) echo '! Download... ';
1020
+	    if ($globalDebug) {
1021
+	    	echo '! Download... ';
1022
+	    }
752 1023
 	    for ($i =0; $i <= 1; $i++) {
753
-		    if ($globalDebug) echo 'Racetype: '.$i.' ';
1024
+		    if ($globalDebug) {
1025
+		    	echo 'Racetype: '.$i.' ';
1026
+		    }
754 1027
 	    $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
755
-	    if ($globalDebug) echo 'done'."\n";
1028
+	    if ($globalDebug) {
1029
+	    	echo 'done'."\n";
1030
+	    }
756 1031
 	    if ($buffer != '') {
757 1032
 		$all_data = json_decode($buffer,true);
758 1033
 		if (isset($all_data['missions'])) {
@@ -760,8 +1035,11 @@  discard block
 block discarded – undo
760 1035
 				$mission_user = $mission['usrname'];
761 1036
 				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
762 1037
 				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
763
-					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
764
-					else $racebuffer = '';
1038
+					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') {
1039
+						$racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
1040
+					} else {
1041
+						$racebuffer = '';
1042
+					}
765 1043
 					$bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
766 1044
 				} else {
767 1045
 					$bufferm = '';
@@ -825,7 +1103,9 @@  discard block
 block discarded – undo
825 1103
 								$data['captain_id'] = $sail['usrnr'];
826 1104
 								$data['captain_name'] = $sail['usrname'];
827 1105
 								$data['race_id'] = $sail['misnr'];
828
-								if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank'];
1106
+								if ($sail['rank'] != 'DNF') {
1107
+									$data['race_rank'] = $sail['rank'];
1108
+								}
829 1109
 								$data['race_time'] = $sail['racetime'];
830 1110
 								if ($mission_user != '') {
831 1111
 									$data['race_name'] = $mission_name.' ('.$mission_user.')';
@@ -835,7 +1115,9 @@  discard block
 block discarded – undo
835 1115
 								//$data['callsign'] = trim(substr($line,100,7);
836 1116
 								$data['format_source'] = 'sailaway';
837 1117
 								$data['id_source'] = $id_source;
838
-								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1118
+								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1119
+									$data['noarchive'] = true;
1120
+								}
839 1121
 								//print_r($data);
840 1122
 								//echo 'Add...'."\n";
841 1123
 								$MI->add($data);
@@ -876,16 +1158,28 @@  discard block
 block discarded – undo
876 1158
     		    $line = explode(':', $line);
877 1159
     		    if (count($line) > 30 && $line[0] != 'callsign') {
878 1160
 			$data = array();
879
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
880
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1161
+			if (isset($line[37]) && $line[37] != '') {
1162
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
1163
+			} else {
1164
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1165
+			}
881 1166
 			$data['pilot_id'] = $line[1];
882 1167
 			$data['pilot_name'] = $line[2];
883 1168
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
884 1169
 			$data['ident'] = $line[0]; // ident
885
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
1170
+			if ($line[7] != '' && $line[7] != 0) {
1171
+				$data['altitude'] = $line[7];
1172
+			}
1173
+			// altitude
886 1174
 			$data['speed'] = $line[8]; // speed
887
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
888
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1175
+			if (isset($line[45])) {
1176
+				$data['heading'] = $line[45];
1177
+			}
1178
+			// heading
1179
+			elseif (isset($line[38])) {
1180
+				$data['heading'] = $line[38];
1181
+			}
1182
+			// heading
889 1183
 			$data['latitude'] = $line[5]; // lat
890 1184
 	        	$data['longitude'] = $line[6]; // long
891 1185
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -901,7 +1195,9 @@  discard block
 block discarded – undo
901 1195
 			$data['frequency'] = $line[4];
902 1196
 			$data['type'] = $line[18];
903 1197
 			$data['range'] = $line[19];
904
-			if (isset($line[35])) $data['info'] = $line[35];
1198
+			if (isset($line[35])) {
1199
+				$data['info'] = $line[35];
1200
+			}
905 1201
     			$data['id_source'] = $id_source;
906 1202
 	    		//$data['arrival_airport_time'] = ;
907 1203
 	    		if ($line[9] != '') {
@@ -915,27 +1211,47 @@  discard block
 block discarded – undo
915 1211
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
916 1212
 	    		*/
917 1213
 	    		$data['format_source'] = $value['format'];
918
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
919
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
920
-    			if ($line[3] === 'PILOT') $SI->add($data);
921
-			elseif ($line[3] === 'ATC') {
1214
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1215
+				$data['noarchive'] = true;
1216
+			}
1217
+			if (isset($value['name']) && $value['name'] != '') {
1218
+				$data['source_name'] = $value['name'];
1219
+			}
1220
+    			if ($line[3] === 'PILOT') {
1221
+    				$SI->add($data);
1222
+    			} elseif ($line[3] === 'ATC') {
922 1223
 				//print_r($data);
923 1224
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
924 1225
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
925 1226
 				$typec = substr($data['ident'],-3);
926
-				if ($typec === 'APP') $data['type'] = 'Approach';
927
-				elseif ($typec === 'TWR') $data['type'] = 'Tower';
928
-				elseif ($typec === 'OBS') $data['type'] = 'Observer';
929
-				elseif ($typec === 'GND') $data['type'] = 'Ground';
930
-				elseif ($typec === 'DEL') $data['type'] = 'Delivery';
931
-				elseif ($typec === 'DEP') $data['type'] = 'Departure';
932
-				elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
933
-				elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
934
-				elseif ($data['type'] === '') $data['type'] = 'Observer';
935
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1227
+				if ($typec === 'APP') {
1228
+					$data['type'] = 'Approach';
1229
+				} elseif ($typec === 'TWR') {
1230
+					$data['type'] = 'Tower';
1231
+				} elseif ($typec === 'OBS') {
1232
+					$data['type'] = 'Observer';
1233
+				} elseif ($typec === 'GND') {
1234
+					$data['type'] = 'Ground';
1235
+				} elseif ($typec === 'DEL') {
1236
+					$data['type'] = 'Delivery';
1237
+				} elseif ($typec === 'DEP') {
1238
+					$data['type'] = 'Departure';
1239
+				} elseif ($typec === 'FSS') {
1240
+					$data['type'] = 'Flight Service Station';
1241
+				} elseif ($typec === 'CTR') {
1242
+					$data['type'] = 'Control Radar or Centre';
1243
+				} elseif ($data['type'] === '') {
1244
+					$data['type'] = 'Observer';
1245
+				}
1246
+				if (!isset($data['source_name'])) {
1247
+					$data['source_name'] = '';
1248
+				}
936 1249
 				if (isset($ATC)) {
937
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($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']);
938
-					else 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']);
1250
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1251
+						echo $ATC->update($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']);
1252
+					} else {
1253
+						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']);
1254
+					}
939 1255
 				}
940 1256
 			}
941 1257
     			unset($data);
@@ -962,14 +1278,20 @@  discard block
 block discarded – undo
962 1278
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
963 1279
 			$data['latitude'] = (float)$line['pktLatitude'];
964 1280
 			$data['longitude'] = (float)$line['pktLongitude'];
965
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
966
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1281
+			if ((float)$line['pktTrack'] != 0) {
1282
+				$data['heading'] = (float)$line['pktTrack'];
1283
+			}
1284
+			if ((int)$line['pktSpeed'] != 0) {
1285
+				$data['speed'] = (int)$line['pktSpeed'];
1286
+			}
967 1287
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
968 1288
 			$data['altitude_relative'] = 'AMSL';
969 1289
 			$data['pilot_id'] = (int)$line['pktPilotID'];
970 1290
 			$data['aircraft_icao'] = 'PARAGLIDER';
971 1291
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
972
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1292
+			if (isset($pilot_data[4])) {
1293
+				$data['pilot_name'] = $pilot_data[4];
1294
+			}
973 1295
 			$data['format_source'] = $value['format'];
974 1296
 			$SI->add($data);
975 1297
 			unset($data);
@@ -1017,25 +1339,59 @@  discard block
 block discarded – undo
1017 1339
 		    foreach ($all_data['acList'] as $line) {
1018 1340
 			$data = array();
1019 1341
 			$data['hex'] = $line['Icao']; // hex
1020
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1021
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1022
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1023
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1024
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1025
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1342
+			if (isset($line['Call'])) {
1343
+				$data['ident'] = $line['Call'];
1344
+			}
1345
+			// ident
1346
+			if (isset($line['Alt'])) {
1347
+				$data['altitude'] = $line['Alt'];
1348
+			}
1349
+			// altitude
1350
+			if (isset($line['Spd'])) {
1351
+				$data['speed'] = $line['Spd'];
1352
+			}
1353
+			// speed
1354
+			if (isset($line['Trak'])) {
1355
+				$data['heading'] = $line['Trak'];
1356
+			}
1357
+			// heading
1358
+			if (isset($line['Lat'])) {
1359
+				$data['latitude'] = $line['Lat'];
1360
+			}
1361
+			// lat
1362
+			if (isset($line['Long'])) {
1363
+				$data['longitude'] = $line['Long'];
1364
+			}
1365
+			// long
1026 1366
 			//$data['verticalrate'] = $line['']; // verticale rate
1027
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1367
+			if (isset($line['Sqk'])) {
1368
+				$data['squawk'] = $line['Sqk'];
1369
+			}
1370
+			// squawk
1028 1371
 			$data['emergency'] = ''; // emergency
1029
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1030
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1031
-			else $data['datetime'] = date('Y-m-d H:i:s');
1372
+			if (isset($line['Reg'])) {
1373
+				$data['registration'] = $line['Reg'];
1374
+			}
1375
+			if (isset($line['PosTime'])) {
1376
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1377
+			} else {
1378
+				$data['datetime'] = date('Y-m-d H:i:s');
1379
+			}
1032 1380
 			//$data['datetime'] = date('Y-m-d H:i:s');
1033
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1381
+			if (isset($line['Type'])) {
1382
+				$data['aircraft_icao'] = $line['Type'];
1383
+			}
1034 1384
 			$data['format_source'] = 'aircraftlistjson';
1035 1385
 			$data['id_source'] = $id_source;
1036
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1037
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1038
-			if (isset($data['latitude'])) $SI->add($data);
1386
+			if (isset($value['name']) && $value['name'] != '') {
1387
+				$data['source_name'] = $value['name'];
1388
+			}
1389
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1390
+				$data['noarchive'] = true;
1391
+			}
1392
+			if (isset($data['latitude'])) {
1393
+				$SI->add($data);
1394
+			}
1039 1395
 			unset($data);
1040 1396
 		    }
1041 1397
 		} elseif (is_array($all_data)) {
@@ -1052,17 +1408,26 @@  discard block
 block discarded – undo
1052 1408
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1053 1409
 			$data['squawk'] = $line['squawk']; // squawk
1054 1410
 			$data['emergency'] = ''; // emergency
1055
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1056
-			else $data['datetime'] = date('Y-m-d H:i:s');
1411
+			if (isset($line['PosTime'])) {
1412
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1413
+			} else {
1414
+				$data['datetime'] = date('Y-m-d H:i:s');
1415
+			}
1057 1416
 			$data['format_source'] = 'aircraftlistjson';
1058 1417
 			$data['id_source'] = $id_source;
1059
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1060
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1418
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1419
+				$data['noarchive'] = true;
1420
+			}
1421
+			if (isset($value['name']) && $value['name'] != '') {
1422
+				$data['source_name'] = $value['name'];
1423
+			}
1061 1424
 			$SI->add($data);
1062 1425
 			unset($data);
1063 1426
 		    }
1064 1427
 		}
1065
-	    } elseif ($globalDebug) echo 'No data'."\n";
1428
+	    } elseif ($globalDebug) {
1429
+	    	echo 'No data'."\n";
1430
+	    }
1066 1431
     	    //$last_exec['aircraftlistjson'] = time();
1067 1432
     	    $last_exec[$id]['last'] = time();
1068 1433
     	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -1098,8 +1463,12 @@  discard block
 block discarded – undo
1098 1463
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1099 1464
 	    	    $data['format_source'] = 'planeupdatefaa';
1100 1465
     		    $data['id_source'] = $id_source;
1101
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1102
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1466
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1467
+		    	$data['noarchive'] = true;
1468
+		    }
1469
+		    if (isset($value['name']) && $value['name'] != '') {
1470
+		    	$data['source_name'] = $value['name'];
1471
+		    }
1103 1472
 		    $SI->add($data);
1104 1473
 		    unset($data);
1105 1474
 		}
@@ -1133,7 +1502,9 @@  discard block
 block discarded – undo
1133 1502
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1134 1503
 		    $data['format_source'] = 'opensky';
1135 1504
 		    $data['id_source'] = $id_source;
1136
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1505
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1506
+		    	$data['noarchive'] = true;
1507
+		    }
1137 1508
 		    $SI->add($data);
1138 1509
 		    unset($data);
1139 1510
 		}
@@ -1153,15 +1524,42 @@  discard block
 block discarded – undo
1153 1524
 		foreach ($all_data['aircraft'] as $key => $line) {
1154 1525
 		    $data = array();
1155 1526
 		    // add support for ground vehicule with ~ in front of hex
1156
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1157
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1158
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1159
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1160
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1161
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1162
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1163
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1164
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1527
+		    if (isset($line['hex'])) {
1528
+		    	$data['hex'] = $line['hex'];
1529
+		    }
1530
+		    // hex
1531
+		    if (isset($line['flight'])) {
1532
+		    	$data['ident'] = trim($line['flight']);
1533
+		    }
1534
+		    // ident
1535
+		    if (isset($line['altitude'])) {
1536
+		    	$data['altitude'] = $line['altitude'];
1537
+		    }
1538
+		    // altitude
1539
+		    if (isset($line['speed'])) {
1540
+		    	$data['speed'] = $line['speed'];
1541
+		    }
1542
+		    // speed
1543
+		    if (isset($line['track'])) {
1544
+		    	$data['heading'] = $line['track'];
1545
+		    }
1546
+		    // heading
1547
+		    if (isset($line['lat'])) {
1548
+		    	$data['latitude'] = $line['lat'];
1549
+		    }
1550
+		    // lat
1551
+		    if (isset($line['lon'])) {
1552
+		    	$data['longitude'] = $line['lon'];
1553
+		    }
1554
+		    // long
1555
+		    if (isset($line['vert_rate'])) {
1556
+		    	$data['verticalrate'] = $line['vert_rate'];
1557
+		    }
1558
+		    // verticale rate
1559
+		    if (isset($line['squawk'])) {
1560
+		    	$data['squawk'] = $line['squawk'];
1561
+		    }
1562
+		    // squawk
1165 1563
 		    //$data['emergency'] = ''; // emergency
1166 1564
 		    //$data['registration'] = $line[2];
1167 1565
 		    //$data['aircraft_icao'] = $line[0];
@@ -1169,10 +1567,17 @@  discard block
 block discarded – undo
1169 1567
 		    $data['format_source'] = 'aircraftjson';
1170 1568
 		    $data['id_source'] = $id_source;
1171 1569
 		    if (isset($value['name']) && $value['name'] != '') {
1172
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1173
-			    else $data['source_name'] = $value['name'];
1174
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1175
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1570
+			    if (isset($line['mlat']) && !empty($line['mlat'])) {
1571
+			    	$data['source_name'] = $value['name'].'_MLAT';
1572
+			    } else {
1573
+			    	$data['source_name'] = $value['name'];
1574
+			    }
1575
+		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) {
1576
+		    	$data['source_name'] = 'MLAT';
1577
+		    }
1578
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1579
+		    	$data['noarchive'] = true;
1580
+		    }
1176 1581
 		    $SI->add($data);
1177 1582
 		    unset($data);
1178 1583
 		}
@@ -1192,22 +1597,54 @@  discard block
 block discarded – undo
1192 1597
 		foreach ($all_data['aircraft'] as $key => $line) {
1193 1598
 		    $data = array();
1194 1599
 		    $data['hex'] = $key; // hex
1195
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1196
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1197
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1198
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1199
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1200
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1201
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1202
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1600
+		    if (isset($line['callsign'])) {
1601
+		    	$data['ident'] = trim($line['callsign']);
1602
+		    }
1603
+		    // ident
1604
+		    if (isset($line['altitude'])) {
1605
+		    	$data['altitude'] = $line['altitude'];
1606
+		    }
1607
+		    // altitude
1608
+		    if (isset($line['speed'])) {
1609
+		    	$data['speed'] = $line['speed'];
1610
+		    }
1611
+		    // speed
1612
+		    if (isset($line['heading'])) {
1613
+		    	$data['heading'] = $line['heading'];
1614
+		    }
1615
+		    // heading
1616
+		    if (isset($line['lat'])) {
1617
+		    	$data['latitude'] = $line['lat'];
1618
+		    }
1619
+		    // lat
1620
+		    if (isset($line['lon'])) {
1621
+		    	$data['longitude'] = $line['lon'];
1622
+		    }
1623
+		    // long
1624
+		    if (isset($line['vert_rate'])) {
1625
+		    	$data['verticalrate'] = $line['vert_rate'];
1626
+		    }
1627
+		    // verticale rate
1628
+		    if (isset($line['squawk'])) {
1629
+		    	$data['squawk'] = $line['squawk'];
1630
+		    }
1631
+		    // squawk
1203 1632
 		    //$data['emergency'] = ''; // emergency
1204
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1205
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1633
+		    if (isset($line['reg'])) {
1634
+		    	$data['registration'] = $line['reg'];
1635
+		    }
1636
+		    if (isset($line['type'])) {
1637
+		    	$data['aircraft_icao'] = $line['type'];
1638
+		    }
1206 1639
 		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1207 1640
 		    $data['format_source'] = 'planefinderclient';
1208 1641
 		    $data['id_source'] = $id_source;
1209
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1210
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1642
+		    if (isset($value['name']) && $value['name'] != '') {
1643
+		    	$data['source_name'] = $value['name'];
1644
+		    }
1645
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1646
+		    	$data['noarchive'] = true;
1647
+		    }
1211 1648
 		    $SI->add($data);
1212 1649
 		    unset($data);
1213 1650
 		}
@@ -1223,7 +1660,9 @@  discard block
 block discarded – undo
1223 1660
 	    //$buffer = $Common->getData($hosts[$id]);
1224 1661
 	    $buffer = $Common->getData($value['host']);
1225 1662
 	    $all_data = json_decode($buffer,true);
1226
-	    if (!empty($all_data)) $reset = 0;
1663
+	    if (!empty($all_data)) {
1664
+	    	$reset = 0;
1665
+	    }
1227 1666
 	    foreach ($all_data as $key => $line) {
1228 1667
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1229 1668
 		    $data = array();
@@ -1244,8 +1683,12 @@  discard block
 block discarded – undo
1244 1683
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1245 1684
 	    	    $data['format_source'] = 'fr24json';
1246 1685
     		    $data['id_source'] = $id_source;
1247
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1248
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1686
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1687
+		    	$data['noarchive'] = true;
1688
+		    }
1689
+		    if (isset($value['name']) && $value['name'] != '') {
1690
+		    	$data['source_name'] = $value['name'];
1691
+		    }
1249 1692
 		    $SI->add($data);
1250 1693
 		    unset($data);
1251 1694
 		}
@@ -1274,24 +1717,42 @@  discard block
 block discarded – undo
1274 1717
 		    if (isset($line['inf'])) {
1275 1718
 			$data = array();
1276 1719
 			$data['hex'] = $line['inf']['ia'];
1277
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1720
+			if (isset($line['inf']['cs'])) {
1721
+				$data['ident'] = $line['inf']['cs'];
1722
+			}
1723
+			//$line[13]
1278 1724
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1279
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1280
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1725
+	    		if (isset($line['inf']['gs'])) {
1726
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1727
+	    		}
1728
+	    		// speed
1729
+	    		if (isset($line['inf']['tr'])) {
1730
+	    			$data['heading'] = $line['inf']['tr'];
1731
+	    		}
1732
+	    		// heading
1281 1733
 	    		$data['latitude'] = $line['pt'][0]; // lat
1282 1734
 	    		$data['longitude'] = $line['pt'][1]; // long
1283 1735
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1284
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1736
+	    		if (isset($line['inf']['sq'])) {
1737
+	    			$data['squawk'] = $line['inf']['sq'];
1738
+	    		}
1739
+	    		// squawk
1285 1740
 	    		//$data['aircraft_icao'] = $line[8];
1286
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1741
+	    		if (isset($line['inf']['rc'])) {
1742
+	    			$data['registration'] = $line['inf']['rc'];
1743
+	    		}
1287 1744
 			//$data['departure_airport_iata'] = $line[11];
1288 1745
 			//$data['arrival_airport_iata'] = $line[12];
1289 1746
 	    		//$data['emergency'] = ''; // emergency
1290 1747
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1291 1748
 	    		$data['format_source'] = 'radarvirtueljson';
1292 1749
     			$data['id_source'] = $id_source;
1293
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1294
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1750
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1751
+				$data['noarchive'] = true;
1752
+			}
1753
+			if (isset($value['name']) && $value['name'] != '') {
1754
+				$data['source_name'] = $value['name'];
1755
+			}
1295 1756
 			$SI->add($data);
1296 1757
 			unset($data);
1297 1758
 		    }
@@ -1317,30 +1778,65 @@  discard block
 block discarded – undo
1317 1778
 		    $data['id'] = $line['id'];
1318 1779
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1319 1780
 		    $data['ident'] = $line['callsign']; // ident
1320
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1321
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1322
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1323
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1324
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1325
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1781
+		    if (isset($line['pilotid'])) {
1782
+		    	$data['pilot_id'] = $line['pilotid'];
1783
+		    }
1784
+		    // pilot id
1785
+		    if (isset($line['name'])) {
1786
+		    	$data['pilot_name'] = $line['name'];
1787
+		    }
1788
+		    // pilot name
1789
+		    if (isset($line['alt'])) {
1790
+		    	$data['altitude'] = $line['alt'];
1791
+		    }
1792
+		    // altitude
1793
+		    if (isset($line['gs'])) {
1794
+		    	$data['speed'] = $line['gs'];
1795
+		    }
1796
+		    // speed
1797
+		    if (isset($line['heading'])) {
1798
+		    	$data['heading'] = $line['heading'];
1799
+		    }
1800
+		    // heading
1801
+		    if (isset($line['route'])) {
1802
+		    	$data['waypoints'] = $line['route'];
1803
+		    }
1804
+		    // route
1326 1805
 		    $data['latitude'] = $line['lat']; // lat
1327 1806
 		    $data['longitude'] = $line['lon']; // long
1328 1807
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1329 1808
 		    //$data['squawk'] = $line['squawk']; // squawk
1330 1809
 		    //$data['emergency'] = ''; // emergency
1331
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1332
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1333
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1810
+		    if (isset($line['depicao'])) {
1811
+		    	$data['departure_airport_icao'] = $line['depicao'];
1812
+		    }
1813
+		    if (isset($line['deptime'])) {
1814
+		    	$data['departure_airport_time'] = $line['deptime'];
1815
+		    }
1816
+		    if (isset($line['arricao'])) {
1817
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1818
+		    }
1334 1819
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1335
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1336
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1337
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1338
-		    else $data['info'] = '';
1820
+		    if (isset($line['aircraft'])) {
1821
+		    	$data['aircraft_icao'] = $line['aircraft'];
1822
+		    }
1823
+		    if (isset($line['transponder'])) {
1824
+		    	$data['squawk'] = $line['transponder'];
1825
+		    }
1826
+		    if (isset($line['atis'])) {
1827
+		    	$data['info'] = $line['atis'];
1828
+		    } else {
1829
+		    	$data['info'] = '';
1830
+		    }
1339 1831
 		    $data['format_source'] = 'pireps';
1340 1832
     		    $data['id_source'] = $id_source;
1341 1833
 		    $data['datetime'] = date('Y-m-d H:i:s');
1342
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1343
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1834
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1835
+		    	$data['noarchive'] = true;
1836
+		    }
1837
+		    if (isset($value['name']) && $value['name'] != '') {
1838
+		    	$data['source_name'] = $value['name'];
1839
+		    }
1344 1840
 		    if ($line['icon'] === 'plane') {
1345 1841
 			$SI->add($data);
1346 1842
 		    //    print_r($data);
@@ -1349,16 +1845,28 @@  discard block
 block discarded – undo
1349 1845
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1350 1846
 			$typec = substr($data['ident'],-3);
1351 1847
 			$data['type'] = '';
1352
-			if ($typec === 'APP') $data['type'] = 'Approach';
1353
-			elseif ($typec === 'TWR') $data['type'] = 'Tower';
1354
-			elseif ($typec === 'OBS') $data['type'] = 'Observer';
1355
-			elseif ($typec === 'GND') $data['type'] = 'Ground';
1356
-			elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1357
-			elseif ($typec === 'DEP') $data['type'] = 'Departure';
1358
-			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1359
-			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1360
-			else $data['type'] = 'Observer';
1361
-			if (isset($ATC)) 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']);
1848
+			if ($typec === 'APP') {
1849
+				$data['type'] = 'Approach';
1850
+			} elseif ($typec === 'TWR') {
1851
+				$data['type'] = 'Tower';
1852
+			} elseif ($typec === 'OBS') {
1853
+				$data['type'] = 'Observer';
1854
+			} elseif ($typec === 'GND') {
1855
+				$data['type'] = 'Ground';
1856
+			} elseif ($typec === 'DEL') {
1857
+				$data['type'] = 'Delivery';
1858
+			} elseif ($typec === 'DEP') {
1859
+				$data['type'] = 'Departure';
1860
+			} elseif ($typec === 'FSS') {
1861
+				$data['type'] = 'Flight Service Station';
1862
+			} elseif ($typec === 'CTR') {
1863
+				$data['type'] = 'Control Radar or Centre';
1864
+			} else {
1865
+				$data['type'] = 'Observer';
1866
+			}
1867
+			if (isset($ATC)) {
1868
+				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']);
1869
+			}
1362 1870
 		    }
1363 1871
 		    unset($data);
1364 1872
 		}
@@ -1373,7 +1881,9 @@  discard block
 block discarded – undo
1373 1881
 	    )
1374 1882
 	) {
1375 1883
 	    //$buffer = $Common->getData($hosts[$id]);
1376
-	    if ($globalDebug) echo 'Get Data...'."\n";
1884
+	    if ($globalDebug) {
1885
+	    	echo 'Get Data...'."\n";
1886
+	    }
1377 1887
 	    $buffer = $Common->getData($value['host']);
1378 1888
 	    $all_data = json_decode($buffer,true);
1379 1889
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1381,10 +1891,16 @@  discard block
 block discarded – undo
1381 1891
 		foreach ($all_data as $line) {
1382 1892
 	    	    $data = array();
1383 1893
 	    	    //$data['id'] = $line['id']; // id not usable
1384
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1894
+	    	    if (isset($line['pilotid'])) {
1895
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1896
+	    	    }
1385 1897
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1386
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1387
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1898
+	    	    if (isset($line['pilotname'])) {
1899
+	    	    	$data['pilot_name'] = $line['pilotname'];
1900
+	    	    }
1901
+	    	    if (isset($line['pilotid'])) {
1902
+	    	    	$data['pilot_id'] = $line['pilotid'];
1903
+	    	    }
1388 1904
 	    	    $data['ident'] = $line['flightnum']; // ident
1389 1905
 	    	    $data['altitude'] = $line['alt']; // altitude
1390 1906
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1400,7 +1916,9 @@  discard block
 block discarded – undo
1400 1916
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1401 1917
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1402 1918
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1403
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1919
+	    	    } else {
1920
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1921
+	    	    }
1404 1922
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1405 1923
 	    	    $data['departure_airport_time'] = $line['deptime'];
1406 1924
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1408,29 +1926,47 @@  discard block
 block discarded – undo
1408 1926
     		    if (isset($line['registration'])) {
1409 1927
     			$data['registration'] = $line['registration'];
1410 1928
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1411
-    		    } else $data['registration'] = $line['aircraft'];
1412
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1413
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1929
+    		    } else {
1930
+    		    	$data['registration'] = $line['aircraft'];
1931
+    		    }
1932
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1933
+		    	$data['noarchive'] = true;
1934
+		    }
1935
+		    if (isset($line['route'])) {
1936
+		    	$data['waypoints'] = $line['route'];
1937
+		    }
1938
+		    // route
1414 1939
 		    if (isset($line['aircraftname'])) {
1415 1940
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1416 1941
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1417 1942
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1418
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1419
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1420
-	    		else {
1943
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1944
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1945
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1946
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1947
+	    		} else {
1421 1948
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1422
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1423
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1949
+	    		    if (isset($aircraft_data[1])) {
1950
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1951
+	    		    } else {
1952
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1953
+	    		    }
1424 1954
 	    		}
1425 1955
 	    	    }
1426
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1956
+    		    if (isset($line['route'])) {
1957
+    		    	$data['waypoints'] = $line['route'];
1958
+    		    }
1427 1959
     		    $data['id_source'] = $id_source;
1428 1960
 	    	    $data['format_source'] = 'phpvmacars';
1429
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1961
+		    if (isset($value['name']) && $value['name'] != '') {
1962
+		    	$data['source_name'] = $value['name'];
1963
+		    }
1430 1964
 		    $SI->add($data);
1431 1965
 		    unset($data);
1432 1966
 		}
1433
-		if ($globalDebug) echo 'No more data...'."\n";
1967
+		if ($globalDebug) {
1968
+			echo 'No more data...'."\n";
1969
+		}
1434 1970
 		unset($buffer);
1435 1971
 		unset($all_data);
1436 1972
 	    }
@@ -1443,7 +1979,9 @@  discard block
 block discarded – undo
1443 1979
 	    )
1444 1980
 	) {
1445 1981
 	    //$buffer = $Common->getData($hosts[$id]);
1446
-	    if ($globalDebug) echo 'Get Data...'."\n";
1982
+	    if ($globalDebug) {
1983
+	    	echo 'Get Data...'."\n";
1984
+	    }
1447 1985
 	    $buffer = $Common->getData($value['host']);
1448 1986
 	    $all_data = json_decode($buffer,true);
1449 1987
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1454,10 +1992,16 @@  discard block
 block discarded – undo
1454 1992
 	    	    //$data['id'] = $line['id']; // id not usable
1455 1993
 	    	    $data['id'] = $line['id'];
1456 1994
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1457
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1458
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1995
+	    	    if (isset($line['user']['username'])) {
1996
+	    	    	$data['pilot_name'] = $line['user']['username'];
1997
+	    	    }
1998
+	    	    if (isset($line['user_id'])) {
1999
+	    	    	$data['pilot_id'] = $line['user_id'];
2000
+	    	    }
1459 2001
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1460
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2002
+	    	    if (is_numeric($data['ident'])) {
2003
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2004
+	    	    }
1461 2005
 	    	    $data['altitude'] = $line['altitude']; // altitude
1462 2006
 	    	    $data['speed'] = $line['groundspeed']; // speed
1463 2007
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1470,7 +2014,9 @@  discard block
 block discarded – undo
1470 2014
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1471 2015
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1472 2016
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1473
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
2017
+	    	    } else {
2018
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
2019
+	    	    }
1474 2020
 	    	    
1475 2021
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1476 2022
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1478,17 +2024,26 @@  discard block
 block discarded – undo
1478 2024
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1479 2025
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1480 2026
 
1481
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1482
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
2027
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2028
+		    	$data['noarchive'] = true;
2029
+		    }
2030
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
2031
+		    	$data['waypoints'] = $line['bid']['route'];
2032
+		    }
2033
+		    // route
1483 2034
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1484 2035
 
1485 2036
     		    $data['id_source'] = $id_source;
1486 2037
 	    	    $data['format_source'] = 'vaos';
1487
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2038
+		    if (isset($value['name']) && $value['name'] != '') {
2039
+		    	$data['source_name'] = $value['name'];
2040
+		    }
1488 2041
 		    $SI->add($data);
1489 2042
 		    unset($data);
1490 2043
 		}
1491
-		if ($globalDebug) echo 'No more data...'."\n";
2044
+		if ($globalDebug) {
2045
+			echo 'No more data...'."\n";
2046
+		}
1492 2047
 		unset($buffer);
1493 2048
 		unset($all_data);
1494 2049
 	    }
@@ -1501,7 +2056,9 @@  discard block
 block discarded – undo
1501 2056
 	    )
1502 2057
 	) {
1503 2058
 	    //$buffer = $Common->getData($hosts[$id]);
1504
-	    if ($globalDebug) echo 'Get Data...'."\n";
2059
+	    if ($globalDebug) {
2060
+	    	echo 'Get Data...'."\n";
2061
+	    }
1505 2062
 	    $buffer = $Common->getData($value['host']);
1506 2063
 	    $all_data = json_decode($buffer,true);
1507 2064
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1530,16 +2087,25 @@  discard block
 block discarded – undo
1530 2087
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1531 2088
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1532 2089
     		    //$data['registration'] = $line['aircraft'];
1533
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
2090
+		    if (isset($line['route'])) {
2091
+		    	$data['waypoints'] = $line['route'];
2092
+		    }
2093
+		    // route
1534 2094
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1535 2095
     		    $data['id_source'] = $id_source;
1536 2096
 	    	    $data['format_source'] = 'vam';
1537
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1538
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2097
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2098
+		    	$data['noarchive'] = true;
2099
+		    }
2100
+		    if (isset($value['name']) && $value['name'] != '') {
2101
+		    	$data['source_name'] = $value['name'];
2102
+		    }
1539 2103
 		    $SI->add($data);
1540 2104
 		    unset($data);
1541 2105
 		}
1542
-		if ($globalDebug) echo 'No more data...'."\n";
2106
+		if ($globalDebug) {
2107
+			echo 'No more data...'."\n";
2108
+		}
1543 2109
 		unset($buffer);
1544 2110
 		unset($all_data);
1545 2111
 	    }
@@ -1552,7 +2118,9 @@  discard block
 block discarded – undo
1552 2118
 	    )
1553 2119
 	) {
1554 2120
 	    //$buffer = $Common->getData($hosts[$id]);
1555
-	    if ($globalDebug) echo 'Get Data...'."\n";
2121
+	    if ($globalDebug) {
2122
+	    	echo 'Get Data...'."\n";
2123
+	    }
1556 2124
 	    $buffer = $Common->getData($value['host']);
1557 2125
 	    $all_data = json_decode($buffer,true);
1558 2126
 	    if ($buffer != '') {
@@ -1570,12 +2138,16 @@  discard block
 block discarded – undo
1570 2138
 			$data['id_source'] = $id_source;
1571 2139
 			$data['format_source'] = 'blitzortung';
1572 2140
 			$SI->add($data);
1573
-			if ($globalDebug) echo '☈ Lightning added'."\n";
2141
+			if ($globalDebug) {
2142
+				echo '☈ Lightning added'."\n";
2143
+			}
1574 2144
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1575 2145
 			unset($data);
1576 2146
 		    }
1577 2147
 		}
1578
-		if ($globalDebug) echo 'No more data...'."\n";
2148
+		if ($globalDebug) {
2149
+			echo 'No more data...'."\n";
2150
+		}
1579 2151
 		unset($buffer);
1580 2152
 	    }
1581 2153
 	    $last_exec[$id]['last'] = time();
@@ -1587,7 +2159,9 @@  discard block
 block discarded – undo
1587 2159
 	    $write = NULL;
1588 2160
 	    $e = NULL;
1589 2161
 	    $n = socket_select($read, $write, $e, $timeout);
1590
-	    if ($e != NULL) var_dump($e);
2162
+	    if ($e != NULL) {
2163
+	    	var_dump($e);
2164
+	    }
1591 2165
 	    if ($n > 0) {
1592 2166
 		$reset = 0;
1593 2167
 		foreach ($read as $nb => $r) {
@@ -1609,13 +2183,17 @@  discard block
 block discarded – undo
1609 2183
 		    if ($buffer !== FALSE) {
1610 2184
 			if ($format === 'vrstcp') {
1611 2185
 			    $buffer = explode('},{',$buffer);
1612
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2186
+			} else {
2187
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2188
+			}
1613 2189
 		    }
1614 2190
 		    // SBS format is CSV format
1615 2191
 		    if ($buffer !== FALSE && $buffer !== '') {
1616 2192
 			$tt[$format] = 0;
1617 2193
 			if ($format === 'acarssbs3') {
1618
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2194
+			    if ($globalDebug) {
2195
+			    	echo 'ACARS : '.$buffer."\n";
2196
+			    }
1619 2197
 			    $ACARS->add(trim($buffer));
1620 2198
 			    $ACARS->deleteLiveAcarsData();
1621 2199
 			} elseif ($format === 'raw') {
@@ -1624,30 +2202,70 @@  discard block
 block discarded – undo
1624 2202
 			    if (is_array($data)) {
1625 2203
 				$data['datetime'] = date('Y-m-d H:i:s');
1626 2204
 				$data['format_source'] = 'raw';
1627
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1628
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1629
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1630
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2205
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2206
+					$data['source_name'] = $globalSources[$nb]['name'];
2207
+				}
2208
+				if (isset($globalSources[$nb]['sourcestats'])) {
2209
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2210
+				}
2211
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2212
+					$data['noarchive'] = true;
2213
+				}
2214
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2215
+					$SI->add($data);
2216
+				}
1631 2217
 			    }
1632 2218
 			} elseif ($format === 'ais') {
1633 2219
 			    $ais_data = $AIS->parse_line(trim($buffer));
1634 2220
 			    $data = array();
1635
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1636
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1637
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1638
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1639
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1640
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1641
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1642
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1643
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1644
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1645
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1646
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1647
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1648
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1649
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1650
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2221
+			    if (isset($ais_data['ident'])) {
2222
+			    	$data['ident'] = $ais_data['ident'];
2223
+			    }
2224
+			    if (isset($ais_data['mmsi'])) {
2225
+			    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
2226
+			    }
2227
+			    if (isset($ais_data['speed'])) {
2228
+			    	$data['speed'] = $ais_data['speed'];
2229
+			    }
2230
+			    if (isset($ais_data['heading'])) {
2231
+			    	$data['heading'] = $ais_data['heading'];
2232
+			    }
2233
+			    if (isset($ais_data['latitude'])) {
2234
+			    	$data['latitude'] = $ais_data['latitude'];
2235
+			    }
2236
+			    if (isset($ais_data['longitude'])) {
2237
+			    	$data['longitude'] = $ais_data['longitude'];
2238
+			    }
2239
+			    if (isset($ais_data['status'])) {
2240
+			    	$data['status'] = $ais_data['status'];
2241
+			    }
2242
+			    if (isset($ais_data['statusid'])) {
2243
+			    	$data['status_id'] = $ais_data['statusid'];
2244
+			    }
2245
+			    if (isset($ais_data['type'])) {
2246
+			    	$data['type'] = $ais_data['type'];
2247
+			    }
2248
+			    if (isset($ais_data['imo'])) {
2249
+			    	$data['imo'] = $ais_data['imo'];
2250
+			    }
2251
+			    if (isset($ais_data['callsign'])) {
2252
+			    	$data['callsign'] = $ais_data['callsign'];
2253
+			    }
2254
+			    if (isset($ais_data['destination'])) {
2255
+			    	$data['arrival_code'] = $ais_data['destination'];
2256
+			    }
2257
+			    if (isset($ais_data['eta_ts'])) {
2258
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
2259
+			    }
2260
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2261
+			    	$data['noarchive'] = true;
2262
+			    }
2263
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2264
+			    	$data['source_name'] = $globalSources[$nb]['name'];
2265
+			    }
2266
+			    if (isset($globalSources[$nb]['sourcestats'])) {
2267
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2268
+			    }
1651 2269
 
1652 2270
 			    if (isset($ais_data['timestamp'])) {
1653 2271
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1656,7 +2274,9 @@  discard block
 block discarded – undo
1656 2274
 			    }
1657 2275
 			    $data['format_source'] = 'aisnmea';
1658 2276
     			    $data['id_source'] = $id_source;
1659
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
2277
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
2278
+			    	$MI->add($data);
2279
+			    }
1660 2280
 			    unset($data);
1661 2281
                         } elseif ($format === 'flightgearsp') {
1662 2282
                     	    //echo $buffer."\n";
@@ -1674,12 +2294,18 @@  discard block
 block discarded – undo
1674 2294
 				$data['speed'] = round($line[5]*1.94384);
1675 2295
 				$data['datetime'] = date('Y-m-d H:i:s');
1676 2296
 				$data['format_source'] = 'flightgearsp';
1677
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1678
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2297
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2298
+					$data['noarchive'] = true;
2299
+				}
2300
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2301
+					$SI->add($data);
2302
+				}
1679 2303
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1680 2304
 			    }
1681 2305
                         } elseif ($format === 'acars') {
1682
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2306
+                    	    if ($globalDebug) {
2307
+                    	    	echo 'ACARS : '.$buffer."\n";
2308
+                    	    }
1683 2309
 			    $ACARS->add(trim($buffer));
1684 2310
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1685 2311
 			    $ACARS->deleteLiveAcarsData();
@@ -1700,8 +2326,12 @@  discard block
 block discarded – undo
1700 2326
 				    $aircraft_type = $line[10];
1701 2327
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1702 2328
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1703
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1704
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2329
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2330
+				    	$data['noarchive'] = true;
2331
+				    }
2332
+				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2333
+				    	$SI->add($data);
2334
+				    }
1705 2335
 				}
1706 2336
 			    }
1707 2337
 			} elseif ($format === 'beast') {
@@ -1711,28 +2341,62 @@  discard block
 block discarded – undo
1711 2341
 			    foreach($buffer as $all_data) {
1712 2342
 				$line = json_decode('{'.$all_data.'}',true);
1713 2343
 				$data = array();
1714
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1715
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1716
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1717
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1718
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1719
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1720
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2344
+				if (isset($line['Icao'])) {
2345
+					$data['hex'] = $line['Icao'];
2346
+				}
2347
+				// hex
2348
+				if (isset($line['Call'])) {
2349
+					$data['ident'] = $line['Call'];
2350
+				}
2351
+				// ident
2352
+				if (isset($line['Alt'])) {
2353
+					$data['altitude'] = $line['Alt'];
2354
+				}
2355
+				// altitude
2356
+				if (isset($line['Spd'])) {
2357
+					$data['speed'] = $line['Spd'];
2358
+				}
2359
+				// speed
2360
+				if (isset($line['Trak'])) {
2361
+					$data['heading'] = $line['Trak'];
2362
+				}
2363
+				// heading
2364
+				if (isset($line['Lat'])) {
2365
+					$data['latitude'] = $line['Lat'];
2366
+				}
2367
+				// lat
2368
+				if (isset($line['Long'])) {
2369
+					$data['longitude'] = $line['Long'];
2370
+				}
2371
+				// long
1721 2372
 				//$data['verticalrate'] = $line['']; // verticale rate
1722
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2373
+				if (isset($line['Sqk'])) {
2374
+					$data['squawk'] = $line['Sqk'];
2375
+				}
2376
+				// squawk
1723 2377
 				$data['emergency'] = ''; // emergency
1724
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2378
+				if (isset($line['Reg'])) {
2379
+					$data['registration'] = $line['Reg'];
2380
+				}
1725 2381
 				/*
1726 2382
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1727 2383
 				else $data['datetime'] = date('Y-m-d H:i:s');
1728 2384
 				*/
1729 2385
 				$data['datetime'] = date('Y-m-d H:i:s');
1730
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2386
+				if (isset($line['Type'])) {
2387
+					$data['aircraft_icao'] = $line['Type'];
2388
+				}
1731 2389
 		    		$data['format_source'] = 'vrstcp';
1732 2390
 				$data['id_source'] = $id_source;
1733
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1734
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1735
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2391
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2392
+					$data['noarchive'] = true;
2393
+				}
2394
+				if (isset($value['name']) && $value['name'] != '') {
2395
+					$data['source_name'] = $value['name'];
2396
+				}
2397
+				if (isset($data['latitude']) && isset($data['hex'])) {
2398
+					$SI->add($data);
2399
+				}
1736 2400
 				unset($data);
1737 2401
 			    }
1738 2402
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
@@ -1745,22 +2409,46 @@  discard block
 block discarded – undo
1745 2409
     				$data['hex'] = $lined['hexid'];
1746 2410
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1747 2411
     				$data['datetime'] = date('Y-m-d H:i:s');;
1748
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1749
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1750
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1751
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1752
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1753
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1754
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2412
+    				if (isset($lined['ident'])) {
2413
+    					$data['ident'] = $lined['ident'];
2414
+    				}
2415
+    				if (isset($lined['lat'])) {
2416
+    					$data['latitude'] = $lined['lat'];
2417
+    				}
2418
+    				if (isset($lined['lon'])) {
2419
+    					$data['longitude'] = $lined['lon'];
2420
+    				}
2421
+    				if (isset($lined['speed'])) {
2422
+    					$data['speed'] = $lined['speed'];
2423
+    				}
2424
+    				if (isset($lined['squawk'])) {
2425
+    					$data['squawk'] = $lined['squawk'];
2426
+    				}
2427
+    				if (isset($lined['alt'])) {
2428
+    					$data['altitude'] = $lined['alt'];
2429
+    				}
2430
+    				if (isset($lined['heading'])) {
2431
+    					$data['heading'] = $lined['heading'];
2432
+    				}
1755 2433
     				$data['id_source'] = $id_source;
1756 2434
     				$data['format_source'] = 'tsv';
1757
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1758
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1759
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1760
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2435
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2436
+    					$data['source_name'] = $globalSources[$nb]['name'];
2437
+    				}
2438
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2439
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2440
+    				}
2441
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2442
+					$data['noarchive'] = true;
2443
+				}
2444
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2445
+    					$SI->add($data);
2446
+    				}
1761 2447
     				unset($lined);
1762 2448
     				unset($data);
1763
-    			    } else $error = true;
2449
+    			    } else {
2450
+    			    	$error = true;
2451
+    			    }
1764 2452
 			} elseif ($format === 'aprs' && $use_aprs) {
1765 2453
 			    if ($aprs_connect === 0) {
1766 2454
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1786,47 +2474,96 @@  discard block
 block discarded – undo
1786 2474
 				    $aprs_last_tx = time();
1787 2475
 				    $data = array();
1788 2476
 				    //print_r($line);
1789
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1790
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1791
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1792
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1793
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1794
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1795
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1796
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1797
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1798
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2477
+				    if (isset($line['address'])) {
2478
+				    	$data['hex'] = $line['address'];
2479
+				    }
2480
+				    if (isset($line['mmsi'])) {
2481
+				    	$data['mmsi'] = $line['mmsi'];
2482
+				    }
2483
+				    if (isset($line['imo'])) {
2484
+				    	$data['imo'] = $line['imo'];
2485
+				    }
2486
+				    if (isset($line['squawk'])) {
2487
+				    	$data['squawk'] = $line['squawk'];
2488
+				    }
2489
+				    if (isset($line['arrival_code'])) {
2490
+				    	$data['arrival_code'] = $line['arrival_code'];
2491
+				    }
2492
+				    if (isset($line['arrival_date'])) {
2493
+				    	$data['arrival_date'] = $line['arrival_date'];
2494
+				    }
2495
+				    if (isset($line['typeid'])) {
2496
+				    	$data['type_id'] = $line['typeid'];
2497
+				    }
2498
+				    if (isset($line['statusid'])) {
2499
+				    	$data['status_id'] = $line['statusid'];
2500
+				    }
2501
+				    if (isset($line['timestamp'])) {
2502
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2503
+				    } else {
2504
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2505
+				    }
1799 2506
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1800
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2507
+				    if (isset($line['ident'])) {
2508
+				    	$data['ident'] = $line['ident'];
2509
+				    }
1801 2510
 				    $data['latitude'] = $line['latitude'];
1802 2511
 				    $data['longitude'] = $line['longitude'];
1803 2512
 				    //$data['verticalrate'] = $line[16];
1804
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2513
+				    if (isset($line['speed'])) {
2514
+				    	$data['speed'] = $line['speed'];
2515
+				    }
1805 2516
 				    //else $data['speed'] = 0;
1806
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1807
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1808
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2517
+				    if (isset($line['altitude'])) {
2518
+				    	$data['altitude'] = $line['altitude'];
2519
+				    }
2520
+				    if (isset($line['comment'])) {
2521
+				    	$data['comment'] = $line['comment'];
2522
+				    }
2523
+				    if (isset($line['symbol'])) {
2524
+				    	$data['type'] = $line['symbol'];
2525
+				    }
1809 2526
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1810 2527
 				    
1811
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2528
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2529
+				    	$data['heading'] = $line['heading'];
2530
+				    }
1812 2531
 				    //else echo 'No heading...'."\n";
1813 2532
 				    //else $data['heading'] = 0;
1814
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2533
+				    if (isset($line['stealth'])) {
2534
+				    	$data['aircraft_type'] = $line['stealth'];
2535
+				    }
1815 2536
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1816
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1817
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1818
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1819
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2537
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2538
+				    	$data['noarchive'] = true;
2539
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2540
+				    	$data['noarchive'] = false;
2541
+				    }
2542
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2543
+				    	$data['noarchive'] = true;
2544
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2545
+				    	$data['noarchive'] = false;
2546
+				    }
1820 2547
     				    $data['id_source'] = $id_source;
1821
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1822
-				    else $data['format_source'] = 'aprs';
2548
+    				    if (isset($line['format_source'])) {
2549
+    				    	$data['format_source'] = $line['format_source'];
2550
+    				    } else {
2551
+				    	$data['format_source'] = 'aprs';
2552
+				    }
1823 2553
 				    $data['source_name'] = $line['source'];
1824
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1825
-				    else $data['source_type'] = 'flarm';
1826
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2554
+				    if (isset($line['source_type'])) {
2555
+				    	$data['source_type'] = $line['source_type'];
2556
+				    } else {
2557
+				    	$data['source_type'] = 'flarm';
2558
+				    }
2559
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2560
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2561
+    				    }
1827 2562
 				    $currentdate = date('Y-m-d H:i:s');
1828 2563
 				    $aprsdate = strtotime($data['datetime']);
1829
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2564
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2565
+				    	$data['altitude_relative'] = 'AMSL';
2566
+				    }
1830 2567
 				    // Accept data if time <= system time + 20s
1831 2568
 				    //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1832 2569
 				    if (
@@ -1838,7 +2575,9 @@  discard block
 block discarded – undo
1838 2575
 					$send = $SI->add($data);
1839 2576
 				    } elseif ($data['source_type'] === 'ais') {
1840 2577
 					$data['type'] = '';
1841
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2578
+					if (isset($globalMarine) && $globalMarine) {
2579
+						$send = $MI->add($data);
2580
+					}
1842 2581
 				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1843 2582
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1844 2583
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
@@ -1846,8 +2585,12 @@  discard block
 block discarded – undo
1846 2585
 					    $line['symbol'] === 'Glider' || 
1847 2586
 					    $line['symbol'] === 'No. Plane' || 
1848 2587
 					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1849
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1850
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2588
+					    if ($line['symbol'] === 'Ballon') {
2589
+					    	$data['aircraft_icao'] = 'BALL';
2590
+					    }
2591
+					    if ($line['symbol'] === 'Glider') {
2592
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2593
+					    }
1851 2594
 					    $send = $SI->add($data);
1852 2595
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1853 2596
 					    $line['symbol'] === 'Yacht (Sail)' || 
@@ -1878,9 +2621,13 @@  discard block
 block discarded – undo
1878 2621
 				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1879 2622
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1880 2623
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1881
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2624
+					if (isset($globalTracker) && $globalTracker) {
2625
+						$send = $TI->add($data);
2626
+					}
1882 2627
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1883
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2628
+					if (!isset($data['altitude'])) {
2629
+						$data['altitude'] = 0;
2630
+					}
1884 2631
 					$Source->deleteOldLocationByType('gs');
1885 2632
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1886 2633
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1889,7 +2636,9 @@  discard block
 block discarded – undo
1889 2636
 					}
1890 2637
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1891 2638
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1892
-					if ($globalDebug) echo '# Weather Station added'."\n";
2639
+					if ($globalDebug) {
2640
+						echo '# Weather Station added'."\n";
2641
+					}
1893 2642
 					$Source->deleteOldLocationByType('wx');
1894 2643
 					$weather_data = json_encode($line);
1895 2644
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1899,7 +2648,9 @@  discard block
 block discarded – undo
1899 2648
 					}
1900 2649
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1901 2650
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1902
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2651
+					if ($globalDebug) {
2652
+						echo '☈ Lightning added'."\n";
2653
+					}
1903 2654
 					$Source->deleteOldLocationByType('lightning');
1904 2655
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1905 2656
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1911,8 +2662,7 @@  discard block
 block discarded – undo
1911 2662
 				    	print_r($line);
1912 2663
 				    }
1913 2664
 				    unset($data);
1914
-				}
1915
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2665
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1916 2666
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1917 2667
 				}
1918 2668
 				/*
@@ -1921,7 +2671,9 @@  discard block
 block discarded – undo
1921 2671
 				}
1922 2672
 				*/
1923 2673
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1924
-				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2674
+				elseif ($line === true && $globalDebug) {
2675
+					echo '!! Failed : '.$buffer."!!\n";
2676
+				}
1925 2677
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1926 2678
 					$Source->deleteOldLocationByType('lightning');
1927 2679
 					$Source->deleteOldLocationByType('wx');
@@ -1957,27 +2709,47 @@  discard block
 block discarded – undo
1957 2709
     				$data['ground'] = $line[21];
1958 2710
     				$data['emergency'] = $line[19];
1959 2711
     				$data['format_source'] = 'sbs';
1960
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1961
-				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
1962
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1963
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2712
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2713
+					$data['source_name'] = $globalSources[$nb]['name'];
2714
+				} elseif ($line[0] == 'MLAT') {
2715
+					$data['source_name'] = 'MLAT';
2716
+				}
2717
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2718
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2719
+    				}
2720
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2721
+					$data['noarchive'] = true;
2722
+				}
1964 2723
     				$data['id_source'] = $id_source;
1965
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1966
-    				else $error = true;
2724
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2725
+    					$send = $SI->add($data);
2726
+    				} else {
2727
+    					$error = true;
2728
+    				}
1967 2729
     				unset($data);
1968
-    			    } else $error = true;
2730
+    			    } else {
2731
+    			    	$error = true;
2732
+    			    }
1969 2733
 			    if ($error) {
1970 2734
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1971
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2735
+					if ($globalDebug) {
2736
+						echo "Not a message. Ignoring... \n";
2737
+					}
1972 2738
 				} else {
1973
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2739
+					if ($globalDebug) {
2740
+						echo "Wrong line format. Ignoring... \n";
2741
+					}
1974 2742
 					if ($globalDebug) {
1975 2743
 						echo $buffer;
1976 2744
 						//print_r($line);
1977 2745
 					}
1978 2746
 					//socket_close($r);
1979
-					if ($globalDebug) echo "Reconnect after an error...\n";
1980
-					if ($format === 'aprs') $aprs_connect = 0;
2747
+					if ($globalDebug) {
2748
+						echo "Reconnect after an error...\n";
2749
+					}
2750
+					if ($format === 'aprs') {
2751
+						$aprs_connect = 0;
2752
+					}
1981 2753
 					$sourceer[$nb] = $globalSources[$nb];
1982 2754
 					connect_all($sourceer);
1983 2755
 					$sourceer = array();
@@ -1985,10 +2757,14 @@  discard block
 block discarded – undo
1985 2757
 			    }
1986 2758
 			}
1987 2759
 			// Sleep for xxx microseconds
1988
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2760
+			if (isset($globalSBSSleep)) {
2761
+				usleep($globalSBSSleep);
2762
+			}
1989 2763
 		    } else {
1990 2764
 			if ($format === 'flightgearmp') {
1991
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2765
+			    	if ($globalDebug) {
2766
+			    		echo "Reconnect FlightGear MP...";
2767
+			    	}
1992 2768
 				//@socket_close($r);
1993 2769
 				sleep($globalMinFetch);
1994 2770
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1997,10 +2773,15 @@  discard block
 block discarded – undo
1997 2773
 				break;
1998 2774
 				
1999 2775
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2000
-			    if (isset($tt[$format])) $tt[$format]++;
2001
-			    else $tt[$format] = 0;
2776
+			    if (isset($tt[$format])) {
2777
+			    	$tt[$format]++;
2778
+			    } else {
2779
+			    	$tt[$format] = 0;
2780
+			    }
2002 2781
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
2003
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2782
+				if ($globalDebug) {
2783
+					echo "ERROR : Reconnect ".$format."...";
2784
+				}
2004 2785
 				//@socket_close($r);
2005 2786
 				sleep(2);
2006 2787
 				$aprs_connect = 0;
@@ -2018,11 +2799,17 @@  discard block
 block discarded – undo
2018 2799
 	    } else {
2019 2800
 		$error = socket_strerror(socket_last_error());
2020 2801
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2021
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2022
-			if (isset($globalDebug)) echo "Restarting...\n";
2802
+			if ($globalDebug) {
2803
+				echo "ERROR : socket_select give this error ".$error . "\n";
2804
+			}
2805
+			if (isset($globalDebug)) {
2806
+				echo "Restarting...\n";
2807
+			}
2023 2808
 			// Restart the script if possible
2024 2809
 			if (is_array($sockets)) {
2025
-			    if ($globalDebug) echo "Shutdown all sockets...";
2810
+			    if ($globalDebug) {
2811
+			    	echo "Shutdown all sockets...";
2812
+			    }
2026 2813
 			    
2027 2814
 			    foreach ($sockets as $sock) {
2028 2815
 				@socket_shutdown($sock,2);
@@ -2030,25 +2817,45 @@  discard block
 block discarded – undo
2030 2817
 			    }
2031 2818
 			    
2032 2819
 			}
2033
-			if ($globalDebug) echo "Waiting...";
2820
+			if ($globalDebug) {
2821
+				echo "Waiting...";
2822
+			}
2034 2823
 			sleep(2);
2035 2824
 			$time = time();
2036 2825
 			//connect_all($hosts);
2037 2826
 			$aprs_connect = 0;
2038
-			if ($reset%5 === 0) sleep(20);
2039
-			if ($reset%10 === 0) sleep(100);
2040
-			if ($reset%20 === 0) sleep(200);
2041
-			if ($reset > 100) exit('Too many attempts...');
2042
-			if ($globalDebug) echo "Restart all connections...";
2827
+			if ($reset%5 === 0) {
2828
+				sleep(20);
2829
+			}
2830
+			if ($reset%10 === 0) {
2831
+				sleep(100);
2832
+			}
2833
+			if ($reset%20 === 0) {
2834
+				sleep(200);
2835
+			}
2836
+			if ($reset > 100) {
2837
+				exit('Too many attempts...');
2838
+			}
2839
+			if ($globalDebug) {
2840
+				echo "Restart all connections...";
2841
+			}
2043 2842
 			connect_all($globalSources);
2044 2843
 		}
2045 2844
 	    }
2046 2845
 	}
2047 2846
 	if ($globalDaemon === false) {
2048
-	    if ($globalDebug) echo 'Check all...'."\n";
2049
-	    if (isset($SI)) $SI->checkAll();
2050
-	    if (isset($TI)) $TI->checkAll();
2051
-	    if (isset($MI)) $MI->checkAll();
2847
+	    if ($globalDebug) {
2848
+	    	echo 'Check all...'."\n";
2849
+	    }
2850
+	    if (isset($SI)) {
2851
+	    	$SI->checkAll();
2852
+	    }
2853
+	    if (isset($TI)) {
2854
+	    	$TI->checkAll();
2855
+	    }
2856
+	    if (isset($MI)) {
2857
+	    	$MI->checkAll();
2858
+	    }
2052 2859
 	}
2053 2860
     }
2054 2861
 }
Please login to merge, or discard this patch.
require/class.MarineLive.php 2 patches
Spacing   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -17,33 +17,33 @@  discard block
 block discarded – undo
17 17
 	* @param Array $filter the filter
18 18
 	* @return Array the SQL part
19 19
 	*/
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
23 23
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
24 24
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
25 25
 				$filters = $globalStatsFilters[$globalFilterName];
26 26
 			} else {
27
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
27
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
28 28
 			}
29 29
 		}
30 30
 		if (isset($filter[0]['source'])) {
31
-			$filters = array_merge($filters,$filter);
31
+			$filters = array_merge($filters, $filter);
32 32
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
34 34
 		$filter_query_join = '';
35 35
 		$filter_query_where = '';
36
-		foreach($filters as $flt) {
36
+		foreach ($filters as $flt) {
37 37
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
38 38
 				if (isset($flt['source'])) {
39
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
39
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
40 40
 				} else {
41
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
41
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
42 42
 				}
43 43
 			}
44 44
 		}
45 45
 		if (isset($filter['source']) && !empty($filter['source'])) {
46
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
46
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
47 47
 		}
48 48
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
49 49
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -81,15 +81,15 @@  discard block
 block discarded – undo
81 81
 					$filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
82 82
 				}
83 83
 			}
84
-			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
84
+			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
85 85
 		}
86 86
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
87
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
87
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
88 88
 		}
89 89
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
90 90
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
91 91
 		if ($filter_query_where != '') {
92
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
92
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
93 93
 		}
94 94
 		$filter_query = $filter_query_join.$filter_query_where;
95 95
 		return $filter_query;
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 		if ($limit != '')
113 113
 		{
114 114
 			$limit_array = explode(',', $limit);
115
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
116
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
115
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
116
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
117 117
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
118 118
 			{
119 119
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
129 129
 			}
130 130
 		}
131
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
131
+		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
132 132
 
133 133
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
134 134
 		if ($globalDBdriver == 'mysql') {
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 		} else {
138 138
 			$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query;
139 139
 		}
140
-		$spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true);
140
+		$spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true);
141 141
 
142 142
 		return $spotter_array;
143 143
 	}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		global $globalDBdriver, $globalLiveInterval;
154 154
 		date_default_timezone_set('UTC');
155 155
 
156
-		$filter_query = $this->getFilter($filter,true,true);
156
+		$filter_query = $this->getFilter($filter, true, true);
157 157
 
158 158
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
159 159
 		if ($globalDBdriver == 'mysql') {
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 		try {
168 168
 			$sth = $this->db->prepare($query);
169 169
 			$sth->execute();
170
-		} catch(PDOException $e) {
170
+		} catch (PDOException $e) {
171 171
 			echo $e->getMessage();
172 172
 			die;
173 173
 		}
@@ -182,26 +182,26 @@  discard block
 block discarded – undo
182 182
 	* @return Array the spotter information
183 183
 	*
184 184
 	*/
185
-	public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false, $id = '')
185
+	public function getMinLastLiveMarineData($coord = array(), $filter = array(), $limit = false, $id = '')
186 186
 	{
187 187
 		global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive;
188 188
 		date_default_timezone_set('UTC');
189 189
 		$usecoord = false;
190 190
 		if (is_array($coord) && !empty($coord)) {
191
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
192
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
193
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
194
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
191
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
192
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
193
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
194
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
195 195
 			$usecoord = true;
196 196
 		}
197
-		$id = filter_var($id,FILTER_SANITIZE_STRING);
198
-		$filter_query = $this->getFilter($filter,true,true);
197
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
198
+		$filter_query = $this->getFilter($filter, true, true);
199 199
 
200 200
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
201 201
 		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
202 202
 		if ($globalDBdriver == 'mysql') {
203 203
 			if (isset($globalArchive) && $globalArchive === TRUE) {
204
-				$query  = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id 
204
+				$query = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id 
205 205
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
206 206
 				if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
207 207
 				if ($id != '') $query .= "OR marine_archive.fammarine_id = :id ";
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 				    ORDER BY fammarine_id, date";
216 216
 				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
217 217
 			} else {
218
-				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id 
218
+				$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id 
219 219
 				    FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date ";
220 220
 				if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
221 221
 				if ($id != '') $query .= "OR marine_live.fammarine_id = :id ";
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 			}
226 226
 		} else {
227 227
 			if (isset($globalArchive) && $globalArchive === TRUE) {
228
-				$query  = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id 
228
+				$query = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id 
229 229
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
230 230
 				if ($usecoord) $query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
231 231
 				if ($id != '') $query .= "OR marine_archive.fammarine_id = :id ";
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 		try {
253 253
 			$sth = $this->db->prepare($query);
254 254
 			$sth->execute($query_values);
255
-		} catch(PDOException $e) {
255
+		} catch (PDOException $e) {
256 256
 			echo $e->getMessage();
257 257
 			die;
258 258
 		}
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	public function getLiveMarineCount($filter = array())
270 270
 	{
271 271
 		global $globalDBdriver, $globalLiveInterval;
272
-		$filter_query = $this->getFilter($filter,true,true);
272
+		$filter_query = $this->getFilter($filter, true, true);
273 273
 
274 274
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
275 275
 		if ($globalDBdriver == 'mysql') {
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 		try {
281 281
 			$sth = $this->db->prepare($query);
282 282
 			$sth->execute();
283
-		} catch(PDOException $e) {
283
+		} catch (PDOException $e) {
284 284
 			echo $e->getMessage();
285 285
 			die;
286 286
 		}
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
 		$filter_query = $this->getFilter($filter);
304 304
 
305 305
 		if (is_array($coord)) {
306
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
307
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
308
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
309
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
306
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
307
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
308
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
309
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
310 310
 		} else return array();
311 311
 		if ($globalDBdriver == 'mysql') {
312 312
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id ORDER BY date DESC'.$filter_query;
@@ -328,13 +328,13 @@  discard block
 block discarded – undo
328 328
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
329 329
 		$Marine = new Marine($this->db);
330 330
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
331
-		$filter_query = $this->getFilter($filter,true,true);
331
+		$filter_query = $this->getFilter($filter, true, true);
332 332
 
333 333
 		if (is_array($coord)) {
334
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
335
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
336
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
337
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
334
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
335
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
336
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
337
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
338 338
 		} else return array();
339 339
 		/*
340 340
 		if ($globalDBdriver == 'mysql') {
@@ -349,13 +349,13 @@  discard block
 block discarded – undo
349 349
 		*/
350 350
 		if ($globalDBdriver == 'mysql') {
351 351
 			if (isset($globalArchive) && $globalArchive === TRUE) {
352
-				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id 
352
+				$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id 
353 353
 				    FROM marine_live 
354 354
 				    '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= marine_live.date 
355 355
 				    AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
356 356
 				    AND marine_live.latitude <> 0 AND marine_live.longitude <> 0 ORDER BY date DESC';
357 357
 			} else {
358
-				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id 
358
+				$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id 
359 359
 				    FROM marine_live 
360 360
 				    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate 
361 361
 				    FROM marine_live l 
@@ -367,14 +367,14 @@  discard block
 block discarded – undo
367 367
 			}
368 368
 		} else {
369 369
 			if (isset($globalArchive) && $globalArchive === TRUE) {
370
-				$query  = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id 
370
+				$query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id 
371 371
 				    FROM marine_live 
372 372
 				    ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date 
373 373
 				    AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
374 374
 				    AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
375 375
 				    AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' ORDER BY date DESC";
376 376
 			} else {
377
-				$query  = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id 
377
+				$query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id 
378 378
 				    FROM marine_live 
379 379
 				    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate 
380 380
 				    FROM marine_live l 
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
                 if ($interval == '1m')
432 432
                 {
433 433
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
434
-                } else if ($interval == '15m'){
434
+                } else if ($interval == '15m') {
435 435
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
436 436
                 } 
437 437
             }
@@ -439,14 +439,14 @@  discard block
 block discarded – undo
439 439
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
440 440
         }
441 441
 
442
-                $query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
442
+                $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
443 443
                    WHERE marine_live.latitude <> '' 
444 444
                                    AND marine_live.longitude <> '' 
445 445
                    ".$additional_query."
446 446
                    HAVING distance < :radius  
447 447
                                    ORDER BY distance";
448 448
 
449
-                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
449
+                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
450 450
 
451 451
                 return $spotter_array;
452 452
         }
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
 		date_default_timezone_set('UTC');
465 465
 
466 466
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
467
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
467
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
468 468
 
469
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
469
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true);
470 470
 
471 471
 		return $spotter_array;
472 472
 	}
@@ -477,14 +477,14 @@  discard block
 block discarded – undo
477 477
 	* @return Array the spotter information
478 478
 	*
479 479
 	*/
480
-	public function getDateLiveMarineDataByIdent($ident,$date)
480
+	public function getDateLiveMarineDataByIdent($ident, $date)
481 481
 	{
482 482
 		$Marine = new Marine($this->db);
483 483
 		date_default_timezone_set('UTC');
484 484
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
485 485
 		$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
486
-		$date = date('c',$date);
487
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
486
+		$date = date('c', $date);
487
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
488 488
 		return $spotter_array;
489 489
 	}
490 490
 
@@ -494,14 +494,14 @@  discard block
 block discarded – undo
494 494
 	* @return Array the spotter information
495 495
 	*
496 496
 	*/
497
-	public function getDateLiveMarineDataByMMSI($mmsi,$date)
497
+	public function getDateLiveMarineDataByMMSI($mmsi, $date)
498 498
 	{
499 499
 		$Marine = new Marine($this->db);
500 500
 		date_default_timezone_set('UTC');
501 501
 		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
502 502
 		$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.mmsi = :mmsi AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
503
-		$date = date('c',$date);
504
-		$spotter_array = $Marine->getDataFromDB($query,array(':mmsi' => $mmsi,':date' => $date));
503
+		$date = date('c', $date);
504
+		$spotter_array = $Marine->getDataFromDB($query, array(':mmsi' => $mmsi, ':date' => $date));
505 505
 		return $spotter_array;
506 506
 	}
507 507
 
@@ -517,9 +517,9 @@  discard block
 block discarded – undo
517 517
 		date_default_timezone_set('UTC');
518 518
 
519 519
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
520
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
520
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
521 521
 
522
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
522
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true);
523 523
 
524 524
 		return $spotter_array;
525 525
 	}
@@ -530,15 +530,15 @@  discard block
 block discarded – undo
530 530
 	* @return Array the spotter information
531 531
 	*
532 532
 	*/
533
-	public function getDateLiveMarineDataById($id,$date)
533
+	public function getDateLiveMarineDataById($id, $date)
534 534
 	{
535 535
 		$Marine = new Marine($this->db);
536 536
 		date_default_timezone_set('UTC');
537 537
 
538 538
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
539
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
540
-                $date = date('c',$date);
541
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
539
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
540
+                $date = date('c', $date);
541
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
542 542
 
543 543
 		return $spotter_array;
544 544
 	}
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
 	* @return Array the spotter information
551 551
 	*
552 552
 	*/
553
-	public function getAllLiveMarineDataById($id,$liveinterval = false)
553
+	public function getAllLiveMarineDataById($id, $liveinterval = false)
554 554
 	{
555 555
 		global $globalDBdriver, $globalLiveInterval;
556 556
 		date_default_timezone_set('UTC');
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 		try {
570 570
 			$sth = $this->db->prepare($query);
571 571
 			$sth->execute(array(':id' => $id));
572
-		} catch(PDOException $e) {
572
+		} catch (PDOException $e) {
573 573
 			echo $e->getMessage();
574 574
 			die;
575 575
 		}
@@ -587,12 +587,12 @@  discard block
 block discarded – undo
587 587
 	{
588 588
 		date_default_timezone_set('UTC');
589 589
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
590
-		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
590
+		$query = self::$global_query.' WHERE marine_live.ident = :ident';
591 591
     		try {
592 592
 			
593 593
 			$sth = $this->db->prepare($query);
594 594
 			$sth->execute(array(':ident' => $ident));
595
-		} catch(PDOException $e) {
595
+		} catch (PDOException $e) {
596 596
 			echo $e->getMessage();
597 597
 			die;
598 598
 		}
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 			
623 623
 			$sth = $this->db->prepare($query);
624 624
 			$sth->execute();
625
-		} catch(PDOException $e) {
625
+		} catch (PDOException $e) {
626 626
 			return "error";
627 627
 		}
628 628
 
@@ -645,14 +645,14 @@  discard block
 block discarded – undo
645 645
 				
646 646
 				$sth = $this->db->prepare($query);
647 647
 				$sth->execute();
648
-			} catch(PDOException $e) {
648
+			} catch (PDOException $e) {
649 649
 				return "error";
650 650
 			}
651 651
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
652 652
                         $i = 0;
653
-                        $j =0;
653
+                        $j = 0;
654 654
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
655
-			foreach($all as $row)
655
+			foreach ($all as $row)
656 656
 			{
657 657
 				$i++;
658 658
 				$j++;
@@ -660,9 +660,9 @@  discard block
 block discarded – undo
660 660
 					if ($globalDebug) echo ".";
661 661
 				    	try {
662 662
 						
663
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
663
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
664 664
 						$sth->execute();
665
-					} catch(PDOException $e) {
665
+					} catch (PDOException $e) {
666 666
 						return "error";
667 667
 					}
668 668
                                 	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
@@ -673,9 +673,9 @@  discard block
 block discarded – undo
673 673
 			if ($i > 0) {
674 674
     				try {
675 675
 					
676
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
676
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
677 677
 					$sth->execute();
678
-				} catch(PDOException $e) {
678
+				} catch (PDOException $e) {
679 679
 					return "error";
680 680
 				}
681 681
 			}
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 				
689 689
 				$sth = $this->db->prepare($query);
690 690
 				$sth->execute();
691
-			} catch(PDOException $e) {
691
+			} catch (PDOException $e) {
692 692
 				return "error";
693 693
 			}
694 694
 /*			$query_delete = "DELETE FROM marine_live WHERE fammarine_id IN (";
@@ -736,13 +736,13 @@  discard block
 block discarded – undo
736 736
 	public function deleteLiveMarineDataByIdent($ident)
737 737
 	{
738 738
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
739
-		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
739
+		$query = 'DELETE FROM marine_live WHERE ident = :ident';
740 740
         
741 741
     		try {
742 742
 			
743 743
 			$sth = $this->db->prepare($query);
744 744
 			$sth->execute(array(':ident' => $ident));
745
-		} catch(PDOException $e) {
745
+		} catch (PDOException $e) {
746 746
 			return "error";
747 747
 		}
748 748
 
@@ -758,13 +758,13 @@  discard block
 block discarded – undo
758 758
 	public function deleteLiveMarineDataById($id)
759 759
 	{
760 760
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
761
-		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
761
+		$query = 'DELETE FROM marine_live WHERE fammarine_id = :id';
762 762
         
763 763
     		try {
764 764
 			
765 765
 			$sth = $this->db->prepare($query);
766 766
 			$sth->execute(array(':id' => $id));
767
-		} catch(PDOException $e) {
767
+		} catch (PDOException $e) {
768 768
 			return "error";
769 769
 		}
770 770
 
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 	*/
781 781
 	public function getAllRaces()
782 782
 	{
783
-		$query  = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name';
783
+		$query = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name';
784 784
 		$sth = $this->db->prepare($query);
785 785
 		$sth->execute();
786 786
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -796,13 +796,13 @@  discard block
 block discarded – undo
796 796
 	{
797 797
 		global $globalDBdriver, $globalTimezone;
798 798
 		if ($globalDBdriver == 'mysql') {
799
-			$query  = 'SELECT marine_live.ident FROM marine_live 
799
+			$query = 'SELECT marine_live.ident FROM marine_live 
800 800
 				WHERE marine_live.ident = :ident 
801 801
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
802 802
 				AND marine_live.date < UTC_TIMESTAMP()';
803 803
 			$query_data = array(':ident' => $ident);
804 804
 		} else {
805
-			$query  = "SELECT marine_live.ident FROM marine_live 
805
+			$query = "SELECT marine_live.ident FROM marine_live 
806 806
 				WHERE marine_live.ident = :ident 
807 807
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
808 808
 				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -811,8 +811,8 @@  discard block
 block discarded – undo
811 811
 		
812 812
 		$sth = $this->db->prepare($query);
813 813
 		$sth->execute($query_data);
814
-		$ident_result='';
815
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
814
+		$ident_result = '';
815
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
816 816
 		{
817 817
 			$ident_result = $row['ident'];
818 818
 		}
@@ -829,13 +829,13 @@  discard block
 block discarded – undo
829 829
 	{
830 830
 		global $globalDBdriver, $globalTimezone;
831 831
 		if ($globalDBdriver == 'mysql') {
832
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
832
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
833 833
 				WHERE marine_live.ident = :ident 
834 834
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
835 835
 //				AND marine_live.date < UTC_TIMESTAMP()";
836 836
 			$query_data = array(':ident' => $ident);
837 837
 		} else {
838
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
838
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
839 839
 				WHERE marine_live.ident = :ident 
840 840
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
841 841
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -844,8 +844,8 @@  discard block
 block discarded – undo
844 844
 		
845 845
 		$sth = $this->db->prepare($query);
846 846
 		$sth->execute($query_data);
847
-		$ident_result='';
848
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
847
+		$ident_result = '';
848
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
849 849
 		{
850 850
 			$ident_result = $row['fammarine_id'];
851 851
 		}
@@ -862,13 +862,13 @@  discard block
 block discarded – undo
862 862
 	{
863 863
 		global $globalDBdriver, $globalTimezone;
864 864
 		if ($globalDBdriver == 'mysql') {
865
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
865
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
866 866
 				WHERE marine_live.fammarine_id = :id 
867 867
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
868 868
 //				AND marine_live.date < UTC_TIMESTAMP()";
869 869
 			$query_data = array(':id' => $id);
870 870
 		} else {
871
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
871
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
872 872
 				WHERE marine_live.fammarine_id = :id 
873 873
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
874 874
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -877,8 +877,8 @@  discard block
 block discarded – undo
877 877
 		
878 878
 		$sth = $this->db->prepare($query);
879 879
 		$sth->execute($query_data);
880
-		$ident_result='';
881
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
880
+		$ident_result = '';
881
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
882 882
 		{
883 883
 			$ident_result = $row['fammarine_id'];
884 884
 		}
@@ -895,13 +895,13 @@  discard block
 block discarded – undo
895 895
 	{
896 896
 		global $globalDBdriver, $globalTimezone;
897 897
 		if ($globalDBdriver == 'mysql') {
898
-			$query  = 'SELECT marine_live.fammarine_id FROM marine_live 
898
+			$query = 'SELECT marine_live.fammarine_id FROM marine_live 
899 899
 				WHERE marine_live.mmsi = :mmsi 
900 900
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
901 901
 //				AND marine_live.date < UTC_TIMESTAMP()";
902 902
 			$query_data = array(':mmsi' => $mmsi);
903 903
 		} else {
904
-			$query  = "SELECT marine_live.fammarine_id FROM marine_live 
904
+			$query = "SELECT marine_live.fammarine_id FROM marine_live 
905 905
 				WHERE marine_live.mmsi = :mmsi 
906 906
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
907 907
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -910,8 +910,8 @@  discard block
 block discarded – undo
910 910
 		
911 911
 		$sth = $this->db->prepare($query);
912 912
 		$sth->execute($query_data);
913
-		$ident_result='';
914
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
913
+		$ident_result = '';
914
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
915 915
 		{
916 916
 			$ident_result = $row['fammarine_id'];
917 917
 		}
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 	* @return String success or false
930 930
 	*
931 931
 	*/
932
-	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '')
932
+	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '')
933 933
 	{
934 934
 		global $globalURL, $globalArchive, $globalDebug;
935 935
 		$Common = new Common();
@@ -981,37 +981,37 @@  discard block
 block discarded – undo
981 981
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
982 982
 
983 983
         
984
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
985
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
986
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
987
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
988
-		$distance = filter_var($distance,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
989
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
990
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
991
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
992
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
993
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
994
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
995
-		$typeid = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT);
996
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
997
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
998
-		$statusid = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT);
999
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
1000
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
1001
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
1002
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
1003
-		$captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING);
1004
-		$captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING);
1005
-		$race_id = filter_var($race_id,FILTER_SANITIZE_STRING);
1006
-		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
1007
-		$race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT);
1008
-		$race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
984
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
985
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
986
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
987
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
988
+		$distance = filter_var($distance, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
989
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
990
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
991
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
992
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
993
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
994
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
995
+		$typeid = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT);
996
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
997
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
998
+		$statusid = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT);
999
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
1000
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
1001
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
1002
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
1003
+		$captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING);
1004
+		$captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING);
1005
+		$race_id = filter_var($race_id, FILTER_SANITIZE_STRING);
1006
+		$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
1007
+		$race_rank = filter_var($race_rank, FILTER_SANITIZE_NUMBER_INT);
1008
+		$race_time = filter_var($race_time, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1009 1009
 		if ($typeid == '') $typeid = NULL;
1010 1010
 		if ($statusid == '') $statusid = NULL;
1011 1011
 		if ($distance == '') $distance = NULL;
1012 1012
 
1013 1013
             	//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1014
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1014
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1015 1015
             	if ($arrival_date == '') $arrival_date = NULL;
1016 1016
             	$query = '';
1017 1017
 		if ($globalArchive) {
@@ -1020,19 +1020,19 @@  discard block
 block discarded – undo
1020 1020
 		}
1021 1021
 		$query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) 
1022 1022
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:typeid,:status,:statusid,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name,:distance,:race_rank,:race_time)';
1023
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':typeid' => $typeid,':status' => $status,':statusid' => $statusid,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_time' => $race_time,':race_rank' => $race_rank);
1023
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':typeid' => $typeid, ':status' => $status, ':statusid' => $statusid, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_time' => $race_time, ':race_rank' => $race_rank);
1024 1024
 		try {
1025 1025
 			$sth = $this->db->prepare($query);
1026 1026
 			$sth->execute($query_values);
1027 1027
 			$sth->closeCursor();
1028
-		} catch(PDOException $e) {
1028
+		} catch (PDOException $e) {
1029 1029
 			return "error : ".$e->getMessage();
1030 1030
 		}
1031 1031
 		
1032 1032
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1033 1033
 			if ($globalDebug) echo '(Add to Marine archive : ';
1034 1034
 			$MarineArchive = new MarineArchive($this->db);
1035
-			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source, $source_name, $over_country,$captain_id,$captain_name,$race_id,$race_name,$distance,$race_rank,$race_time);
1035
+			$result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country, $captain_id, $captain_name, $race_id, $race_name, $distance, $race_rank, $race_time);
1036 1036
 			if ($globalDebug) echo $result.')';
1037 1037
 		}
1038 1038
 		return "success";
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 
1041 1041
 	public function getOrderBy()
1042 1042
 	{
1043
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
1043
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
1044 1044
 		return $orderby;
1045 1045
 	}
1046 1046
 
Please login to merge, or discard this patch.
Braces   +140 added lines, -47 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (MarineLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (MarineLive)');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -86,8 +90,11 @@  discard block
 block discarded – undo
86 90
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
87 91
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
88 92
 		}
89
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
90
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
93
+		if ($filter_query_where == '' && $where) {
94
+			$filter_query_where = ' WHERE';
95
+		} elseif ($filter_query_where != '' && $and) {
96
+			$filter_query_where .= ' AND';
97
+		}
91 98
 		if ($filter_query_where != '') {
92 99
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
93 100
 		}
@@ -128,9 +135,13 @@  discard block
 block discarded – undo
128 135
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
129 136
 			}
130 137
 		}
131
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
138
+		if ($orderby_query == '') {
139
+			$orderby_query= ' ORDER BY date DESC';
140
+		}
132 141
 
133
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
142
+		if (!isset($globalLiveInterval)) {
143
+			$globalLiveInterval = '200';
144
+		}
134 145
 		if ($globalDBdriver == 'mysql') {
135 146
 			//$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate";
136 147
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -155,7 +166,9 @@  discard block
 block discarded – undo
155 166
 
156 167
 		$filter_query = $this->getFilter($filter,true,true);
157 168
 
158
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
169
+		if (!isset($globalLiveInterval)) {
170
+			$globalLiveInterval = '200';
171
+		}
159 172
 		if ($globalDBdriver == 'mysql') {
160 173
 			$query  = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id 
161 174
 			FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0";
@@ -197,58 +210,96 @@  discard block
 block discarded – undo
197 210
 		$id = filter_var($id,FILTER_SANITIZE_STRING);
198 211
 		$filter_query = $this->getFilter($filter,true,true);
199 212
 
200
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
201
-		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
213
+		if (!isset($globalLiveInterval)) {
214
+			$globalLiveInterval = '200';
215
+		}
216
+		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') {
217
+			$globalMap3DMarinesLimit = '300';
218
+		}
202 219
 		if ($globalDBdriver == 'mysql') {
203 220
 			if (isset($globalArchive) && $globalArchive === TRUE) {
204 221
 				$query  = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id 
205 222
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
206
-				if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
207
-				if ($id != '') $query .= "OR marine_archive.fammarine_id = :id ";
223
+				if ($usecoord) {
224
+					$query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
225
+				}
226
+				if ($id != '') {
227
+					$query .= "OR marine_archive.fammarine_id = :id ";
228
+				}
208 229
 				$query .= "UNION
209 230
 				    SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id 
210 231
 				    FROM marine_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date";
211
-				if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
212
-				if ($id != '') $query .= "OR marine_live.fammarine_id = :id ";
232
+				if ($usecoord) {
233
+					$query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
234
+				}
235
+				if ($id != '') {
236
+					$query .= "OR marine_live.fammarine_id = :id ";
237
+				}
213 238
 				$query .= ") AS marine 
214 239
 				    WHERE latitude <> '0' AND longitude <> '0' 
215 240
 				    ORDER BY fammarine_id, date";
216
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
241
+				if ($limit) {
242
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
243
+				}
217 244
 			} else {
218 245
 				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id 
219 246
 				    FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date ";
220
-				if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
221
-				if ($id != '') $query .= "OR marine_live.fammarine_id = :id ";
247
+				if ($usecoord) {
248
+					$query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
249
+				}
250
+				if ($id != '') {
251
+					$query .= "OR marine_live.fammarine_id = :id ";
252
+				}
222 253
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
223 254
 				ORDER BY marine_live.fammarine_id, marine_live.date";
224
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
255
+				if ($limit) {
256
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
257
+				}
225 258
 			}
226 259
 		} else {
227 260
 			if (isset($globalArchive) && $globalArchive === TRUE) {
228 261
 				$query  = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id 
229 262
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
230
-				if ($usecoord) $query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
231
-				if ($id != '') $query .= "OR marine_archive.fammarine_id = :id ";
263
+				if ($usecoord) {
264
+					$query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
265
+				}
266
+				if ($id != '') {
267
+					$query .= "OR marine_archive.fammarine_id = :id ";
268
+				}
232 269
 				$query .= "UNION
233 270
 				    SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id 
234 271
 				    FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date";
235
-				if ($usecoord) $query .= " AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
236
-				if ($id != '') $query .= " OR marine_live.fammarine_id = :id";
272
+				if ($usecoord) {
273
+					$query .= " AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
274
+				}
275
+				if ($id != '') {
276
+					$query .= " OR marine_live.fammarine_id = :id";
277
+				}
237 278
 				$query .= ") AS marine WHERE latitude <> '0' AND longitude <> '0' ";
238 279
 				$query .= "ORDER BY fammarine_id, date";
239
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
280
+				if ($limit) {
281
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
282
+				}
240 283
 			} else {
241 284
 				$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_archive.race_id 
242 285
 				    FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date ";
243
-				if ($usecoord) $query .= "AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
244
-				if ($id != '') $query .= "OR marine_live.fammarine_id = :id ";
286
+				if ($usecoord) {
287
+					$query .= "AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
288
+				}
289
+				if ($id != '') {
290
+					$query .= "OR marine_live.fammarine_id = :id ";
291
+				}
245 292
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
246 293
 				ORDER BY marine_live.fammarine_id, marine_live.date";
247
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
294
+				if ($limit) {
295
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
296
+				}
248 297
 			}
249 298
 		}
250 299
 		$query_values = array();
251
-		if ($id != '') $query_values = array(':id' => $id);
300
+		if ($id != '') {
301
+			$query_values = array(':id' => $id);
302
+		}
252 303
 		try {
253 304
 			$sth = $this->db->prepare($query);
254 305
 			$sth->execute($query_values);
@@ -271,7 +322,9 @@  discard block
 block discarded – undo
271 322
 		global $globalDBdriver, $globalLiveInterval;
272 323
 		$filter_query = $this->getFilter($filter,true,true);
273 324
 
274
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
325
+		if (!isset($globalLiveInterval)) {
326
+			$globalLiveInterval = '200';
327
+		}
275 328
 		if ($globalDBdriver == 'mysql') {
276 329
 			$query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
277 330
 		} else {
@@ -299,7 +352,9 @@  discard block
 block discarded – undo
299 352
 	{
300 353
 		global $globalDBdriver, $globalLiveInterval;
301 354
 		$Marine = new Marine($this->db);
302
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
355
+		if (!isset($globalLiveInterval)) {
356
+			$globalLiveInterval = '200';
357
+		}
303 358
 		$filter_query = $this->getFilter($filter);
304 359
 
305 360
 		if (is_array($coord)) {
@@ -307,7 +362,9 @@  discard block
 block discarded – undo
307 362
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
308 363
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
309 364
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
310
-		} else return array();
365
+		} else {
366
+			return array();
367
+		}
311 368
 		if ($globalDBdriver == 'mysql') {
312 369
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id ORDER BY date DESC'.$filter_query;
313 370
 		} else {
@@ -327,7 +384,9 @@  discard block
 block discarded – undo
327 384
 	{
328 385
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
329 386
 		$Marine = new Marine($this->db);
330
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
387
+		if (!isset($globalLiveInterval)) {
388
+			$globalLiveInterval = '200';
389
+		}
331 390
 		$filter_query = $this->getFilter($filter,true,true);
332 391
 
333 392
 		if (is_array($coord)) {
@@ -335,7 +394,9 @@  discard block
 block discarded – undo
335 394
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
336 395
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
337 396
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
338
-		} else return array();
397
+		} else {
398
+			return array();
399
+		}
339 400
 		/*
340 401
 		if ($globalDBdriver == 'mysql') {
341 402
 			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
@@ -558,11 +619,15 @@  discard block
 block discarded – undo
558 619
 		//$query  = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date';
559 620
 		if ($globalDBdriver == 'mysql') {
560 621
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
561
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
622
+			if ($liveinterval) {
623
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
624
+			}
562 625
 			$query .= ' ORDER BY date';
563 626
 		} else {
564 627
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
565
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
628
+			if ($liveinterval) {
629
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
630
+			}
566 631
 			$query .= ' ORDER BY date';
567 632
 		}
568 633
 
@@ -657,7 +722,9 @@  discard block
 block discarded – undo
657 722
 				$i++;
658 723
 				$j++;
659 724
 				if ($j == 30) {
660
-					if ($globalDebug) echo ".";
725
+					if ($globalDebug) {
726
+						echo ".";
727
+					}
661 728
 				    	try {
662 729
 						
663 730
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -951,7 +1018,9 @@  discard block
 block discarded – undo
951 1018
 			{
952 1019
 				return false;
953 1020
 			}
954
-		} else return '';
1021
+		} else {
1022
+			return '';
1023
+		}
955 1024
 
956 1025
 		if ($longitude != '')
957 1026
 		{
@@ -959,7 +1028,9 @@  discard block
 block discarded – undo
959 1028
 			{
960 1029
 				return false;
961 1030
 			}
962
-		} else return '';
1031
+		} else {
1032
+			return '';
1033
+		}
963 1034
 
964 1035
 
965 1036
 		if ($heading != '')
@@ -968,7 +1039,9 @@  discard block
 block discarded – undo
968 1039
 			{
969 1040
 				return false;
970 1041
 			}
971
-		} else $heading = 0;
1042
+		} else {
1043
+			$heading = 0;
1044
+		}
972 1045
 
973 1046
 		if ($groundspeed != '')
974 1047
 		{
@@ -976,9 +1049,13 @@  discard block
 block discarded – undo
976 1049
 			{
977 1050
 				return false;
978 1051
 			}
979
-		} else $groundspeed = 0;
1052
+		} else {
1053
+			$groundspeed = 0;
1054
+		}
980 1055
 		date_default_timezone_set('UTC');
981
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1056
+		if ($date == '') {
1057
+			$date = date("Y-m-d H:i:s", time());
1058
+		}
982 1059
 
983 1060
         
984 1061
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -1006,16 +1083,28 @@  discard block
 block discarded – undo
1006 1083
 		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
1007 1084
 		$race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT);
1008 1085
 		$race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1009
-		if ($typeid == '') $typeid = NULL;
1010
-		if ($statusid == '') $statusid = NULL;
1011
-		if ($distance == '') $distance = NULL;
1086
+		if ($typeid == '') {
1087
+			$typeid = NULL;
1088
+		}
1089
+		if ($statusid == '') {
1090
+			$statusid = NULL;
1091
+		}
1092
+		if ($distance == '') {
1093
+			$distance = NULL;
1094
+		}
1012 1095
 
1013 1096
             	//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1014
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1015
-            	if ($arrival_date == '') $arrival_date = NULL;
1097
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1098
+            		$heading = 0;
1099
+            	}
1100
+            	if ($arrival_date == '') {
1101
+            		$arrival_date = NULL;
1102
+            	}
1016 1103
             	$query = '';
1017 1104
 		if ($globalArchive) {
1018
-			if ($globalDebug) echo '-- Delete previous data -- ';
1105
+			if ($globalDebug) {
1106
+				echo '-- Delete previous data -- ';
1107
+			}
1019 1108
 			$query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';
1020 1109
 		}
1021 1110
 		$query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) 
@@ -1030,10 +1119,14 @@  discard block
 block discarded – undo
1030 1119
 		}
1031 1120
 		
1032 1121
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1033
-			if ($globalDebug) echo '(Add to Marine archive : ';
1122
+			if ($globalDebug) {
1123
+				echo '(Add to Marine archive : ';
1124
+			}
1034 1125
 			$MarineArchive = new MarineArchive($this->db);
1035 1126
 			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source, $source_name, $over_country,$captain_id,$captain_name,$race_id,$race_name,$distance,$race_rank,$race_time);
1036
-			if ($globalDebug) echo $result.')';
1127
+			if ($globalDebug) {
1128
+				echo $result.')';
1129
+			}
1037 1130
 		}
1038 1131
 		return "success";
1039 1132
 	}
Please login to merge, or discard this patch.
require/class.Marine.php 3 patches
Indentation   +288 added lines, -288 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 	}
13 13
 
14 14
 	/**
15
-	* Get SQL query part for filter used
16
-	* @param Array $filter the filter
17
-	* @return Array the SQL part
18
-	*/
15
+	 * Get SQL query part for filter used
16
+	 * @param Array $filter the filter
17
+	 * @return Array the SQL part
18
+	 */
19 19
 	
20 20
 	public function getFilter($filter = array(),$where = false,$and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
 	}
89 89
 
90 90
 	/**
91
-	* Executes the SQL statements to get the spotter information
92
-	*
93
-	* @param String $query the SQL query
94
-	* @param Array $params parameter of the query
95
-	* @param String $limitQuery the limit query
96
-	* @return Array the spotter information
97
-	*
98
-	*/
91
+	 * Executes the SQL statements to get the spotter information
92
+	 *
93
+	 * @param String $query the SQL query
94
+	 * @param Array $params parameter of the query
95
+	 * @param String $limitQuery the limit query
96
+	 * @return Array the spotter information
97
+	 *
98
+	 */
99 99
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
100 100
 	{
101 101
 		global $globalVM;
@@ -246,11 +246,11 @@  discard block
 block discarded – undo
246 246
 	
247 247
 	
248 248
 	/**
249
-	* Gets all the spotter information based on the latest data entry
250
-	*
251
-	* @return Array the spotter information
252
-	*
253
-	*/
249
+	 * Gets all the spotter information based on the latest data entry
250
+	 *
251
+	 * @return Array the spotter information
252
+	 *
253
+	 */
254 254
 	public function getLatestMarineData($limit = '', $sort = '', $filter = array())
255 255
 	{
256 256
 		global $global_marine_query;
@@ -299,11 +299,11 @@  discard block
 block discarded – undo
299 299
 	}
300 300
 
301 301
 	/**
302
-	* Gets all the spotter information based on the callsign
303
-	*
304
-	* @return Array the spotter information
305
-	*
306
-	*/
302
+	 * Gets all the spotter information based on the callsign
303
+	 *
304
+	 * @return Array the spotter information
305
+	 *
306
+	 */
307 307
 	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
308 308
 	{
309 309
 		global $global_marine_query;
@@ -355,11 +355,11 @@  discard block
 block discarded – undo
355 355
 	}
356 356
 
357 357
 	/**
358
-	* Gets all the marine information based on the type
359
-	*
360
-	* @return Array the marine information
361
-	*
362
-	*/
358
+	 * Gets all the marine information based on the type
359
+	 *
360
+	 * @return Array the marine information
361
+	 *
362
+	 */
363 363
 	public function getMarineDataByType($type = '', $limit = '', $sort = '', $filter = array())
364 364
 	{
365 365
 		global $global_marine_query;
@@ -465,11 +465,11 @@  discard block
 block discarded – undo
465 465
 	}
466 466
 
467 467
 	/**
468
-	* Gets all the marine information based on the captain
469
-	*
470
-	* @return Array the marine information
471
-	*
472
-	*/
468
+	 * Gets all the marine information based on the captain
469
+	 *
470
+	 * @return Array the marine information
471
+	 *
472
+	 */
473 473
 	public function getMarineDataByCaptain($captain = '', $limit = '', $sort = '', $filter = array())
474 474
 	{
475 475
 		global $global_marine_query;
@@ -508,11 +508,11 @@  discard block
 block discarded – undo
508 508
 	}
509 509
 
510 510
 	/**
511
-	* Gets all the marine information based on the race
512
-	*
513
-	* @return Array the marine information
514
-	*
515
-	*/
511
+	 * Gets all the marine information based on the race
512
+	 *
513
+	 * @return Array the marine information
514
+	 *
515
+	 */
516 516
 	public function getMarineDataByRace($race = '', $limit = '', $sort = '', $filter = array())
517 517
 	{
518 518
 		global $global_marine_query,$globalDBdriver;
@@ -555,11 +555,11 @@  discard block
 block discarded – undo
555 555
 	}
556 556
 
557 557
 	/**
558
-	* Count races by captain
559
-	*
560
-	* @return String Duration of all races
561
-	*
562
-	*/
558
+	 * Count races by captain
559
+	 *
560
+	 * @return String Duration of all races
561
+	 *
562
+	 */
563 563
 	public function countRacesByCaptain($captain,$filters = array())
564 564
 	{
565 565
 		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
@@ -575,11 +575,11 @@  discard block
 block discarded – undo
575 575
 	}
576 576
 
577 577
 	/**
578
-	* Count captains by race
579
-	*
580
-	* @return String Duration of all races
581
-	*
582
-	*/
578
+	 * Count captains by race
579
+	 *
580
+	 * @return String Duration of all races
581
+	 *
582
+	 */
583 583
 	public function countCaptainsByRace($race,$filters = array())
584 584
 	{
585 585
 		$race = filter_var($race,FILTER_SANITIZE_STRING);
@@ -595,11 +595,11 @@  discard block
 block discarded – undo
595 595
 	}
596 596
 
597 597
 	/**
598
-	* Gets all boat types that have been used by a captain
599
-	*
600
-	* @return Array the boat list
601
-	*
602
-	*/
598
+	 * Gets all boat types that have been used by a captain
599
+	 *
600
+	 * @return Array the boat list
601
+	 *
602
+	 */
603 603
 	public function countAllBoatTypesByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '')
604 604
 	{
605 605
 		global $globalDBdriver;
@@ -644,11 +644,11 @@  discard block
 block discarded – undo
644 644
 	}
645 645
 
646 646
 	/**
647
-	* Gets all boat types that have been used on a race
648
-	*
649
-	* @return Array the boat list
650
-	*
651
-	*/
647
+	 * Gets all boat types that have been used on a race
648
+	 *
649
+	 * @return Array the boat list
650
+	 *
651
+	 */
652 652
 	public function countAllBoatTypesByRace($race,$filters = array(),$year = '',$month = '',$day = '')
653 653
 	{
654 654
 		global $globalDBdriver;
@@ -693,11 +693,11 @@  discard block
 block discarded – undo
693 693
 	}
694 694
 
695 695
 	/**
696
-	* Gets race duration by captain
697
-	*
698
-	* @return String Duration of all race
699
-	*
700
-	*/
696
+	 * Gets race duration by captain
697
+	 *
698
+	 * @return String Duration of all race
699
+	 *
700
+	 */
701 701
 	public function getRaceDurationByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '')
702 702
 	{
703 703
 		global $globalDBdriver;
@@ -743,11 +743,11 @@  discard block
 block discarded – undo
743 743
 	}
744 744
 
745 745
 	/**
746
-	* Gets a list of all captain names and captain ids
747
-	*
748
-	* @return Array list of captain names and captain ids
749
-	*
750
-	*/
746
+	 * Gets a list of all captain names and captain ids
747
+	 *
748
+	 * @return Array list of captain names and captain ids
749
+	 *
750
+	 */
751 751
 	public function getAllCaptainNames($filters = array())
752 752
 	{
753 753
 		$filter_query = $this->getFilter($filters,true,true);
@@ -761,11 +761,11 @@  discard block
 block discarded – undo
761 761
 	} 
762 762
 
763 763
 	/**
764
-	* Gets a list of all race names and race ids
765
-	*
766
-	* @return Array list of race names and race ids
767
-	*
768
-	*/
764
+	 * Gets a list of all race names and race ids
765
+	 *
766
+	 * @return Array list of race names and race ids
767
+	 *
768
+	 */
769 769
 	public function getAllRaceNames($filters = array())
770 770
 	{
771 771
 		$filter_query = $this->getFilter($filters,true,true);
@@ -779,12 +779,12 @@  discard block
 block discarded – undo
779 779
 	} 
780 780
 
781 781
 	/**
782
-	* Gets all source name
783
-	*
784
-	* @param String type format of source
785
-	* @return Array list of source name
786
-	*
787
-	*/
782
+	 * Gets all source name
783
+	 *
784
+	 * @param String type format of source
785
+	 * @return Array list of source name
786
+	 *
787
+	 */
788 788
 	public function getAllSourceName($type = '',$filters = array())
789 789
 	{
790 790
 		$filter_query = $this->getFilter($filters,true,true);
@@ -814,11 +814,11 @@  discard block
 block discarded – undo
814 814
 
815 815
 
816 816
 	/**
817
-	* Gets a list of all idents/callsigns
818
-	*
819
-	* @return Array list of ident/callsign names
820
-	*
821
-	*/
817
+	 * Gets a list of all idents/callsigns
818
+	 *
819
+	 * @return Array list of ident/callsign names
820
+	 *
821
+	 */
822 822
 	public function getAllIdents($filters = array())
823 823
 	{
824 824
 		$filter_query = $this->getFilter($filters,true,true);
@@ -842,11 +842,11 @@  discard block
 block discarded – undo
842 842
 	}
843 843
 
844 844
 	/**
845
-	* Gets all info from a mmsi
846
-	*
847
-	* @return Array ident
848
-	*
849
-	*/
845
+	 * Gets all info from a mmsi
846
+	 *
847
+	 * @return Array ident
848
+	 *
849
+	 */
850 850
 	public function getIdentity($mmsi)
851 851
 	{
852 852
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -859,9 +859,9 @@  discard block
 block discarded – undo
859 859
 	}
860 860
 
861 861
 	/**
862
-	* Add identity
863
-	*
864
-	*/
862
+	 * Add identity
863
+	 *
864
+	 */
865 865
 	public function addIdentity($mmsi,$imo,$ident,$callsign,$type)
866 866
 	{
867 867
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -927,13 +927,13 @@  discard block
 block discarded – undo
927 927
 	}
928 928
 
929 929
 	/**
930
-	* Update ident tracker data
931
-	*
932
-	* @param String $fammarine_id the ID
933
-	* @param String $ident the marine ident
934
-	* @return String success or false
935
-	*
936
-	*/
930
+	 * Update ident tracker data
931
+	 *
932
+	 * @param String $fammarine_id the ID
933
+	 * @param String $ident the marine ident
934
+	 * @return String success or false
935
+	 *
936
+	 */
937 937
 	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
938 938
 	{
939 939
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
@@ -948,13 +948,13 @@  discard block
 block discarded – undo
948 948
 	}
949 949
 
950 950
 	/**
951
-	* Update arrival marine data
952
-	*
953
-	* @param String $fammarine_id the ID
954
-	* @param String $arrival_code the marine ident
955
-	* @return String success or false
956
-	*
957
-	*/
951
+	 * Update arrival marine data
952
+	 *
953
+	 * @param String $fammarine_id the ID
954
+	 * @param String $arrival_code the marine ident
955
+	 * @return String success or false
956
+	 *
957
+	 */
958 958
 	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL)
959 959
 	{
960 960
 		$query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id';
@@ -969,19 +969,19 @@  discard block
 block discarded – undo
969 969
 	}
970 970
 
971 971
 	/**
972
-	* Update Status data
973
-	*
974
-	* @param String $fammarine_id the ID
975
-	* @param String $status_id the marine status id
976
-	* @param String $status the marine status
977
-	* @return String success or false
978
-	*
979
-	*/
972
+	 * Update Status data
973
+	 *
974
+	 * @param String $fammarine_id the ID
975
+	 * @param String $status_id the marine status id
976
+	 * @param String $status the marine status
977
+	 * @return String success or false
978
+	 *
979
+	 */
980 980
 	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
981 981
 	{
982 982
 
983 983
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
984
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
984
+				$query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
985 985
 
986 986
 		try {
987 987
 			$sth = $this->db->prepare($query);
@@ -994,13 +994,13 @@  discard block
 block discarded – undo
994 994
 
995 995
 	}
996 996
 	/**
997
-	* Update latest marine data
998
-	*
999
-	* @param String $fammarine_id the ID
1000
-	* @param String $ident the marine ident
1001
-	* @return String success or false
1002
-	*
1003
-	*/	
997
+	 * Update latest marine data
998
+	 *
999
+	 * @param String $fammarine_id the ID
1000
+	 * @param String $ident the marine ident
1001
+	 * @return String success or false
1002
+	 *
1003
+	 */	
1004 1004
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '')
1005 1005
 	{
1006 1006
 		if ($latitude == '') $latitude = NULL;
@@ -1026,30 +1026,30 @@  discard block
 block discarded – undo
1026 1026
 	}
1027 1027
 
1028 1028
 	/**
1029
-	* Adds a new marine data
1030
-	*
1031
-	* @param String $fammarine_id the ID
1032
-	* @param String $ident the marine ident
1033
-	* @param String $departure_airport_icao the departure airport
1034
-	* @param String $arrival_airport_icao the arrival airport
1035
-	* @param String $latitude latitude of flight
1036
-	* @param String $longitude latitude of flight
1037
-	* @param String $waypoints waypoints of flight
1038
-	* @param String $heading heading of flight
1039
-	* @param String $groundspeed speed of flight
1040
-	* @param String $date date of flight
1041
-	* @param String $departure_airport_time departure time of flight
1042
-	* @param String $arrival_airport_time arrival time of flight
1043
-	* @param String $squawk squawk code of flight
1044
-	* @param String $route_stop route stop of flight
1045
-	* @param String $highlight highlight or not
1046
-	* @param String $ModeS ModesS code of flight
1047
-	* @param String $registration registration code of flight
1048
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
1049
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
1050
-	* @param String $verticalrate vertival rate of flight
1051
-	* @return String success or false
1052
-	*/
1029
+	 * Adds a new marine data
1030
+	 *
1031
+	 * @param String $fammarine_id the ID
1032
+	 * @param String $ident the marine ident
1033
+	 * @param String $departure_airport_icao the departure airport
1034
+	 * @param String $arrival_airport_icao the arrival airport
1035
+	 * @param String $latitude latitude of flight
1036
+	 * @param String $longitude latitude of flight
1037
+	 * @param String $waypoints waypoints of flight
1038
+	 * @param String $heading heading of flight
1039
+	 * @param String $groundspeed speed of flight
1040
+	 * @param String $date date of flight
1041
+	 * @param String $departure_airport_time departure time of flight
1042
+	 * @param String $arrival_airport_time arrival time of flight
1043
+	 * @param String $squawk squawk code of flight
1044
+	 * @param String $route_stop route stop of flight
1045
+	 * @param String $highlight highlight or not
1046
+	 * @param String $ModeS ModesS code of flight
1047
+	 * @param String $registration registration code of flight
1048
+	 * @param String $pilot_id pilot id of flight (for virtual airlines)
1049
+	 * @param String $pilot_name pilot name of flight (for virtual airlines)
1050
+	 * @param String $verticalrate vertival rate of flight
1051
+	 * @return String success or false
1052
+	 */
1053 1053
 	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '',$race_rank = '', $race_time = '')
1054 1054
 	{
1055 1055
 		global $globalURL, $globalMarineImageFetch;
@@ -1183,11 +1183,11 @@  discard block
 block discarded – undo
1183 1183
 	
1184 1184
   
1185 1185
 	/**
1186
-	* Gets the aircraft ident within the last hour
1187
-	*
1188
-	* @return String the ident
1189
-	*
1190
-	*/
1186
+	 * Gets the aircraft ident within the last hour
1187
+	 *
1188
+	 * @return String the ident
1189
+	 *
1190
+	 */
1191 1191
 	public function getIdentFromLastHour($ident)
1192 1192
 	{
1193 1193
 		global $globalDBdriver, $globalTimezone;
@@ -1203,11 +1203,11 @@  discard block
 block discarded – undo
1203 1203
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
1204 1204
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
1205 1205
 			$query_data = array(':ident' => $ident);
1206
-    		}
1206
+			}
1207 1207
 		
1208 1208
 		$sth = $this->db->prepare($query);
1209 1209
 		$sth->execute($query_data);
1210
-    		$ident_result='';
1210
+			$ident_result='';
1211 1211
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1212 1212
 		{
1213 1213
 			$ident_result = $row['ident'];
@@ -1218,11 +1218,11 @@  discard block
 block discarded – undo
1218 1218
 	
1219 1219
 	
1220 1220
 	/**
1221
-	* Gets the aircraft data from the last 20 seconds
1222
-	*
1223
-	* @return Array the marine data
1224
-	*
1225
-	*/
1221
+	 * Gets the aircraft data from the last 20 seconds
1222
+	 *
1223
+	 * @return Array the marine data
1224
+	 *
1225
+	 */
1226 1226
 	public function getRealTimeData($q = '')
1227 1227
 	{
1228 1228
 		global $globalDBdriver;
@@ -1260,11 +1260,11 @@  discard block
 block discarded – undo
1260 1260
 	
1261 1261
 
1262 1262
 	/**
1263
-	* Gets all number of flight over countries
1264
-	*
1265
-	* @return Array the airline country list
1266
-	*
1267
-	*/
1263
+	 * Gets all number of flight over countries
1264
+	 *
1265
+	 * @return Array the airline country list
1266
+	 *
1267
+	 */
1268 1268
 
1269 1269
 	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
1270 1270
 	{
@@ -1337,11 +1337,11 @@  discard block
 block discarded – undo
1337 1337
 	
1338 1338
 	
1339 1339
 	/**
1340
-	* Gets all callsigns that have flown over
1341
-	*
1342
-	* @return Array the callsign list
1343
-	*
1344
-	*/
1340
+	 * Gets all callsigns that have flown over
1341
+	 *
1342
+	 * @return Array the callsign list
1343
+	 *
1344
+	 */
1345 1345
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
1346 1346
 	{
1347 1347
 		global $globalDBdriver;
@@ -1408,11 +1408,11 @@  discard block
 block discarded – undo
1408 1408
 
1409 1409
 
1410 1410
 	/**
1411
-	* Counts all dates
1412
-	*
1413
-	* @return Array the date list
1414
-	*
1415
-	*/
1411
+	 * Counts all dates
1412
+	 *
1413
+	 * @return Array the date list
1414
+	 *
1415
+	 */
1416 1416
 	public function countAllDates($filters = array())
1417 1417
 	{
1418 1418
 		global $globalTimezone, $globalDBdriver;
@@ -1458,11 +1458,11 @@  discard block
 block discarded – undo
1458 1458
 	
1459 1459
 	
1460 1460
 	/**
1461
-	* Counts all dates during the last 7 days
1462
-	*
1463
-	* @return Array the date list
1464
-	*
1465
-	*/
1461
+	 * Counts all dates during the last 7 days
1462
+	 *
1463
+	 * @return Array the date list
1464
+	 *
1465
+	 */
1466 1466
 	public function countAllDatesLast7Days($filters = array())
1467 1467
 	{
1468 1468
 		global $globalTimezone, $globalDBdriver;
@@ -1484,7 +1484,7 @@  discard block
 block discarded – undo
1484 1484
 			$query .= " GROUP BY date_name 
1485 1485
 								ORDER BY date_name ASC";
1486 1486
 			$query_data = array(':offset' => $offset);
1487
-    		}
1487
+			}
1488 1488
 		
1489 1489
 		$sth = $this->db->prepare($query);
1490 1490
 		$sth->execute($query_data);
@@ -1504,11 +1504,11 @@  discard block
 block discarded – undo
1504 1504
 	}
1505 1505
 
1506 1506
 	/**
1507
-	* Counts all dates during the last month
1508
-	*
1509
-	* @return Array the date list
1510
-	*
1511
-	*/
1507
+	 * Counts all dates during the last month
1508
+	 *
1509
+	 * @return Array the date list
1510
+	 *
1511
+	 */
1512 1512
 	public function countAllDatesLastMonth($filters = array())
1513 1513
 	{
1514 1514
 		global $globalTimezone, $globalDBdriver;
@@ -1530,7 +1530,7 @@  discard block
 block discarded – undo
1530 1530
 			$query .= " GROUP BY date_name 
1531 1531
 								ORDER BY date_name ASC";
1532 1532
 			$query_data = array(':offset' => $offset);
1533
-    		}
1533
+			}
1534 1534
 		
1535 1535
 		$sth = $this->db->prepare($query);
1536 1536
 		$sth->execute($query_data);
@@ -1552,11 +1552,11 @@  discard block
 block discarded – undo
1552 1552
 
1553 1553
 
1554 1554
 	/**
1555
-	* Counts all month
1556
-	*
1557
-	* @return Array the month list
1558
-	*
1559
-	*/
1555
+	 * Counts all month
1556
+	 *
1557
+	 * @return Array the month list
1558
+	 *
1559
+	 */
1560 1560
 	public function countAllMonths($filters = array())
1561 1561
 	{
1562 1562
 		global $globalTimezone, $globalDBdriver;
@@ -1601,11 +1601,11 @@  discard block
 block discarded – undo
1601 1601
 	
1602 1602
 
1603 1603
 	/**
1604
-	* Counts all dates during the last year
1605
-	*
1606
-	* @return Array the date list
1607
-	*
1608
-	*/
1604
+	 * Counts all dates during the last year
1605
+	 *
1606
+	 * @return Array the date list
1607
+	 *
1608
+	 */
1609 1609
 	public function countAllMonthsLastYear($filters)
1610 1610
 	{
1611 1611
 		global $globalTimezone, $globalDBdriver;
@@ -1627,7 +1627,7 @@  discard block
 block discarded – undo
1627 1627
 			$query .= " GROUP BY year_name, month_name
1628 1628
 								ORDER BY year_name, month_name ASC";
1629 1629
 			$query_data = array(':offset' => $offset);
1630
-    		}
1630
+			}
1631 1631
 		
1632 1632
 		$sth = $this->db->prepare($query);
1633 1633
 		$sth->execute($query_data);
@@ -1650,11 +1650,11 @@  discard block
 block discarded – undo
1650 1650
 	
1651 1651
 	
1652 1652
 	/**
1653
-	* Counts all hours
1654
-	*
1655
-	* @return Array the hour list
1656
-	*
1657
-	*/
1653
+	 * Counts all hours
1654
+	 *
1655
+	 * @return Array the hour list
1656
+	 *
1657
+	 */
1658 1658
 	public function countAllHours($orderby,$filters = array())
1659 1659
 	{
1660 1660
 		global $globalTimezone, $globalDBdriver;
@@ -1717,11 +1717,11 @@  discard block
 block discarded – undo
1717 1717
 	
1718 1718
 	
1719 1719
 	/**
1720
-	* Counts all hours by date
1721
-	*
1722
-	* @return Array the hour list
1723
-	*
1724
-	*/
1720
+	 * Counts all hours by date
1721
+	 *
1722
+	 * @return Array the hour list
1723
+	 *
1724
+	 */
1725 1725
 	public function countAllHoursByDate($date, $filters = array())
1726 1726
 	{
1727 1727
 		global $globalTimezone, $globalDBdriver;
@@ -1765,11 +1765,11 @@  discard block
 block discarded – undo
1765 1765
 	
1766 1766
 	
1767 1767
 	/**
1768
-	* Counts all hours by a ident/callsign
1769
-	*
1770
-	* @return Array the hour list
1771
-	*
1772
-	*/
1768
+	 * Counts all hours by a ident/callsign
1769
+	 *
1770
+	 * @return Array the hour list
1771
+	 *
1772
+	 */
1773 1773
 	public function countAllHoursByIdent($ident, $filters = array())
1774 1774
 	{
1775 1775
 		global $globalTimezone, $globalDBdriver;
@@ -1814,11 +1814,11 @@  discard block
 block discarded – undo
1814 1814
 	
1815 1815
 	
1816 1816
 	/**
1817
-	* Counts all vessels
1818
-	*
1819
-	* @return Integer the number of vessels
1820
-	*
1821
-	*/
1817
+	 * Counts all vessels
1818
+	 *
1819
+	 * @return Integer the number of vessels
1820
+	 *
1821
+	 */
1822 1822
 	public function countOverallMarine($filters = array(),$year = '',$month = '')
1823 1823
 	{
1824 1824
 		global $globalDBdriver;
@@ -1853,11 +1853,11 @@  discard block
 block discarded – undo
1853 1853
 	}
1854 1854
 	
1855 1855
 	/**
1856
-	* Counts all vessel type
1857
-	*
1858
-	* @return Integer the number of vessels
1859
-	*
1860
-	*/
1856
+	 * Counts all vessel type
1857
+	 *
1858
+	 * @return Integer the number of vessels
1859
+	 *
1860
+	 */
1861 1861
 	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
1862 1862
 	{
1863 1863
 		global $globalDBdriver;
@@ -1892,11 +1892,11 @@  discard block
 block discarded – undo
1892 1892
 	
1893 1893
   
1894 1894
 	/**
1895
-	* Counts all hours of today
1896
-	*
1897
-	* @return Array the hour list
1898
-	*
1899
-	*/
1895
+	 * Counts all hours of today
1896
+	 *
1897
+	 * @return Array the hour list
1898
+	 *
1899
+	 */
1900 1900
 	public function countAllHoursFromToday($filters = array())
1901 1901
 	{
1902 1902
 		global $globalTimezone, $globalDBdriver;
@@ -1936,12 +1936,12 @@  discard block
 block discarded – undo
1936 1936
 	}
1937 1937
     
1938 1938
     
1939
-     /**
1940
-	* Gets the Barrie Spotter ID based on the FlightAware ID
1941
-	*
1942
-	* @return Integer the Barrie Spotter ID
1939
+	 /**
1940
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
1941
+	  *
1942
+	  * @return Integer the Barrie Spotter ID
1943 1943
 q	*
1944
-	*/
1944
+	  */
1945 1945
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1946 1946
 	{
1947 1947
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -1962,13 +1962,13 @@  discard block
 block discarded – undo
1962 1962
   
1963 1963
  
1964 1964
 	/**
1965
-	* Parses a date string
1966
-	*
1967
-	* @param String $dateString the date string
1968
-	* @param String $timezone the timezone of a user
1969
-	* @return Array the time information
1970
-	*
1971
-	*/
1965
+	 * Parses a date string
1966
+	 *
1967
+	 * @param String $dateString the date string
1968
+	 * @param String $timezone the timezone of a user
1969
+	 * @return Array the time information
1970
+	 *
1971
+	 */
1972 1972
 	public function parseDateString($dateString, $timezone = '')
1973 1973
 	{
1974 1974
 		$time_array = array();
@@ -2001,12 +2001,12 @@  discard block
 block discarded – undo
2001 2001
 	}
2002 2002
 	
2003 2003
 	/**
2004
-	* Parses the direction degrees to working
2005
-	*
2006
-	* @param Float $direction the direction in degrees
2007
-	* @return Array the direction information
2008
-	*
2009
-	*/
2004
+	 * Parses the direction degrees to working
2005
+	 *
2006
+	 * @param Float $direction the direction in degrees
2007
+	 * @return Array the direction information
2008
+	 *
2009
+	 */
2010 2010
 	public function parseDirection($direction = 0)
2011 2011
 	{
2012 2012
 		if ($direction == '') $direction = 0;
@@ -2085,12 +2085,12 @@  discard block
 block discarded – undo
2085 2085
 	
2086 2086
 	
2087 2087
 	/**
2088
-	* Gets Country from latitude/longitude
2089
-	*
2090
-	* @param Float $latitude latitute of the flight
2091
-	* @param Float $longitude longitute of the flight
2092
-	* @return String the countrie
2093
-	*/
2088
+	 * Gets Country from latitude/longitude
2089
+	 *
2090
+	 * @param Float $latitude latitute of the flight
2091
+	 * @param Float $longitude longitute of the flight
2092
+	 * @return String the countrie
2093
+	 */
2094 2094
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
2095 2095
 	{
2096 2096
 		global $globalDBdriver, $globalDebug;
@@ -2127,11 +2127,11 @@  discard block
 block discarded – undo
2127 2127
 	}
2128 2128
 
2129 2129
 	/**
2130
-	* Gets Country from iso2
2131
-	*
2132
-	* @param String $iso2 ISO2 country code
2133
-	* @return String the countrie
2134
-	*/
2130
+	 * Gets Country from iso2
2131
+	 *
2132
+	 * @param String $iso2 ISO2 country code
2133
+	 * @return String the countrie
2134
+	 */
2135 2135
 	public function getCountryFromISO2($iso2)
2136 2136
 	{
2137 2137
 		global $globalDBdriver, $globalDebug;
@@ -2160,12 +2160,12 @@  discard block
 block discarded – undo
2160 2160
 
2161 2161
 	
2162 2162
 	/**
2163
-	* Gets the short url from bit.ly
2164
-	*
2165
-	* @param String $url the full url
2166
-	* @return String the bit.ly url
2167
-	*
2168
-	*/
2163
+	 * Gets the short url from bit.ly
2164
+	 *
2165
+	 * @param String $url the full url
2166
+	 * @return String the bit.ly url
2167
+	 *
2168
+	 */
2169 2169
 	public function getBitlyURL($url)
2170 2170
 	{
2171 2171
 		global $globalBitlyAccessToken;
@@ -2192,11 +2192,11 @@  discard block
 block discarded – undo
2192 2192
 
2193 2193
 	
2194 2194
 	/**
2195
-	* Gets all vessels types that have flown over
2196
-	*
2197
-	* @return Array the vessel type list
2198
-	*
2199
-	*/
2195
+	 * Gets all vessels types that have flown over
2196
+	 *
2197
+	 * @return Array the vessel type list
2198
+	 *
2199
+	 */
2200 2200
 	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
2201 2201
 	{
2202 2202
 		global $globalDBdriver;
@@ -2262,11 +2262,11 @@  discard block
 block discarded – undo
2262 2262
 	}
2263 2263
 
2264 2264
 	/**
2265
-	* Gets all the tracker information
2266
-	*
2267
-	* @return Array the tracker information
2268
-	*
2269
-	*/
2265
+	 * Gets all the tracker information
2266
+	 *
2267
+	 * @return Array the tracker information
2268
+	 *
2269
+	 */
2270 2270
 	public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array())
2271 2271
 	{
2272 2272
 		global $globalTimezone, $globalDBdriver;
@@ -2395,11 +2395,11 @@  discard block
 block discarded – undo
2395 2395
 	}
2396 2396
 
2397 2397
 	/**
2398
-	* Check marine by id
2399
-	*
2400
-	* @return String the ident
2401
-	*
2402
-	*/
2398
+	 * Check marine by id
2399
+	 *
2400
+	 * @return String the ident
2401
+	 *
2402
+	 */
2403 2403
 	public function checkId($id)
2404 2404
 	{
2405 2405
 		global $globalDBdriver, $globalTimezone;
@@ -2416,11 +2416,11 @@  discard block
 block discarded – undo
2416 2416
 	}
2417 2417
 
2418 2418
 	/**
2419
-	* Gets all info from a race
2420
-	*
2421
-	* @return Array race
2422
-	*
2423
-	*/
2419
+	 * Gets all info from a race
2420
+	 *
2421
+	 * @return Array race
2422
+	 *
2423
+	 */
2424 2424
 	public function getRaceByName($race_name)
2425 2425
 	{
2426 2426
 		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
@@ -2433,11 +2433,11 @@  discard block
 block discarded – undo
2433 2433
 	}
2434 2434
 
2435 2435
 	/**
2436
-	* Gets all info from a race
2437
-	*
2438
-	* @return Array race
2439
-	*
2440
-	*/
2436
+	 * Gets all info from a race
2437
+	 *
2438
+	 * @return Array race
2439
+	 *
2440
+	 */
2441 2441
 	public function getRace($race_id)
2442 2442
 	{
2443 2443
 		$race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT);
@@ -2450,9 +2450,9 @@  discard block
 block discarded – undo
2450 2450
 	}
2451 2451
 
2452 2452
 	/**
2453
-	* Add race
2454
-	*
2455
-	*/
2453
+	 * Add race
2454
+	 *
2455
+	 */
2456 2456
 	public function addRace($race_id,$race_name,$race_creator,$race_desc,$race_startdate,$race_markers)
2457 2457
 	{
2458 2458
 		$race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT);
Please login to merge, or discard this patch.
Spacing   +289 added lines, -289 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once(dirname(__FILE__).'/class.Image.php');
3 3
 $global_marine_query = "SELECT marine_output.* FROM marine_output";
4 4
 
5
-class Marine{
5
+class Marine {
6 6
 	public $db;
7 7
 	
8 8
 	public function __construct($dbc = null) {
@@ -17,33 +17,33 @@  discard block
 block discarded – undo
17 17
 	* @return Array the SQL part
18 18
 	*/
19 19
 	
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
23 23
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
24 24
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
25 25
 				$filters = $globalStatsFilters[$globalFilterName];
26 26
 			} else {
27
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
27
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
28 28
 			}
29 29
 		}
30 30
 		if (isset($filter[0]['source'])) {
31
-			$filters = array_merge($filters,$filter);
31
+			$filters = array_merge($filters, $filter);
32 32
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
34 34
 		$filter_query_join = '';
35 35
 		$filter_query_where = '';
36
-		foreach($filters as $flt) {
36
+		foreach ($filters as $flt) {
37 37
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
38 38
 				if (isset($flt['source'])) {
39
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
39
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
40 40
 				} else {
41
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
41
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
42 42
 				}
43 43
 			}
44 44
 		}
45 45
 		if (isset($filter['source']) && !empty($filter['source'])) {
46
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
46
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
47 47
 		}
48 48
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
49 49
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
82 82
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
83 83
 		if ($filter_query_where != '') {
84
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
84
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
85 85
 		}
86 86
 		$filter_query = $filter_query_join.$filter_query_where;
87 87
 		return $filter_query;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	* @return Array the spotter information
97 97
 	*
98 98
 	*/
99
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
99
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
100 100
 	{
101 101
 		global $globalVM;
102 102
 		date_default_timezone_set('UTC');
@@ -117,13 +117,13 @@  discard block
 block discarded – undo
117 117
 			$sth = $this->db->prepare($query.$limitQuery);
118 118
 			$sth->execute($params);
119 119
 		} catch (PDOException $e) {
120
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
120
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
121 121
 			exit();
122 122
 		}
123 123
 		
124 124
 		$num_rows = 0;
125 125
 		$spotter_array = array();
126
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
126
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
127 127
 		{
128 128
 			$num_rows++;
129 129
 			$temp_array = array();
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
 			}
166 166
 			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
167 167
 
168
-			if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
168
+			if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
169 169
 			{
170 170
 				$Image = new Image($this->db);
171
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
171
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']);
172 172
 				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
173 173
 				unset($Image);
174 174
 				if (count($image_array) > 0) {
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
 					$temp_array['image_source_website'] = $image_array[0]['image_source_website'];
179 179
 					$temp_array['image_copyright'] = $image_array[0]['image_copyright'];
180 180
 				}
181
-			} elseif(isset($temp_array['type']) && $temp_array['type'] != "")
181
+			} elseif (isset($temp_array['type']) && $temp_array['type'] != "")
182 182
 			{
183 183
 				$Image = new Image($this->db);
184
-				$image_array = $Image->getMarineImage('','','',$temp_array['type']);
184
+				$image_array = $Image->getMarineImage('', '', '', $temp_array['type']);
185 185
 				unset($Image);
186 186
 				if (count($image_array) > 0) {
187 187
 					$temp_array['image'] = $image_array[0]['image'];
@@ -216,17 +216,17 @@  discard block
 block discarded – undo
216 216
 				{
217 217
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
218 218
 				} else {
219
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
219
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
220 220
 				}
221 221
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
222
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
223
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
222
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
223
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
224 224
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
225 225
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
226 226
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
227 227
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
228
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
229
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
228
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
229
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
230 230
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
231 231
 					}
232 232
 				}
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 		if ($limit != "")
260 260
 		{
261 261
 			$limit_array = explode(",", $limit);
262
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
263
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
262
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
263
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
264 264
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
265 265
 			{
266 266
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
 		} else {
275 275
 			$orderby_query = " ORDER BY marine_output.date DESC";
276 276
 		}
277
-		$query  = $global_marine_query.$filter_query." ".$orderby_query;
278
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
277
+		$query = $global_marine_query.$filter_query." ".$orderby_query;
278
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
279 279
 		return $spotter_array;
280 280
 	}
281 281
     
@@ -293,8 +293,8 @@  discard block
 block discarded – undo
293 293
 		if ($id == '') return array();
294 294
 		$additional_query = "marine_output.fammarine_id = :id";
295 295
 		$query_values = array(':id' => $id);
296
-		$query  = $global_marine_query." WHERE ".$additional_query." ";
297
-		$spotter_array = $this->getDataFromDB($query,$query_values);
296
+		$query = $global_marine_query." WHERE ".$additional_query." ";
297
+		$spotter_array = $this->getDataFromDB($query, $query_values);
298 298
 		return $spotter_array;
299 299
 	}
300 300
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 		$query_values = array();
314 314
 		$limit_query = '';
315 315
 		$additional_query = '';
316
-		$filter_query = $this->getFilter($filter,true,true);
316
+		$filter_query = $this->getFilter($filter, true, true);
317 317
 		if ($ident != "")
318 318
 		{
319 319
 			if (!is_string($ident))
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
 		{
330 330
 			$limit_array = explode(",", $limit);
331 331
 			
332
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
333
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
332
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
333
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
334 334
 			
335 335
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
336 336
 			{
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 		$query_values = array();
370 370
 		$limit_query = '';
371 371
 		$additional_query = '';
372
-		$filter_query = $this->getFilter($filter,true,true);
372
+		$filter_query = $this->getFilter($filter, true, true);
373 373
 		if (!is_string($type))
374 374
 		{
375 375
 			return false;
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 		{
383 383
 			$limit_array = explode(",", $limit);
384 384
 			
385
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
386
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
385
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
386
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
387 387
 			
388 388
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
389 389
 			{
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 		return $spotter_array;
408 408
 	}
409 409
 	
410
-	public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array())
410
+	public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
411 411
 	{
412 412
 		global $global_marine_query, $globalTimezone, $globalDBdriver;
413 413
 		
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 		$limit_query = '';
416 416
 		$additional_query = '';
417 417
 
418
-		$filter_query = $this->getFilter($filter,true,true);
418
+		$filter_query = $this->getFilter($filter, true, true);
419 419
 		
420 420
 		if ($date != "")
421 421
 		{
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
 		{
442 442
 			$limit_array = explode(",", $limit);
443 443
 			
444
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
445
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
444
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
445
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
446 446
 			
447 447
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
448 448
 			{
@@ -477,8 +477,8 @@  discard block
 block discarded – undo
477 477
 		$query_values = array();
478 478
 		$limit_query = '';
479 479
 		$additional_query = '';
480
-		$filter_query = $this->getFilter($filter,true,true);
481
-		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
480
+		$filter_query = $this->getFilter($filter, true, true);
481
+		$captain = filter_var($captain, FILTER_SANITIZE_STRING);
482 482
 		if ($captain != "")
483 483
 		{
484 484
 			$additional_query = " AND (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)";
@@ -487,8 +487,8 @@  discard block
 block discarded – undo
487 487
 		if ($limit != "")
488 488
 		{
489 489
 			$limit_array = explode(",", $limit);
490
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
491
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
490
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
491
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
492 492
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
493 493
 			{
494 494
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -515,13 +515,13 @@  discard block
 block discarded – undo
515 515
 	*/
516 516
 	public function getMarineDataByRace($race = '', $limit = '', $sort = '', $filter = array())
517 517
 	{
518
-		global $global_marine_query,$globalDBdriver;
518
+		global $global_marine_query, $globalDBdriver;
519 519
 		date_default_timezone_set('UTC');
520 520
 		$query_values = array();
521 521
 		$limit_query = '';
522 522
 		$additional_query = '';
523
-		$filter_query = $this->getFilter($filter,true,true);
524
-		$race = filter_var($race,FILTER_SANITIZE_STRING);
523
+		$filter_query = $this->getFilter($filter, true, true);
524
+		$race = filter_var($race, FILTER_SANITIZE_STRING);
525 525
 		if ($race != "")
526 526
 		{
527 527
 			$additional_query = " AND (marine_output.race_name = :race OR marine_output.race_id = :race)";
@@ -530,8 +530,8 @@  discard block
 block discarded – undo
530 530
 		if ($limit != "")
531 531
 		{
532 532
 			$limit_array = explode(",", $limit);
533
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
534
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
533
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
534
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
535 535
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
536 536
 			{
537 537
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -560,14 +560,14 @@  discard block
 block discarded – undo
560 560
 	* @return String Duration of all races
561 561
 	*
562 562
 	*/
563
-	public function countRacesByCaptain($captain,$filters = array())
563
+	public function countRacesByCaptain($captain, $filters = array())
564 564
 	{
565
-		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
566
-		$filter_query = $this->getFilter($filters,true,true);
567
-		$query  = "SELECT COUNT(*) AS nb 
565
+		$captain = filter_var($captain, FILTER_SANITIZE_STRING);
566
+		$filter_query = $this->getFilter($filters, true, true);
567
+		$query = "SELECT COUNT(*) AS nb 
568 568
 			FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain)";
569 569
 		$query_values = array();
570
-		$query_values = array_merge($query_values,array(':captain' => $captain));
570
+		$query_values = array_merge($query_values, array(':captain' => $captain));
571 571
 		$sth = $this->db->prepare($query);
572 572
 		$sth->execute($query_values);
573 573
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -580,14 +580,14 @@  discard block
 block discarded – undo
580 580
 	* @return String Duration of all races
581 581
 	*
582 582
 	*/
583
-	public function countCaptainsByRace($race,$filters = array())
583
+	public function countCaptainsByRace($race, $filters = array())
584 584
 	{
585
-		$race = filter_var($race,FILTER_SANITIZE_STRING);
586
-		$filter_query = $this->getFilter($filters,true,true);
587
-		$query  = "SELECT COUNT(*) AS nb 
585
+		$race = filter_var($race, FILTER_SANITIZE_STRING);
586
+		$filter_query = $this->getFilter($filters, true, true);
587
+		$query = "SELECT COUNT(*) AS nb 
588 588
 			FROM marine_output".$filter_query." (marine_output.race_name = :race OR marine_output.race_id = :race)";
589 589
 		$query_values = array();
590
-		$query_values = array_merge($query_values,array(':race' => $race));
590
+		$query_values = array_merge($query_values, array(':race' => $race));
591 591
 		$sth = $this->db->prepare($query);
592 592
 		$sth->execute($query_values);
593 593
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -600,44 +600,44 @@  discard block
 block discarded – undo
600 600
 	* @return Array the boat list
601 601
 	*
602 602
 	*/
603
-	public function countAllBoatTypesByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '')
603
+	public function countAllBoatTypesByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '')
604 604
 	{
605 605
 		global $globalDBdriver;
606
-		$filter_query = $this->getFilter($filters,true,true);
607
-		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
608
-		$query  = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count
606
+		$filter_query = $this->getFilter($filters, true, true);
607
+		$captain = filter_var($captain, FILTER_SANITIZE_STRING);
608
+		$query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count
609 609
 			FROM marine_output".$filter_query." (marine_output.captain_id = :captain OR marine_output.captain_name = :captain)";
610 610
 		$query_values = array();
611 611
 		if ($year != '') {
612 612
 			if ($globalDBdriver == 'mysql') {
613 613
 				$query .= " AND YEAR(marine_output.date) = :year";
614
-				$query_values = array_merge($query_values,array(':year' => $year));
614
+				$query_values = array_merge($query_values, array(':year' => $year));
615 615
 			} else {
616 616
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
617
-				$query_values = array_merge($query_values,array(':year' => $year));
617
+				$query_values = array_merge($query_values, array(':year' => $year));
618 618
 			}
619 619
 		}
620 620
 		if ($month != '') {
621 621
 			if ($globalDBdriver == 'mysql') {
622 622
 				$query .= " AND MONTH(marine_output.date) = :month";
623
-				$query_values = array_merge($query_values,array(':month' => $month));
623
+				$query_values = array_merge($query_values, array(':month' => $month));
624 624
 			} else {
625 625
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
626
-				$query_values = array_merge($query_values,array(':month' => $month));
626
+				$query_values = array_merge($query_values, array(':month' => $month));
627 627
 			}
628 628
 		}
629 629
 		if ($day != '') {
630 630
 			if ($globalDBdriver == 'mysql') {
631 631
 				$query .= " AND DAY(marine_output.date) = :day";
632
-				$query_values = array_merge($query_values,array(':day' => $day));
632
+				$query_values = array_merge($query_values, array(':day' => $day));
633 633
 			} else {
634 634
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
635
-				$query_values = array_merge($query_values,array(':day' => $day));
635
+				$query_values = array_merge($query_values, array(':day' => $day));
636 636
 			}
637 637
 		}
638 638
 		$query .= " GROUP BY marine_output.type
639 639
 			ORDER BY type_count DESC";
640
-		$query_values = array_merge($query_values,array(':captain' => $captain));
640
+		$query_values = array_merge($query_values, array(':captain' => $captain));
641 641
 		$sth = $this->db->prepare($query);
642 642
 		$sth->execute($query_values);
643 643
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -649,44 +649,44 @@  discard block
 block discarded – undo
649 649
 	* @return Array the boat list
650 650
 	*
651 651
 	*/
652
-	public function countAllBoatTypesByRace($race,$filters = array(),$year = '',$month = '',$day = '')
652
+	public function countAllBoatTypesByRace($race, $filters = array(), $year = '', $month = '', $day = '')
653 653
 	{
654 654
 		global $globalDBdriver;
655
-		$filter_query = $this->getFilter($filters,true,true);
656
-		$race = filter_var($race,FILTER_SANITIZE_STRING);
657
-		$query  = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count
655
+		$filter_query = $this->getFilter($filters, true, true);
656
+		$race = filter_var($race, FILTER_SANITIZE_STRING);
657
+		$query = "SELECT DISTINCT marine_output.type, COUNT(marine_output.type) AS type_count
658 658
 			FROM marine_output".$filter_query." (marine_output.race_id = :race OR marine_output.race_name = :race)";
659 659
 		$query_values = array();
660 660
 		if ($year != '') {
661 661
 			if ($globalDBdriver == 'mysql') {
662 662
 				$query .= " AND YEAR(marine_output.date) = :year";
663
-				$query_values = array_merge($query_values,array(':year' => $year));
663
+				$query_values = array_merge($query_values, array(':year' => $year));
664 664
 			} else {
665 665
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
666
-				$query_values = array_merge($query_values,array(':year' => $year));
666
+				$query_values = array_merge($query_values, array(':year' => $year));
667 667
 			}
668 668
 		}
669 669
 		if ($month != '') {
670 670
 			if ($globalDBdriver == 'mysql') {
671 671
 				$query .= " AND MONTH(marine_output.date) = :month";
672
-				$query_values = array_merge($query_values,array(':month' => $month));
672
+				$query_values = array_merge($query_values, array(':month' => $month));
673 673
 			} else {
674 674
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
675
-				$query_values = array_merge($query_values,array(':month' => $month));
675
+				$query_values = array_merge($query_values, array(':month' => $month));
676 676
 			}
677 677
 		}
678 678
 		if ($day != '') {
679 679
 			if ($globalDBdriver == 'mysql') {
680 680
 				$query .= " AND DAY(marine_output.date) = :day";
681
-				$query_values = array_merge($query_values,array(':day' => $day));
681
+				$query_values = array_merge($query_values, array(':day' => $day));
682 682
 			} else {
683 683
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
684
-				$query_values = array_merge($query_values,array(':day' => $day));
684
+				$query_values = array_merge($query_values, array(':day' => $day));
685 685
 			}
686 686
 		}
687 687
 		$query .= " GROUP BY marine_output.type
688 688
 			ORDER BY type_count DESC";
689
-		$query_values = array_merge($query_values,array(':race' => $race));
689
+		$query_values = array_merge($query_values, array(':race' => $race));
690 690
 		$sth = $this->db->prepare($query);
691 691
 		$sth->execute($query_values);
692 692
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -698,47 +698,47 @@  discard block
 block discarded – undo
698 698
 	* @return String Duration of all race
699 699
 	*
700 700
 	*/
701
-	public function getRaceDurationByCaptain($captain,$filters = array(),$year = '',$month = '',$day = '')
701
+	public function getRaceDurationByCaptain($captain, $filters = array(), $year = '', $month = '', $day = '')
702 702
 	{
703 703
 		global $globalDBdriver;
704
-		$captain = filter_var($captain,FILTER_SANITIZE_STRING);
705
-		$filter_query = $this->getFilter($filters,true,true);
706
-		$query  = "SELECT SUM(last_seen - date) AS duration 
704
+		$captain = filter_var($captain, FILTER_SANITIZE_STRING);
705
+		$filter_query = $this->getFilter($filters, true, true);
706
+		$query = "SELECT SUM(last_seen - date) AS duration 
707 707
 		    FROM marine_output".$filter_query." (marine_output.captain_name = :captain OR marine_output.captain_id = :captain) 
708 708
 		    AND last_seen > date";
709 709
 		$query_values = array();
710 710
 		if ($year != '') {
711 711
 			if ($globalDBdriver == 'mysql') {
712 712
 				$query .= " AND YEAR(marine_output.date) = :year";
713
-				$query_values = array_merge($query_values,array(':year' => $year));
713
+				$query_values = array_merge($query_values, array(':year' => $year));
714 714
 			} else {
715 715
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
716
-				$query_values = array_merge($query_values,array(':year' => $year));
716
+				$query_values = array_merge($query_values, array(':year' => $year));
717 717
 			}
718 718
 		}
719 719
 		if ($month != '') {
720 720
 			if ($globalDBdriver == 'mysql') {
721 721
 				$query .= " AND MONTH(marine_output.date) = :month";
722
-				$query_values = array_merge($query_values,array(':month' => $month));
722
+				$query_values = array_merge($query_values, array(':month' => $month));
723 723
 			} else {
724 724
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
725
-				$query_values = array_merge($query_values,array(':month' => $month));
725
+				$query_values = array_merge($query_values, array(':month' => $month));
726 726
 			}
727 727
 		}
728 728
 		if ($day != '') {
729 729
 			if ($globalDBdriver == 'mysql') {
730 730
 				$query .= " AND DAY(marine_output.date) = :day";
731
-				$query_values = array_merge($query_values,array(':day' => $day));
731
+				$query_values = array_merge($query_values, array(':day' => $day));
732 732
 			} else {
733 733
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
734
-				$query_values = array_merge($query_values,array(':day' => $day));
734
+				$query_values = array_merge($query_values, array(':day' => $day));
735 735
 			}
736 736
 		}
737
-		$query_values = array_merge($query_values,array(':captain' => $captain));
737
+		$query_values = array_merge($query_values, array(':captain' => $captain));
738 738
 		$sth = $this->db->prepare($query);
739 739
 		$sth->execute($query_values);
740 740
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
741
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
741
+		if (is_int($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']);
742 742
 		else return $result[0]['duration'];
743 743
 	}
744 744
 
@@ -750,8 +750,8 @@  discard block
 block discarded – undo
750 750
 	*/
751 751
 	public function getAllCaptainNames($filters = array())
752 752
 	{
753
-		$filter_query = $this->getFilter($filters,true,true);
754
-		$query  = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id
753
+		$filter_query = $this->getFilter($filters, true, true);
754
+		$query = "SELECT DISTINCT marine_output.captain_name, marine_output.captain_id
755 755
 			FROM marine_output".$filter_query." marine_output.captain_name <> '' 
756 756
 			ORDER BY marine_output.captain_name ASC";
757 757
 	
@@ -768,8 +768,8 @@  discard block
 block discarded – undo
768 768
 	*/
769 769
 	public function getAllRaceNames($filters = array())
770 770
 	{
771
-		$filter_query = $this->getFilter($filters,true,true);
772
-		$query  = "SELECT DISTINCT marine_output.race_name, marine_output.race_id
771
+		$filter_query = $this->getFilter($filters, true, true);
772
+		$query = "SELECT DISTINCT marine_output.race_name, marine_output.race_id
773 773
 			FROM marine_output".$filter_query." marine_output.race_name <> '' 
774 774
 			ORDER BY marine_output.race_name ASC";
775 775
 	
@@ -785,11 +785,11 @@  discard block
 block discarded – undo
785 785
 	* @return Array list of source name
786 786
 	*
787 787
 	*/
788
-	public function getAllSourceName($type = '',$filters = array())
788
+	public function getAllSourceName($type = '', $filters = array())
789 789
 	{
790
-		$filter_query = $this->getFilter($filters,true,true);
790
+		$filter_query = $this->getFilter($filters, true, true);
791 791
 		$query_values = array();
792
-		$query  = "SELECT DISTINCT marine_output.source_name 
792
+		$query = "SELECT DISTINCT marine_output.source_name 
793 793
 				FROM marine_output".$filter_query." marine_output.source_name <> ''";
794 794
 		if ($type != '') {
795 795
 			$query_values = array(':type' => $type);
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 		$source_array = array();
805 805
 		$temp_array = array();
806 806
 		
807
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
807
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
808 808
 		{
809 809
 			$temp_array['source_name'] = $row['source_name'];
810 810
 			$source_array[] = $temp_array;
@@ -821,8 +821,8 @@  discard block
 block discarded – undo
821 821
 	*/
822 822
 	public function getAllIdents($filters = array())
823 823
 	{
824
-		$filter_query = $this->getFilter($filters,true,true);
825
-		$query  = "SELECT DISTINCT marine_output.ident
824
+		$filter_query = $this->getFilter($filters, true, true);
825
+		$query = "SELECT DISTINCT marine_output.ident
826 826
 								FROM marine_output".$filter_query." marine_output.ident <> '' 
827 827
 								ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0";
828 828
 
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
 		$ident_array = array();
833 833
 		$temp_array = array();
834 834
 		
835
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
835
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
836 836
 		{
837 837
 			$temp_array['ident'] = $row['ident'];
838 838
 			$ident_array[] = $temp_array;
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
 	*/
850 850
 	public function getIdentity($mmsi)
851 851
 	{
852
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
852
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
853 853
 		$query  = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1";
854 854
 		$sth = $this->db->prepare($query);
855 855
 		$sth->execute(array(':mmsi' => $mmsi));
@@ -862,23 +862,23 @@  discard block
 block discarded – undo
862 862
 	* Add identity
863 863
 	*
864 864
 	*/
865
-	public function addIdentity($mmsi,$imo,$ident,$callsign,$type)
865
+	public function addIdentity($mmsi, $imo, $ident, $callsign, $type)
866 866
 	{
867
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
867
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
868 868
 		if ($mmsi != '') {
869
-			$imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT);
870
-			$ident = filter_var($ident,FILTER_SANITIZE_STRING);
871
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
872
-			$type = filter_var($type,FILTER_SANITIZE_STRING);
869
+			$imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT);
870
+			$ident = filter_var($ident, FILTER_SANITIZE_STRING);
871
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
872
+			$type = filter_var($type, FILTER_SANITIZE_STRING);
873 873
 			$identinfo = $this->getIdentity($mmsi);
874 874
 			if (empty($identinfo)) {
875
-				$query  = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)";
875
+				$query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)";
876 876
 				$sth = $this->db->prepare($query);
877
-				$sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type));
877
+				$sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type));
878 878
 			} elseif ($ident != '' && $identinfo['ship_name'] != $ident) {
879
-				$query  = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi";
879
+				$query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi";
880 880
 				$sth = $this->db->prepare($query);
881
-				$sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type));
881
+				$sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type));
882 882
 			}
883 883
 		}
884 884
 	}
@@ -899,12 +899,12 @@  discard block
 block discarded – undo
899 899
 		} else $offset = '+00:00';
900 900
 
901 901
 		if ($globalDBdriver == 'mysql') {
902
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
902
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
903 903
 								FROM marine_output
904 904
 								WHERE marine_output.date <> '' 
905 905
 								ORDER BY marine_output.date ASC LIMIT 0,100";
906 906
 		} else {
907
-			$query  = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
907
+			$query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
908 908
 								FROM marine_output
909 909
 								WHERE marine_output.date <> '' 
910 910
 								ORDER BY marine_output.date ASC LIMIT 0,100";
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
 		$date_array = array();
917 917
 		$temp_array = array();
918 918
 		
919
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
919
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
920 920
 		{
921 921
 			$temp_array['date'] = $row['date'];
922 922
 
@@ -934,10 +934,10 @@  discard block
 block discarded – undo
934 934
 	* @return String success or false
935 935
 	*
936 936
 	*/
937
-	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
937
+	public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL)
938 938
 	{
939 939
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
940
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
940
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident);
941 941
 		try {
942 942
 			$sth = $this->db->prepare($query);
943 943
 			$sth->execute($query_values);
@@ -955,10 +955,10 @@  discard block
 block discarded – undo
955 955
 	* @return String success or false
956 956
 	*
957 957
 	*/
958
-	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL)
958
+	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL)
959 959
 	{
960 960
 		$query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id';
961
-		$query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code);
961
+		$query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code);
962 962
 		try {
963 963
 			$sth = $this->db->prepare($query);
964 964
 			$sth->execute($query_values);
@@ -977,11 +977,11 @@  discard block
 block discarded – undo
977 977
 	* @return String success or false
978 978
 	*
979 979
 	*/
980
-	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
980
+	public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '')
981 981
 	{
982 982
 
983 983
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
984
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
984
+                $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id);
985 985
 
986 986
 		try {
987 987
 			$sth = $this->db->prepare($query);
@@ -1001,17 +1001,17 @@  discard block
 block discarded – undo
1001 1001
 	* @return String success or false
1002 1002
 	*
1003 1003
 	*/	
1004
-	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '')
1004
+	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '', $distance = NULL, $race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '')
1005 1005
 	{
1006 1006
 		if ($latitude == '') $latitude = NULL;
1007 1007
 		if ($longitude == '') $longitude = NULL;
1008 1008
 		$groundspeed = round($groundspeed);
1009 1009
 		if ($race_begin != '') {
1010 1010
 			$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status, date = :race_begin WHERE fammarine_id = :fammarine_id';
1011
-			$query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time,':status' => $status,':race_begin' => $race_begin);
1011
+			$query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time, ':status' => $status, ':race_begin' => $race_begin);
1012 1012
 		} else {
1013 1013
 			$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status WHERE fammarine_id = :fammarine_id';
1014
-			$query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time,':status' => $status);
1014
+			$query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time, ':status' => $status);
1015 1015
 		}
1016 1016
 		try {
1017 1017
 			$sth = $this->db->prepare($query);
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
 	* @param String $verticalrate vertival rate of flight
1051 1051
 	* @return String success or false
1052 1052
 	*/
1053
-	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '',$race_rank = '', $race_time = '')
1053
+	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '')
1054 1054
 	{
1055 1055
 		global $globalURL, $globalMarineImageFetch;
1056 1056
 		
@@ -1122,34 +1122,34 @@  discard block
 block discarded – undo
1122 1122
 			$date = date("Y-m-d H:i:s", time());
1123 1123
 		}
1124 1124
 
1125
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1126
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1127
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1128
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1129
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1130
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1131
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1132
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
1133
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
1134
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
1135
-		$type_id = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT);
1136
-		$status_id = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT);
1137
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
1138
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
1139
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
1140
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
1141
-		$captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING);
1142
-		$captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING);
1143
-		$race_id = filter_var($race_id,FILTER_SANITIZE_STRING);
1144
-		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
1145
-		$race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT);
1146
-		$race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1147
-		$distance = filter_var($distance,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1125
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1126
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1127
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1128
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1129
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1130
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1131
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1132
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
1133
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
1134
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
1135
+		$type_id = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT);
1136
+		$status_id = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT);
1137
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
1138
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
1139
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
1140
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
1141
+		$captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING);
1142
+		$captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING);
1143
+		$race_id = filter_var($race_id, FILTER_SANITIZE_STRING);
1144
+		$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
1145
+		$race_rank = filter_var($race_rank, FILTER_SANITIZE_NUMBER_INT);
1146
+		$race_time = filter_var($race_time, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1147
+		$distance = filter_var($distance, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1148 1148
 		if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) {
1149 1149
 			$Image = new Image($this->db);
1150
-			$image_array = $Image->getMarineImage($mmsi,$imo,$ident);
1150
+			$image_array = $Image->getMarineImage($mmsi, $imo, $ident);
1151 1151
 			if (!isset($image_array[0]['mmsi'])) {
1152
-				$Image->addMarineImage($mmsi,$imo,$ident);
1152
+				$Image->addMarineImage($mmsi, $imo, $ident);
1153 1153
 			}
1154 1154
 			unset($Image);
1155 1155
 		}
@@ -1165,10 +1165,10 @@  discard block
 block discarded – undo
1165 1165
 		if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1166 1166
 		//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1167 1167
 		if ($arrival_date == '') $arrival_date = NULL;
1168
-		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) 
1168
+		$query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) 
1169 1169
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name, :distance, :race_rank,:race_time)";
1170 1170
 
1171
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':type_id' => $type_id,':status' => $status,':status_id' => $status_id,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time);
1171
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':type_id' => $type_id, ':status' => $status, ':status_id' => $status_id, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time);
1172 1172
 		try {
1173 1173
 			$sth = $this->db->prepare($query);
1174 1174
 			$sth->execute($query_values);
@@ -1192,13 +1192,13 @@  discard block
 block discarded – undo
1192 1192
 	{
1193 1193
 		global $globalDBdriver, $globalTimezone;
1194 1194
 		if ($globalDBdriver == 'mysql') {
1195
-			$query  = "SELECT marine_output.ident FROM marine_output 
1195
+			$query = "SELECT marine_output.ident FROM marine_output 
1196 1196
 								WHERE marine_output.ident = :ident 
1197 1197
 								AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
1198 1198
 								AND marine_output.date < UTC_TIMESTAMP()";
1199 1199
 			$query_data = array(':ident' => $ident);
1200 1200
 		} else {
1201
-			$query  = "SELECT marine_output.ident FROM marine_output 
1201
+			$query = "SELECT marine_output.ident FROM marine_output 
1202 1202
 								WHERE marine_output.ident = :ident 
1203 1203
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
1204 1204
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
@@ -1207,8 +1207,8 @@  discard block
 block discarded – undo
1207 1207
 		
1208 1208
 		$sth = $this->db->prepare($query);
1209 1209
 		$sth->execute($query_data);
1210
-    		$ident_result='';
1211
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1210
+    		$ident_result = '';
1211
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1212 1212
 		{
1213 1213
 			$ident_result = $row['ident'];
1214 1214
 		}
@@ -1234,8 +1234,8 @@  discard block
 block discarded – undo
1234 1234
 				return false;
1235 1235
 			} else {
1236 1236
 				$q_array = explode(" ", $q);
1237
-				foreach ($q_array as $q_item){
1238
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1237
+				foreach ($q_array as $q_item) {
1238
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
1239 1239
 					$additional_query .= " AND (";
1240 1240
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
1241 1241
 					$additional_query .= ")";
@@ -1243,11 +1243,11 @@  discard block
 block discarded – undo
1243 1243
 			}
1244 1244
 		}
1245 1245
 		if ($globalDBdriver == 'mysql') {
1246
-			$query  = "SELECT marine_output.* FROM marine_output 
1246
+			$query = "SELECT marine_output.* FROM marine_output 
1247 1247
 				WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
1248 1248
 				AND marine_output.date < UTC_TIMESTAMP()";
1249 1249
 		} else {
1250
-			$query  = "SELECT marine_output.* FROM marine_output 
1250
+			$query = "SELECT marine_output.* FROM marine_output 
1251 1251
 				WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
1252 1252
 				AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
1253 1253
 		}
@@ -1266,16 +1266,16 @@  discard block
 block discarded – undo
1266 1266
 	*
1267 1267
 	*/
1268 1268
 
1269
-	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
1269
+	public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
1270 1270
 	{
1271 1271
 		global $globalDBdriver, $globalArchive;
1272 1272
 		//$filter_query = $this->getFilter($filters,true,true);
1273
-		$Connection= new Connection($this->db);
1273
+		$Connection = new Connection($this->db);
1274 1274
 		if (!$Connection->tableExists('countries')) return array();
1275 1275
 		require_once('class.SpotterLive.php');
1276 1276
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
1277 1277
 			$MarineLive = new MarineLive($this->db);
1278
-			$filter_query = $MarineLive->getFilter($filters,true,true);
1278
+			$filter_query = $MarineLive->getFilter($filters, true, true);
1279 1279
 			$filter_query .= " over_country IS NOT NULL AND over_country <> ''";
1280 1280
 			if ($olderthanmonths > 0) {
1281 1281
 				if ($globalDBdriver == 'mysql') {
@@ -1295,7 +1295,7 @@  discard block
 block discarded – undo
1295 1295
 		} else {
1296 1296
 			require_once(dirname(__FILE__)."/class.MarineArchive.php");
1297 1297
 			$MarineArchive = new MarineArchive($this->db);
1298
-			$filter_query = $MarineArchive->getFilter($filters,true,true);
1298
+			$filter_query = $MarineArchive->getFilter($filters, true, true);
1299 1299
 			$filter_query .= " over_country <> ''";
1300 1300
 			if ($olderthanmonths > 0) {
1301 1301
 				if ($globalDBdriver == 'mysql') {
@@ -1323,7 +1323,7 @@  discard block
 block discarded – undo
1323 1323
 		$flight_array = array();
1324 1324
 		$temp_array = array();
1325 1325
         
1326
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1326
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1327 1327
 		{
1328 1328
 			$temp_array['marine_count'] = $row['nb'];
1329 1329
 			$temp_array['marine_country'] = $row['name'];
@@ -1342,11 +1342,11 @@  discard block
 block discarded – undo
1342 1342
 	* @return Array the callsign list
1343 1343
 	*
1344 1344
 	*/
1345
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
1345
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
1346 1346
 	{
1347 1347
 		global $globalDBdriver;
1348
-		$filter_query = $this->getFilter($filters,true,true);
1349
-		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
1348
+		$filter_query = $this->getFilter($filters, true, true);
1349
+		$query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
1350 1350
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
1351 1351
 		 if ($olderthanmonths > 0) {
1352 1352
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -1360,28 +1360,28 @@  discard block
 block discarded – undo
1360 1360
 		if ($year != '') {
1361 1361
 			if ($globalDBdriver == 'mysql') {
1362 1362
 				$query .= " AND YEAR(marine_output.date) = :year";
1363
-				$query_values = array_merge($query_values,array(':year' => $year));
1363
+				$query_values = array_merge($query_values, array(':year' => $year));
1364 1364
 			} else {
1365 1365
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1366
-				$query_values = array_merge($query_values,array(':year' => $year));
1366
+				$query_values = array_merge($query_values, array(':year' => $year));
1367 1367
 			}
1368 1368
 		}
1369 1369
 		if ($month != '') {
1370 1370
 			if ($globalDBdriver == 'mysql') {
1371 1371
 				$query .= " AND MONTH(marine_output.date) = :month";
1372
-				$query_values = array_merge($query_values,array(':month' => $month));
1372
+				$query_values = array_merge($query_values, array(':month' => $month));
1373 1373
 			} else {
1374 1374
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1375
-				$query_values = array_merge($query_values,array(':month' => $month));
1375
+				$query_values = array_merge($query_values, array(':month' => $month));
1376 1376
 			}
1377 1377
 		}
1378 1378
 		if ($day != '') {
1379 1379
 			if ($globalDBdriver == 'mysql') {
1380 1380
 				$query .= " AND DAY(marine_output.date) = :day";
1381
-				$query_values = array_merge($query_values,array(':day' => $day));
1381
+				$query_values = array_merge($query_values, array(':day' => $day));
1382 1382
 			} else {
1383 1383
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
1384
-				$query_values = array_merge($query_values,array(':day' => $day));
1384
+				$query_values = array_merge($query_values, array(':day' => $day));
1385 1385
 			}
1386 1386
 		}
1387 1387
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
@@ -1393,7 +1393,7 @@  discard block
 block discarded – undo
1393 1393
 		$callsign_array = array();
1394 1394
 		$temp_array = array();
1395 1395
         
1396
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1396
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1397 1397
 		{
1398 1398
 			$temp_array['callsign_icao'] = $row['ident'];
1399 1399
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -1445,7 +1445,7 @@  discard block
 block discarded – undo
1445 1445
 		$date_array = array();
1446 1446
 		$temp_array = array();
1447 1447
         
1448
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1448
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1449 1449
 		{
1450 1450
 			$temp_array['date_name'] = $row['date_name'];
1451 1451
 			$temp_array['date_count'] = $row['date_count'];
@@ -1471,7 +1471,7 @@  discard block
 block discarded – undo
1471 1471
 			$datetime = new DateTime();
1472 1472
 			$offset = $datetime->format('P');
1473 1473
 		} else $offset = '+00:00';
1474
-		$filter_query = $this->getFilter($filters,true,true);
1474
+		$filter_query = $this->getFilter($filters, true, true);
1475 1475
 		if ($globalDBdriver == 'mysql') {
1476 1476
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1477 1477
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -1492,7 +1492,7 @@  discard block
 block discarded – undo
1492 1492
 		$date_array = array();
1493 1493
 		$temp_array = array();
1494 1494
         
1495
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1495
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1496 1496
 		{
1497 1497
 			$temp_array['date_name'] = $row['date_name'];
1498 1498
 			$temp_array['date_count'] = $row['date_count'];
@@ -1517,7 +1517,7 @@  discard block
 block discarded – undo
1517 1517
 			$datetime = new DateTime();
1518 1518
 			$offset = $datetime->format('P');
1519 1519
 		} else $offset = '+00:00';
1520
-		$filter_query = $this->getFilter($filters,true,true);
1520
+		$filter_query = $this->getFilter($filters, true, true);
1521 1521
 		if ($globalDBdriver == 'mysql') {
1522 1522
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1523 1523
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1538,7 +1538,7 @@  discard block
 block discarded – undo
1538 1538
 		$date_array = array();
1539 1539
 		$temp_array = array();
1540 1540
         
1541
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1541
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1542 1542
 		{
1543 1543
 			$temp_array['date_name'] = $row['date_name'];
1544 1544
 			$temp_array['date_count'] = $row['date_count'];
@@ -1585,7 +1585,7 @@  discard block
 block discarded – undo
1585 1585
 		$date_array = array();
1586 1586
 		$temp_array = array();
1587 1587
         
1588
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1588
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1589 1589
 		{
1590 1590
 			$temp_array['month_name'] = $row['month_name'];
1591 1591
 			$temp_array['year_name'] = $row['year_name'];
@@ -1614,7 +1614,7 @@  discard block
 block discarded – undo
1614 1614
 			$datetime = new DateTime();
1615 1615
 			$offset = $datetime->format('P');
1616 1616
 		} else $offset = '+00:00';
1617
-		$filter_query = $this->getFilter($filters,true,true);
1617
+		$filter_query = $this->getFilter($filters, true, true);
1618 1618
 		if ($globalDBdriver == 'mysql') {
1619 1619
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
1620 1620
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1635,7 +1635,7 @@  discard block
 block discarded – undo
1635 1635
 		$date_array = array();
1636 1636
 		$temp_array = array();
1637 1637
         
1638
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1638
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1639 1639
 		{
1640 1640
 			$temp_array['year_name'] = $row['year_name'];
1641 1641
 			$temp_array['month_name'] = $row['month_name'];
@@ -1655,7 +1655,7 @@  discard block
 block discarded – undo
1655 1655
 	* @return Array the hour list
1656 1656
 	*
1657 1657
 	*/
1658
-	public function countAllHours($orderby,$filters = array())
1658
+	public function countAllHours($orderby, $filters = array())
1659 1659
 	{
1660 1660
 		global $globalTimezone, $globalDBdriver;
1661 1661
 		if ($globalTimezone != '') {
@@ -1703,7 +1703,7 @@  discard block
 block discarded – undo
1703 1703
 		$hour_array = array();
1704 1704
 		$temp_array = array();
1705 1705
         
1706
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1706
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1707 1707
 		{
1708 1708
 			$temp_array['hour_name'] = $row['hour_name'];
1709 1709
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1725,8 +1725,8 @@  discard block
 block discarded – undo
1725 1725
 	public function countAllHoursByDate($date, $filters = array())
1726 1726
 	{
1727 1727
 		global $globalTimezone, $globalDBdriver;
1728
-		$filter_query = $this->getFilter($filters,true,true);
1729
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1728
+		$filter_query = $this->getFilter($filters, true, true);
1729
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1730 1730
 		if ($globalTimezone != '') {
1731 1731
 			date_default_timezone_set($globalTimezone);
1732 1732
 			$datetime = new DateTime($date);
@@ -1734,12 +1734,12 @@  discard block
 block discarded – undo
1734 1734
 		} else $offset = '+00:00';
1735 1735
 
1736 1736
 		if ($globalDBdriver == 'mysql') {
1737
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1737
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1738 1738
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date
1739 1739
 								GROUP BY hour_name 
1740 1740
 								ORDER BY hour_name ASC";
1741 1741
 		} else {
1742
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1742
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1743 1743
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1744 1744
 								GROUP BY hour_name 
1745 1745
 								ORDER BY hour_name ASC";
@@ -1751,7 +1751,7 @@  discard block
 block discarded – undo
1751 1751
 		$hour_array = array();
1752 1752
 		$temp_array = array();
1753 1753
         
1754
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1754
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1755 1755
 		{
1756 1756
 			$temp_array['hour_name'] = $row['hour_name'];
1757 1757
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1773,8 +1773,8 @@  discard block
 block discarded – undo
1773 1773
 	public function countAllHoursByIdent($ident, $filters = array())
1774 1774
 	{
1775 1775
 		global $globalTimezone, $globalDBdriver;
1776
-		$filter_query = $this->getFilter($filters,true,true);
1777
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1776
+		$filter_query = $this->getFilter($filters, true, true);
1777
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1778 1778
 		if ($globalTimezone != '') {
1779 1779
 			date_default_timezone_set($globalTimezone);
1780 1780
 			$datetime = new DateTime();
@@ -1782,12 +1782,12 @@  discard block
 block discarded – undo
1782 1782
 		} else $offset = '+00:00';
1783 1783
 
1784 1784
 		if ($globalDBdriver == 'mysql') {
1785
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1785
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1786 1786
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1787 1787
 								GROUP BY hour_name 
1788 1788
 								ORDER BY hour_name ASC";
1789 1789
 		} else {
1790
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1790
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1791 1791
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1792 1792
 								GROUP BY hour_name 
1793 1793
 								ORDER BY hour_name ASC";
@@ -1795,12 +1795,12 @@  discard block
 block discarded – undo
1795 1795
       
1796 1796
 		
1797 1797
 		$sth = $this->db->prepare($query);
1798
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1798
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1799 1799
       
1800 1800
 		$hour_array = array();
1801 1801
 		$temp_array = array();
1802 1802
         
1803
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1803
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1804 1804
 		{
1805 1805
 			$temp_array['hour_name'] = $row['hour_name'];
1806 1806
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1819,33 +1819,33 @@  discard block
 block discarded – undo
1819 1819
 	* @return Integer the number of vessels
1820 1820
 	*
1821 1821
 	*/
1822
-	public function countOverallMarine($filters = array(),$year = '',$month = '')
1822
+	public function countOverallMarine($filters = array(), $year = '', $month = '')
1823 1823
 	{
1824 1824
 		global $globalDBdriver;
1825 1825
 		//$queryi  = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1826
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1826
+		$queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1827 1827
 		$query_values = array();
1828 1828
 		$query = '';
1829 1829
 		if ($year != '') {
1830 1830
 			if ($globalDBdriver == 'mysql') {
1831 1831
 				$query .= " AND YEAR(marine_output.date) = :year";
1832
-				$query_values = array_merge($query_values,array(':year' => $year));
1832
+				$query_values = array_merge($query_values, array(':year' => $year));
1833 1833
 			} else {
1834 1834
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1835
-				$query_values = array_merge($query_values,array(':year' => $year));
1835
+				$query_values = array_merge($query_values, array(':year' => $year));
1836 1836
 			}
1837 1837
 		}
1838 1838
 		if ($month != '') {
1839 1839
 			if ($globalDBdriver == 'mysql') {
1840 1840
 				$query .= " AND MONTH(marine_output.date) = :month";
1841
-				$query_values = array_merge($query_values,array(':month' => $month));
1841
+				$query_values = array_merge($query_values, array(':month' => $month));
1842 1842
 			} else {
1843 1843
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1844
-				$query_values = array_merge($query_values,array(':month' => $month));
1844
+				$query_values = array_merge($query_values, array(':month' => $month));
1845 1845
 			}
1846 1846
 		}
1847 1847
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1848
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1848
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1849 1849
 		
1850 1850
 		$sth = $this->db->prepare($queryi);
1851 1851
 		$sth->execute($query_values);
@@ -1858,32 +1858,32 @@  discard block
 block discarded – undo
1858 1858
 	* @return Integer the number of vessels
1859 1859
 	*
1860 1860
 	*/
1861
-	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
1861
+	public function countOverallMarineTypes($filters = array(), $year = '', $month = '')
1862 1862
 	{
1863 1863
 		global $globalDBdriver;
1864
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
1864
+		$queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
1865 1865
 		$query_values = array();
1866 1866
 		$query = '';
1867 1867
 		if ($year != '') {
1868 1868
 			if ($globalDBdriver == 'mysql') {
1869 1869
 				$query .= " AND YEAR(marine_output.date) = :year";
1870
-				$query_values = array_merge($query_values,array(':year' => $year));
1870
+				$query_values = array_merge($query_values, array(':year' => $year));
1871 1871
 			} else {
1872 1872
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1873
-				$query_values = array_merge($query_values,array(':year' => $year));
1873
+				$query_values = array_merge($query_values, array(':year' => $year));
1874 1874
 			}
1875 1875
 		}
1876 1876
 		if ($month != '') {
1877 1877
 			if ($globalDBdriver == 'mysql') {
1878 1878
 				$query .= " AND MONTH(marine_output.date) = :month";
1879
-				$query_values = array_merge($query_values,array(':month' => $month));
1879
+				$query_values = array_merge($query_values, array(':month' => $month));
1880 1880
 			} else {
1881 1881
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1882
-				$query_values = array_merge($query_values,array(':month' => $month));
1882
+				$query_values = array_merge($query_values, array(':month' => $month));
1883 1883
 			}
1884 1884
 		}
1885 1885
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1886
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1886
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1887 1887
 		
1888 1888
 		$sth = $this->db->prepare($queryi);
1889 1889
 		$sth->execute($query_values);
@@ -1900,7 +1900,7 @@  discard block
 block discarded – undo
1900 1900
 	public function countAllHoursFromToday($filters = array())
1901 1901
 	{
1902 1902
 		global $globalTimezone, $globalDBdriver;
1903
-		$filter_query = $this->getFilter($filters,true,true);
1903
+		$filter_query = $this->getFilter($filters, true, true);
1904 1904
 		if ($globalTimezone != '') {
1905 1905
 			date_default_timezone_set($globalTimezone);
1906 1906
 			$datetime = new DateTime();
@@ -1908,12 +1908,12 @@  discard block
 block discarded – undo
1908 1908
 		} else $offset = '+00:00';
1909 1909
 
1910 1910
 		if ($globalDBdriver == 'mysql') {
1911
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1911
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1912 1912
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE()
1913 1913
 								GROUP BY hour_name 
1914 1914
 								ORDER BY hour_name ASC";
1915 1915
 		} else {
1916
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1916
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1917 1917
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1918 1918
 								GROUP BY hour_name 
1919 1919
 								ORDER BY hour_name ASC";
@@ -1925,7 +1925,7 @@  discard block
 block discarded – undo
1925 1925
 		$hour_array = array();
1926 1926
 		$temp_array = array();
1927 1927
         
1928
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1928
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1929 1929
 		{
1930 1930
 			$temp_array['hour_name'] = $row['hour_name'];
1931 1931
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1944,9 +1944,9 @@  discard block
 block discarded – undo
1944 1944
 	*/
1945 1945
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1946 1946
 	{
1947
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1947
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1948 1948
 
1949
-		$query  = "SELECT marine_output.marine_id
1949
+		$query = "SELECT marine_output.marine_id
1950 1950
 				FROM marine_output 
1951 1951
 				WHERE marine_output.fammarine_id = '".$fammarine_id."'";
1952 1952
         
@@ -1954,7 +1954,7 @@  discard block
 block discarded – undo
1954 1954
 		$sth = $this->db->prepare($query);
1955 1955
 		$sth->execute();
1956 1956
 
1957
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1957
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1958 1958
 		{
1959 1959
 			return $row['marine_id'];
1960 1960
 		}
@@ -1979,23 +1979,23 @@  discard block
 block discarded – undo
1979 1979
 		}
1980 1980
 		
1981 1981
 		$current_date = date("Y-m-d H:i:s");
1982
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1982
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1983 1983
 		
1984 1984
 		$diff = abs(strtotime($current_date) - strtotime($date));
1985 1985
 
1986
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1986
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1987 1987
 		$years = $time_array['years'];
1988 1988
 		
1989
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1989
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1990 1990
 		$months = $time_array['months'];
1991 1991
 		
1992
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1992
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1993 1993
 		$days = $time_array['days'];
1994
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1994
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1995 1995
 		$hours = $time_array['hours'];
1996
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1996
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1997 1997
 		$minutes = $time_array['minutes'];
1998
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1998
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1999 1999
 		
2000 2000
 		return $time_array;
2001 2001
 	}
@@ -2018,63 +2018,63 @@  discard block
 block discarded – undo
2018 2018
 			$temp_array['direction_degree'] = $direction;
2019 2019
 			$temp_array['direction_shortname'] = "N";
2020 2020
 			$temp_array['direction_fullname'] = "North";
2021
-		} elseif ($direction >= 22.5 && $direction < 45){
2021
+		} elseif ($direction >= 22.5 && $direction < 45) {
2022 2022
 			$temp_array['direction_degree'] = $direction;
2023 2023
 			$temp_array['direction_shortname'] = "NNE";
2024 2024
 			$temp_array['direction_fullname'] = "North-Northeast";
2025
-		} elseif ($direction >= 45 && $direction < 67.5){
2025
+		} elseif ($direction >= 45 && $direction < 67.5) {
2026 2026
 			$temp_array['direction_degree'] = $direction;
2027 2027
 			$temp_array['direction_shortname'] = "NE";
2028 2028
 			$temp_array['direction_fullname'] = "Northeast";
2029
-		} elseif ($direction >= 67.5 && $direction < 90){
2029
+		} elseif ($direction >= 67.5 && $direction < 90) {
2030 2030
 			$temp_array['direction_degree'] = $direction;
2031 2031
 			$temp_array['direction_shortname'] = "ENE";
2032 2032
 			$temp_array['direction_fullname'] = "East-Northeast";
2033
-		} elseif ($direction >= 90 && $direction < 112.5){
2033
+		} elseif ($direction >= 90 && $direction < 112.5) {
2034 2034
 			$temp_array['direction_degree'] = $direction;
2035 2035
 			$temp_array['direction_shortname'] = "E";
2036 2036
 			$temp_array['direction_fullname'] = "East";
2037
-		} elseif ($direction >= 112.5 && $direction < 135){
2037
+		} elseif ($direction >= 112.5 && $direction < 135) {
2038 2038
 			$temp_array['direction_degree'] = $direction;
2039 2039
 			$temp_array['direction_shortname'] = "ESE";
2040 2040
 			$temp_array['direction_fullname'] = "East-Southeast";
2041
-		} elseif ($direction >= 135 && $direction < 157.5){
2041
+		} elseif ($direction >= 135 && $direction < 157.5) {
2042 2042
 			$temp_array['direction_degree'] = $direction;
2043 2043
 			$temp_array['direction_shortname'] = "SE";
2044 2044
 			$temp_array['direction_fullname'] = "Southeast";
2045
-		} elseif ($direction >= 157.5 && $direction < 180){
2045
+		} elseif ($direction >= 157.5 && $direction < 180) {
2046 2046
 			$temp_array['direction_degree'] = $direction;
2047 2047
 			$temp_array['direction_shortname'] = "SSE";
2048 2048
 			$temp_array['direction_fullname'] = "South-Southeast";
2049
-		} elseif ($direction >= 180 && $direction < 202.5){
2049
+		} elseif ($direction >= 180 && $direction < 202.5) {
2050 2050
 			$temp_array['direction_degree'] = $direction;
2051 2051
 			$temp_array['direction_shortname'] = "S";
2052 2052
 			$temp_array['direction_fullname'] = "South";
2053
-		} elseif ($direction >= 202.5 && $direction < 225){
2053
+		} elseif ($direction >= 202.5 && $direction < 225) {
2054 2054
 			$temp_array['direction_degree'] = $direction;
2055 2055
 			$temp_array['direction_shortname'] = "SSW";
2056 2056
 			$temp_array['direction_fullname'] = "South-Southwest";
2057
-		} elseif ($direction >= 225 && $direction < 247.5){
2057
+		} elseif ($direction >= 225 && $direction < 247.5) {
2058 2058
 			$temp_array['direction_degree'] = $direction;
2059 2059
 			$temp_array['direction_shortname'] = "SW";
2060 2060
 			$temp_array['direction_fullname'] = "Southwest";
2061
-		} elseif ($direction >= 247.5 && $direction < 270){
2061
+		} elseif ($direction >= 247.5 && $direction < 270) {
2062 2062
 			$temp_array['direction_degree'] = $direction;
2063 2063
 			$temp_array['direction_shortname'] = "WSW";
2064 2064
 			$temp_array['direction_fullname'] = "West-Southwest";
2065
-		} elseif ($direction >= 270 && $direction < 292.5){
2065
+		} elseif ($direction >= 270 && $direction < 292.5) {
2066 2066
 			$temp_array['direction_degree'] = $direction;
2067 2067
 			$temp_array['direction_shortname'] = "W";
2068 2068
 			$temp_array['direction_fullname'] = "West";
2069
-		} elseif ($direction >= 292.5 && $direction < 315){
2069
+		} elseif ($direction >= 292.5 && $direction < 315) {
2070 2070
 			$temp_array['direction_degree'] = $direction;
2071 2071
 			$temp_array['direction_shortname'] = "WNW";
2072 2072
 			$temp_array['direction_fullname'] = "West-Northwest";
2073
-		} elseif ($direction >= 315 && $direction < 337.5){
2073
+		} elseif ($direction >= 315 && $direction < 337.5) {
2074 2074
 			$temp_array['direction_degree'] = $direction;
2075 2075
 			$temp_array['direction_shortname'] = "NW";
2076 2076
 			$temp_array['direction_fullname'] = "Northwest";
2077
-		} elseif ($direction >= 337.5 && $direction < 360){
2077
+		} elseif ($direction >= 337.5 && $direction < 360) {
2078 2078
 			$temp_array['direction_degree'] = $direction;
2079 2079
 			$temp_array['direction_shortname'] = "NNW";
2080 2080
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -2091,11 +2091,11 @@  discard block
 block discarded – undo
2091 2091
 	* @param Float $longitude longitute of the flight
2092 2092
 	* @return String the countrie
2093 2093
 	*/
2094
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
2094
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
2095 2095
 	{
2096 2096
 		global $globalDBdriver, $globalDebug;
2097
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2098
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2097
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2098
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2099 2099
 	
2100 2100
 		$Connection = new Connection($this->db);
2101 2101
 		if (!$Connection->tableExists('countries')) return '';
@@ -2135,7 +2135,7 @@  discard block
 block discarded – undo
2135 2135
 	public function getCountryFromISO2($iso2)
2136 2136
 	{
2137 2137
 		global $globalDBdriver, $globalDebug;
2138
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
2138
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
2139 2139
 	
2140 2140
 		$Connection = new Connection($this->db);
2141 2141
 		if (!$Connection->tableExists('countries')) return '';
@@ -2183,7 +2183,7 @@  discard block
 block discarded – undo
2183 2183
 		
2184 2184
 		$bitly_data = json_decode($bitly_data);
2185 2185
 		$bitly_url = '';
2186
-		if ($bitly_data->status_txt = "OK"){
2186
+		if ($bitly_data->status_txt = "OK") {
2187 2187
 			$bitly_url = $bitly_data->data->url;
2188 2188
 		}
2189 2189
 
@@ -2197,11 +2197,11 @@  discard block
 block discarded – undo
2197 2197
 	* @return Array the vessel type list
2198 2198
 	*
2199 2199
 	*/
2200
-	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
2200
+	public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
2201 2201
 	{
2202 2202
 		global $globalDBdriver;
2203
-		$filter_query = $this->getFilter($filters,true,true);
2204
-		$query  = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id 
2203
+		$filter_query = $this->getFilter($filters, true, true);
2204
+		$query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id 
2205 2205
 		    FROM marine_output ".$filter_query." marine_output.type <> '' AND marine_output.type_id IS NOT NULL";
2206 2206
 		if ($olderthanmonths > 0) {
2207 2207
 			if ($globalDBdriver == 'mysql') {
@@ -2221,28 +2221,28 @@  discard block
 block discarded – undo
2221 2221
 		if ($year != '') {
2222 2222
 			if ($globalDBdriver == 'mysql') {
2223 2223
 				$query .= " AND YEAR(marine_output.date) = :year";
2224
-				$query_values = array_merge($query_values,array(':year' => $year));
2224
+				$query_values = array_merge($query_values, array(':year' => $year));
2225 2225
 			} else {
2226 2226
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
2227
-				$query_values = array_merge($query_values,array(':year' => $year));
2227
+				$query_values = array_merge($query_values, array(':year' => $year));
2228 2228
 			}
2229 2229
 		}
2230 2230
 		if ($month != '') {
2231 2231
 			if ($globalDBdriver == 'mysql') {
2232 2232
 				$query .= " AND MONTH(marine_output.date) = :month";
2233
-				$query_values = array_merge($query_values,array(':month' => $month));
2233
+				$query_values = array_merge($query_values, array(':month' => $month));
2234 2234
 			} else {
2235 2235
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
2236
-				$query_values = array_merge($query_values,array(':month' => $month));
2236
+				$query_values = array_merge($query_values, array(':month' => $month));
2237 2237
 			}
2238 2238
 		}
2239 2239
 		if ($day != '') {
2240 2240
 			if ($globalDBdriver == 'mysql') {
2241 2241
 				$query .= " AND DAY(marine_output.date) = :day";
2242
-				$query_values = array_merge($query_values,array(':day' => $day));
2242
+				$query_values = array_merge($query_values, array(':day' => $day));
2243 2243
 			} else {
2244 2244
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
2245
-				$query_values = array_merge($query_values,array(':day' => $day));
2245
+				$query_values = array_merge($query_values, array(':day' => $day));
2246 2246
 			}
2247 2247
 		}
2248 2248
 		$query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC";
@@ -2251,7 +2251,7 @@  discard block
 block discarded – undo
2251 2251
 		$sth->execute($query_values);
2252 2252
 		$marine_array = array();
2253 2253
 		$temp_array = array();
2254
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2254
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2255 2255
 		{
2256 2256
 			$temp_array['marine_type'] = $row['marine_type'];
2257 2257
 			$temp_array['marine_type_id'] = $row['marine_type_id'];
@@ -2267,13 +2267,13 @@  discard block
 block discarded – undo
2267 2267
 	* @return Array the tracker information
2268 2268
 	*
2269 2269
 	*/
2270
-	public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array())
2270
+	public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
2271 2271
 	{
2272 2272
 		global $globalTimezone, $globalDBdriver;
2273 2273
 		date_default_timezone_set('UTC');
2274 2274
 		$query_values = array();
2275 2275
 		$additional_query = '';
2276
-		$filter_query = $this->getFilter($filters,true,true);
2276
+		$filter_query = $this->getFilter($filters, true, true);
2277 2277
 		if ($q != "")
2278 2278
 		{
2279 2279
 			if (!is_string($q))
@@ -2281,8 +2281,8 @@  discard block
 block discarded – undo
2281 2281
 				return false;
2282 2282
 			} else {
2283 2283
 				$q_array = explode(" ", $q);
2284
-				foreach ($q_array as $q_item){
2285
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
2284
+				foreach ($q_array as $q_item) {
2285
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
2286 2286
 					$additional_query .= " AND (";
2287 2287
 					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
2288 2288
 					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
@@ -2294,42 +2294,42 @@  discard block
 block discarded – undo
2294 2294
 		}
2295 2295
 		if ($callsign != "")
2296 2296
 		{
2297
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2297
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
2298 2298
 			if (!is_string($callsign))
2299 2299
 			{
2300 2300
 				return false;
2301 2301
 			} else {
2302 2302
 				$additional_query .= " AND marine_output.ident = :callsign";
2303
-				$query_values = array_merge($query_values,array(':callsign' => $callsign));
2303
+				$query_values = array_merge($query_values, array(':callsign' => $callsign));
2304 2304
 			}
2305 2305
 		}
2306 2306
 		if ($mmsi != "")
2307 2307
 		{
2308
-			$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
2308
+			$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
2309 2309
 			if (!is_numeric($mmsi))
2310 2310
 			{
2311 2311
 				return false;
2312 2312
 			} else {
2313 2313
 				$additional_query .= " AND marine_output.mmsi = :mmsi";
2314
-				$query_values = array_merge($query_values,array(':mmsi' => $mmsi));
2314
+				$query_values = array_merge($query_values, array(':mmsi' => $mmsi));
2315 2315
 			}
2316 2316
 		}
2317 2317
 		if ($imo != "")
2318 2318
 		{
2319
-			$imo = filter_var($imo,FILTER_SANITIZE_STRING);
2319
+			$imo = filter_var($imo, FILTER_SANITIZE_STRING);
2320 2320
 			if (!is_numeric($imo))
2321 2321
 			{
2322 2322
 				return false;
2323 2323
 			} else {
2324 2324
 				$additional_query .= " AND marine_output.imo = :imo";
2325
-				$query_values = array_merge($query_values,array(':imo' => $imo));
2325
+				$query_values = array_merge($query_values, array(':imo' => $imo));
2326 2326
 			}
2327 2327
 		}
2328 2328
 		if ($date_posted != "")
2329 2329
 		{
2330 2330
 			$date_array = explode(",", $date_posted);
2331
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
2332
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
2331
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
2332
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
2333 2333
 			if ($globalTimezone != '') {
2334 2334
 				date_default_timezone_set($globalTimezone);
2335 2335
 				$datetime = new DateTime();
@@ -2356,8 +2356,8 @@  discard block
 block discarded – undo
2356 2356
 		if ($limit != "")
2357 2357
 		{
2358 2358
 			$limit_array = explode(",", $limit);
2359
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
2360
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
2359
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
2360
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
2361 2361
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
2362 2362
 			{
2363 2363
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -2375,22 +2375,22 @@  discard block
 block discarded – undo
2375 2375
 			}
2376 2376
 		}
2377 2377
 		if ($origLat != "" && $origLon != "" && $dist != "") {
2378
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
2378
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
2379 2379
 			if ($globalDBdriver == 'mysql') {
2380
-				$query="SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance 
2380
+				$query = "SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance 
2381 2381
 				    FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND marine_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and marine_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
2382 2382
 				    AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query;
2383 2383
 			} else {
2384
-				$query="SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
2384
+				$query = "SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
2385 2385
 				    FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
2386 2386
 				    AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query;
2387 2387
 			}
2388 2388
 		} else {
2389
-			$query  = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' 
2389
+			$query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' 
2390 2390
 			    ".$additional_query."
2391 2391
 			    ".$orderby_query;
2392 2392
 		}
2393
-		$marine_array = $this->getDataFromDB($query, $query_values,$limit_query);
2393
+		$marine_array = $this->getDataFromDB($query, $query_values, $limit_query);
2394 2394
 		return $marine_array;
2395 2395
 	}
2396 2396
 
@@ -2403,12 +2403,12 @@  discard block
 block discarded – undo
2403 2403
 	public function checkId($id)
2404 2404
 	{
2405 2405
 		global $globalDBdriver, $globalTimezone;
2406
-		$query  = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id';
2406
+		$query = 'SELECT marine_output.ident, marine_output.fammarine_id FROM marine_output WHERE marine_output.fammarine_id = :id';
2407 2407
 		$query_data = array(':id' => $id);
2408 2408
 		$sth = $this->db->prepare($query);
2409 2409
 		$sth->execute($query_data);
2410
-		$ident_result='';
2411
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2410
+		$ident_result = '';
2411
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2412 2412
 		{
2413 2413
 			$ident_result = $row['fammarine_id'];
2414 2414
 		}
@@ -2423,7 +2423,7 @@  discard block
 block discarded – undo
2423 2423
 	*/
2424 2424
 	public function getRaceByName($race_name)
2425 2425
 	{
2426
-		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
2426
+		$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
2427 2427
 		$query  = "SELECT * FROM marine_race WHERE race_name = :race_name LIMIT 1";
2428 2428
 		$sth = $this->db->prepare($query);
2429 2429
 		$sth->execute(array(':race_name' => $race_name));
@@ -2440,7 +2440,7 @@  discard block
 block discarded – undo
2440 2440
 	*/
2441 2441
 	public function getRace($race_id)
2442 2442
 	{
2443
-		$race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT);
2443
+		$race_id = filter_var($race_id, FILTER_SANITIZE_NUMBER_INT);
2444 2444
 		$query  = "SELECT * FROM marine_race WHERE race_id = :race_id LIMIT 1";
2445 2445
 		$sth = $this->db->prepare($query);
2446 2446
 		$sth->execute(array(':race_id' => $race_id));
@@ -2453,24 +2453,24 @@  discard block
 block discarded – undo
2453 2453
 	* Add race
2454 2454
 	*
2455 2455
 	*/
2456
-	public function addRace($race_id,$race_name,$race_creator,$race_desc,$race_startdate,$race_markers)
2456
+	public function addRace($race_id, $race_name, $race_creator, $race_desc, $race_startdate, $race_markers)
2457 2457
 	{
2458
-		$race_id = filter_var($race_id,FILTER_SANITIZE_NUMBER_INT);
2458
+		$race_id = filter_var($race_id, FILTER_SANITIZE_NUMBER_INT);
2459 2459
 		if ($race_id != '') {
2460
-			$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
2461
-			$race_creator = filter_var($race_creator,FILTER_SANITIZE_STRING);
2462
-			$race_desc = filter_var($race_desc,FILTER_SANITIZE_STRING);
2463
-			$race_startdate = filter_var($race_startdate,FILTER_SANITIZE_STRING);
2460
+			$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
2461
+			$race_creator = filter_var($race_creator, FILTER_SANITIZE_STRING);
2462
+			$race_desc = filter_var($race_desc, FILTER_SANITIZE_STRING);
2463
+			$race_startdate = filter_var($race_startdate, FILTER_SANITIZE_STRING);
2464 2464
 			//$race_markers = filter_var($race_markers,FILTER_SANITIZE_STRING);
2465 2465
 			$allrace = $this->getRace($race_id);
2466 2466
 			if (empty($allrace)) {
2467 2467
 				$query  = "INSERT INTO marine_race (race_id,race_name,race_creator,race_desc,race_startdate,race_markers) VALUES (:race_id,:race_name,:race_creator,:race_desc,:race_startdate,:race_markers)";
2468 2468
 				$sth = $this->db->prepare($query);
2469
-				$sth->execute(array(':race_id' => $race_id,':race_name' => $race_name,':race_creator' => $race_creator,':race_desc' => $race_desc,':race_startdate' => $race_startdate,':race_markers' => $race_markers));
2469
+				$sth->execute(array(':race_id' => $race_id, ':race_name' => $race_name, ':race_creator' => $race_creator, ':race_desc' => $race_desc, ':race_startdate' => $race_startdate, ':race_markers' => $race_markers));
2470 2470
 			} elseif ($race_id != '') {
2471
-				$query  = "UPDATE marine_race SET race_name = :race_name,race_desc = :race_desc,race_startdate = :race_startdate,race_markers = :race_markers WHERE race_id = :race_id";
2471
+				$query = "UPDATE marine_race SET race_name = :race_name,race_desc = :race_desc,race_startdate = :race_startdate,race_markers = :race_markers WHERE race_id = :race_id";
2472 2472
 				$sth = $this->db->prepare($query);
2473
-				$sth->execute(array(':race_id' => $race_id,':race_name' => $race_name,':race_desc' => $race_desc,':race_startdate' => $race_startdate,':race_markers' => $race_markers));
2473
+				$sth->execute(array(':race_id' => $race_id, ':race_name' => $race_name, ':race_desc' => $race_desc, ':race_startdate' => $race_startdate, ':race_markers' => $race_markers));
2474 2474
 			}
2475 2475
 		}
2476 2476
 	}
@@ -2479,7 +2479,7 @@  discard block
 block discarded – undo
2479 2479
 
2480 2480
 	public function getOrderBy()
2481 2481
 	{
2482
-		$orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure port - ASC", "sql" => "ORDER BY marine_output.departure_port_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
2482
+		$orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure port - ASC", "sql" => "ORDER BY marine_output.departure_port_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
2483 2483
 		
2484 2484
 		return $orderby;
2485 2485
 		
Please login to merge, or discard this patch.
Braces   +254 added lines, -90 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (Marine)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (Marine)');
13
+		}
12 14
 	}
13 15
 
14 16
 	/**
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -78,8 +82,11 @@  discard block
 block discarded – undo
78 82
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
79 83
 			}
80 84
 		}
81
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
82
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
85
+		if ($filter_query_where == '' && $where) {
86
+			$filter_query_where = ' WHERE';
87
+		} elseif ($filter_query_where != '' && $and) {
88
+			$filter_query_where .= ' AND';
89
+		}
83 90
 		if ($filter_query_where != '') {
84 91
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
85 92
 		}
@@ -134,42 +141,84 @@  discard block
 block discarded – undo
134 141
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
135 142
 			} elseif (isset($row['spotter_archive_output_id'])) {
136 143
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
137
-			*/} 
138
-			elseif (isset($row['marineid'])) {
144
+			*/} elseif (isset($row['marineid'])) {
139 145
 				$temp_array['marine_id'] = $row['marineid'];
140 146
 			} else {
141 147
 				$temp_array['marine_id'] = '';
142 148
 			}
143
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
144
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
145
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
146
-			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
147
-			if (isset($row['status'])) $temp_array['status'] = $row['status'];
148
-			if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id'];
149
-			if (isset($row['captain_id'])) $temp_array['captain_id'] = $row['captain_id'];
150
-			if (isset($row['captain_name'])) $temp_array['captain_name'] = $row['captain_name'];
151
-			if (isset($row['race_id'])) $temp_array['race_id'] = $row['race_id'];
152
-			if (isset($row['race_name'])) $temp_array['race_name'] = $row['race_name'];
153
-			if (isset($row['race_time']) && isset($row['status']) && $row['status'] != 'Racing' && $row['race_time'] > 0) $temp_array['race_time'] = $row['race_time'];
154
-			if (isset($row['race_rank'])) $temp_array['race_rank'] = $row['race_rank'];
155
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
156
-			if (isset($row['arrival_port_name'])) $temp_array['arrival_port_name'] = $row['arrival_port_name'];
157
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
158
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
159
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
160
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
149
+			if (isset($row['fammarine_id'])) {
150
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
151
+			}
152
+			if (isset($row['mmsi'])) {
153
+				$temp_array['mmsi'] = $row['mmsi'];
154
+			}
155
+			if (isset($row['type'])) {
156
+				$temp_array['type'] = $row['type'];
157
+			}
158
+			if (isset($row['type_id'])) {
159
+				$temp_array['type_id'] = $row['type_id'];
160
+			}
161
+			if (isset($row['status'])) {
162
+				$temp_array['status'] = $row['status'];
163
+			}
164
+			if (isset($row['status_id'])) {
165
+				$temp_array['status_id'] = $row['status_id'];
166
+			}
167
+			if (isset($row['captain_id'])) {
168
+				$temp_array['captain_id'] = $row['captain_id'];
169
+			}
170
+			if (isset($row['captain_name'])) {
171
+				$temp_array['captain_name'] = $row['captain_name'];
172
+			}
173
+			if (isset($row['race_id'])) {
174
+				$temp_array['race_id'] = $row['race_id'];
175
+			}
176
+			if (isset($row['race_name'])) {
177
+				$temp_array['race_name'] = $row['race_name'];
178
+			}
179
+			if (isset($row['race_time']) && isset($row['status']) && $row['status'] != 'Racing' && $row['race_time'] > 0) {
180
+				$temp_array['race_time'] = $row['race_time'];
181
+			}
182
+			if (isset($row['race_rank'])) {
183
+				$temp_array['race_rank'] = $row['race_rank'];
184
+			}
185
+			if (isset($row['ident'])) {
186
+				$temp_array['ident'] = $row['ident'];
187
+			}
188
+			if (isset($row['arrival_port_name'])) {
189
+				$temp_array['arrival_port_name'] = $row['arrival_port_name'];
190
+			}
191
+			if (isset($row['latitude'])) {
192
+				$temp_array['latitude'] = $row['latitude'];
193
+			}
194
+			if (isset($row['longitude'])) {
195
+				$temp_array['longitude'] = $row['longitude'];
196
+			}
197
+			if (isset($row['distance']) && $row['distance'] != '') {
198
+				$temp_array['distance'] = $row['distance'];
199
+			}
200
+			if (isset($row['format_source'])) {
201
+				$temp_array['format_source'] = $row['format_source'];
202
+			}
161 203
 			if (isset($row['heading'])) {
162 204
 				$temp_array['heading'] = $row['heading'];
163 205
 				$heading_direction = $this->parseDirection($row['heading']);
164
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
206
+				if (isset($heading_direction[0]['direction_fullname'])) {
207
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
208
+				}
209
+			}
210
+			if (isset($row['ground_speed'])) {
211
+				$temp_array['ground_speed'] = $row['ground_speed'];
165 212
 			}
166
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
167 213
 
168 214
 			if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
169 215
 			{
170 216
 				$Image = new Image($this->db);
171
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
172
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
217
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
218
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
219
+				} else {
220
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
221
+				}
173 222
 				unset($Image);
174 223
 				if (count($image_array) > 0) {
175 224
 					$temp_array['image'] = $image_array[0]['image'];
@@ -233,13 +282,21 @@  discard block
 block discarded – undo
233 282
 			}
234 283
 			
235 284
 			$fromsource = NULL;
236
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
237
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
238
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
285
+			if (isset($row['source_name']) && $row['source_name'] != '') {
286
+				$temp_array['source_name'] = $row['source_name'];
287
+			}
288
+			if (isset($row['over_country']) && $row['over_country'] != '') {
289
+				$temp_array['over_country'] = $row['over_country'];
290
+			}
291
+			if (isset($row['distance']) && $row['distance'] != '') {
292
+				$temp_array['distance'] = $row['distance'];
293
+			}
239 294
 			$temp_array['query_number_rows'] = $num_rows;
240 295
 			$spotter_array[] = $temp_array;
241 296
 		}
242
-		if ($num_rows == 0) return array();
297
+		if ($num_rows == 0) {
298
+			return array();
299
+		}
243 300
 		$spotter_array[0]['query_number_rows'] = $num_rows;
244 301
 		return $spotter_array;
245 302
 	}	
@@ -265,8 +322,12 @@  discard block
 block discarded – undo
265 322
 			{
266 323
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
267 324
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
268
-			} else $limit_query = "";
269
-		} else $limit_query = "";
325
+			} else {
326
+				$limit_query = "";
327
+			}
328
+		} else {
329
+			$limit_query = "";
330
+		}
270 331
 		if ($sort != "")
271 332
 		{
272 333
 			$search_orderby_array = $this->getOrderBy();
@@ -290,7 +351,9 @@  discard block
 block discarded – undo
290 351
 		global $global_marine_query;
291 352
 		
292 353
 		date_default_timezone_set('UTC');
293
-		if ($id == '') return array();
354
+		if ($id == '') {
355
+			return array();
356
+		}
294 357
 		$additional_query = "marine_output.fammarine_id = :id";
295 358
 		$query_values = array(':id' => $id);
296 359
 		$query  = $global_marine_query." WHERE ".$additional_query." ";
@@ -738,8 +801,11 @@  discard block
 block discarded – undo
738 801
 		$sth = $this->db->prepare($query);
739 802
 		$sth->execute($query_values);
740 803
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
741
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
742
-		else return $result[0]['duration'];
804
+		if (is_int($result[0]['duration'])) {
805
+			return gmdate('H:i:s',$result[0]['duration']);
806
+		} else {
807
+			return $result[0]['duration'];
808
+		}
743 809
 	}
744 810
 
745 811
 	/**
@@ -798,8 +864,11 @@  discard block
 block discarded – undo
798 864
 		$query .= " ORDER BY marine_output.source_name ASC";
799 865
 
800 866
 		$sth = $this->db->prepare($query);
801
-		if (!empty($query_values)) $sth->execute($query_values);
802
-		else $sth->execute();
867
+		if (!empty($query_values)) {
868
+			$sth->execute($query_values);
869
+		} else {
870
+			$sth->execute();
871
+		}
803 872
 
804 873
 		$source_array = array();
805 874
 		$temp_array = array();
@@ -854,8 +923,11 @@  discard block
 block discarded – undo
854 923
 		$sth = $this->db->prepare($query);
855 924
 		$sth->execute(array(':mmsi' => $mmsi));
856 925
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
857
-		if (isset($result[0])) return $result[0];
858
-		else return array();
926
+		if (isset($result[0])) {
927
+			return $result[0];
928
+		} else {
929
+			return array();
930
+		}
859 931
 	}
860 932
 
861 933
 	/**
@@ -896,7 +968,9 @@  discard block
 block discarded – undo
896 968
 			date_default_timezone_set($globalTimezone);
897 969
 			$datetime = new DateTime();
898 970
 			$offset = $datetime->format('P');
899
-		} else $offset = '+00:00';
971
+		} else {
972
+			$offset = '+00:00';
973
+		}
900 974
 
901 975
 		if ($globalDBdriver == 'mysql') {
902 976
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -1003,8 +1077,12 @@  discard block
 block discarded – undo
1003 1077
 	*/	
1004 1078
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '')
1005 1079
 	{
1006
-		if ($latitude == '') $latitude = NULL;
1007
-		if ($longitude == '') $longitude = NULL;
1080
+		if ($latitude == '') {
1081
+			$latitude = NULL;
1082
+		}
1083
+		if ($longitude == '') {
1084
+			$longitude = NULL;
1085
+		}
1008 1086
 		$groundspeed = round($groundspeed);
1009 1087
 		if ($race_begin != '') {
1010 1088
 			$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status, date = :race_begin WHERE fammarine_id = :fammarine_id';
@@ -1157,14 +1235,28 @@  discard block
 block discarded – undo
1157 1235
 			$latitude = 0;
1158 1236
 			$longitude = 0;
1159 1237
 		}
1160
-		if ($type_id == '') $type_id = NULL;
1161
-		if ($status_id == '') $status_id = NULL;
1162
-		if ($distance == '') $distance = NULL;
1163
-		if ($race_rank == '') $race_rank = NULL;
1164
-		if ($race_time == '') $race_time = NULL;
1165
-		if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1238
+		if ($type_id == '') {
1239
+			$type_id = NULL;
1240
+		}
1241
+		if ($status_id == '') {
1242
+			$status_id = NULL;
1243
+		}
1244
+		if ($distance == '') {
1245
+			$distance = NULL;
1246
+		}
1247
+		if ($race_rank == '') {
1248
+			$race_rank = NULL;
1249
+		}
1250
+		if ($race_time == '') {
1251
+			$race_time = NULL;
1252
+		}
1253
+		if ($heading == '' || $Common->isInteger($heading) === false) {
1254
+			$heading = 0;
1255
+		}
1166 1256
 		//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1167
-		if ($arrival_date == '') $arrival_date = NULL;
1257
+		if ($arrival_date == '') {
1258
+			$arrival_date = NULL;
1259
+		}
1168 1260
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) 
1169 1261
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name, :distance, :race_rank,:race_time)";
1170 1262
 
@@ -1271,7 +1363,9 @@  discard block
 block discarded – undo
1271 1363
 		global $globalDBdriver, $globalArchive;
1272 1364
 		//$filter_query = $this->getFilter($filters,true,true);
1273 1365
 		$Connection= new Connection($this->db);
1274
-		if (!$Connection->tableExists('countries')) return array();
1366
+		if (!$Connection->tableExists('countries')) {
1367
+			return array();
1368
+		}
1275 1369
 		require_once('class.SpotterLive.php');
1276 1370
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
1277 1371
 			$MarineLive = new MarineLive($this->db);
@@ -1315,7 +1409,9 @@  discard block
 block discarded – undo
1315 1409
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country ";
1316 1410
 		}
1317 1411
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
1318
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1412
+		if ($limit) {
1413
+			$query .= " LIMIT 10 OFFSET 0";
1414
+		}
1319 1415
 
1320 1416
 		$sth = $this->db->prepare($query);
1321 1417
 		$sth->execute();
@@ -1349,12 +1445,18 @@  discard block
 block discarded – undo
1349 1445
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
1350 1446
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
1351 1447
 		 if ($olderthanmonths > 0) {
1352
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
1353
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1448
+			if ($globalDBdriver == 'mysql') {
1449
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
1450
+			} else {
1451
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1452
+			}
1354 1453
 		}
1355 1454
 		if ($sincedate != '') {
1356
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
1357
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
1455
+			if ($globalDBdriver == 'mysql') {
1456
+				$query .= " AND marine_output.date > '".$sincedate."'";
1457
+			} else {
1458
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
1459
+			}
1358 1460
 		}
1359 1461
 		$query_values = array();
1360 1462
 		if ($year != '') {
@@ -1385,7 +1487,9 @@  discard block
 block discarded – undo
1385 1487
 			}
1386 1488
 		}
1387 1489
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
1388
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1490
+		if ($limit) {
1491
+			$query .= " LIMIT 10 OFFSET 0";
1492
+		}
1389 1493
       		
1390 1494
 		$sth = $this->db->prepare($query);
1391 1495
 		$sth->execute($query_values);
@@ -1420,7 +1524,9 @@  discard block
 block discarded – undo
1420 1524
 			date_default_timezone_set($globalTimezone);
1421 1525
 			$datetime = new DateTime();
1422 1526
 			$offset = $datetime->format('P');
1423
-		} else $offset = '+00:00';
1527
+		} else {
1528
+			$offset = '+00:00';
1529
+		}
1424 1530
 
1425 1531
 		if ($globalDBdriver == 'mysql') {
1426 1532
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1470,7 +1576,9 @@  discard block
 block discarded – undo
1470 1576
 			date_default_timezone_set($globalTimezone);
1471 1577
 			$datetime = new DateTime();
1472 1578
 			$offset = $datetime->format('P');
1473
-		} else $offset = '+00:00';
1579
+		} else {
1580
+			$offset = '+00:00';
1581
+		}
1474 1582
 		$filter_query = $this->getFilter($filters,true,true);
1475 1583
 		if ($globalDBdriver == 'mysql') {
1476 1584
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1516,7 +1624,9 @@  discard block
 block discarded – undo
1516 1624
 			date_default_timezone_set($globalTimezone);
1517 1625
 			$datetime = new DateTime();
1518 1626
 			$offset = $datetime->format('P');
1519
-		} else $offset = '+00:00';
1627
+		} else {
1628
+			$offset = '+00:00';
1629
+		}
1520 1630
 		$filter_query = $this->getFilter($filters,true,true);
1521 1631
 		if ($globalDBdriver == 'mysql') {
1522 1632
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1564,7 +1674,9 @@  discard block
 block discarded – undo
1564 1674
 			date_default_timezone_set($globalTimezone);
1565 1675
 			$datetime = new DateTime();
1566 1676
 			$offset = $datetime->format('P');
1567
-		} else $offset = '+00:00';
1677
+		} else {
1678
+			$offset = '+00:00';
1679
+		}
1568 1680
 
1569 1681
 		if ($globalDBdriver == 'mysql') {
1570 1682
 			$query  = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1613,7 +1725,9 @@  discard block
 block discarded – undo
1613 1725
 			date_default_timezone_set($globalTimezone);
1614 1726
 			$datetime = new DateTime();
1615 1727
 			$offset = $datetime->format('P');
1616
-		} else $offset = '+00:00';
1728
+		} else {
1729
+			$offset = '+00:00';
1730
+		}
1617 1731
 		$filter_query = $this->getFilter($filters,true,true);
1618 1732
 		if ($globalDBdriver == 'mysql') {
1619 1733
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1662,7 +1776,9 @@  discard block
 block discarded – undo
1662 1776
 			date_default_timezone_set($globalTimezone);
1663 1777
 			$datetime = new DateTime();
1664 1778
 			$offset = $datetime->format('P');
1665
-		} else $offset = '+00:00';
1779
+		} else {
1780
+			$offset = '+00:00';
1781
+		}
1666 1782
 
1667 1783
 		$orderby_sql = '';
1668 1784
 		if ($orderby == "hour")
@@ -1731,7 +1847,9 @@  discard block
 block discarded – undo
1731 1847
 			date_default_timezone_set($globalTimezone);
1732 1848
 			$datetime = new DateTime($date);
1733 1849
 			$offset = $datetime->format('P');
1734
-		} else $offset = '+00:00';
1850
+		} else {
1851
+			$offset = '+00:00';
1852
+		}
1735 1853
 
1736 1854
 		if ($globalDBdriver == 'mysql') {
1737 1855
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1779,7 +1897,9 @@  discard block
 block discarded – undo
1779 1897
 			date_default_timezone_set($globalTimezone);
1780 1898
 			$datetime = new DateTime();
1781 1899
 			$offset = $datetime->format('P');
1782
-		} else $offset = '+00:00';
1900
+		} else {
1901
+			$offset = '+00:00';
1902
+		}
1783 1903
 
1784 1904
 		if ($globalDBdriver == 'mysql') {
1785 1905
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1844,8 +1964,11 @@  discard block
 block discarded – undo
1844 1964
 				$query_values = array_merge($query_values,array(':month' => $month));
1845 1965
 			}
1846 1966
 		}
1847
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1848
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1967
+		if (empty($query_values)) {
1968
+			$queryi .= $this->getFilter($filters);
1969
+		} else {
1970
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1971
+		}
1849 1972
 		
1850 1973
 		$sth = $this->db->prepare($queryi);
1851 1974
 		$sth->execute($query_values);
@@ -1882,8 +2005,11 @@  discard block
 block discarded – undo
1882 2005
 				$query_values = array_merge($query_values,array(':month' => $month));
1883 2006
 			}
1884 2007
 		}
1885
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1886
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2008
+		if (empty($query_values)) {
2009
+			$queryi .= $this->getFilter($filters);
2010
+		} else {
2011
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
2012
+		}
1887 2013
 		
1888 2014
 		$sth = $this->db->prepare($queryi);
1889 2015
 		$sth->execute($query_values);
@@ -1905,7 +2031,9 @@  discard block
 block discarded – undo
1905 2031
 			date_default_timezone_set($globalTimezone);
1906 2032
 			$datetime = new DateTime();
1907 2033
 			$offset = $datetime->format('P');
1908
-		} else $offset = '+00:00';
2034
+		} else {
2035
+			$offset = '+00:00';
2036
+		}
1909 2037
 
1910 2038
 		if ($globalDBdriver == 'mysql') {
1911 2039
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -2009,7 +2137,9 @@  discard block
 block discarded – undo
2009 2137
 	*/
2010 2138
 	public function parseDirection($direction = 0)
2011 2139
 	{
2012
-		if ($direction == '') $direction = 0;
2140
+		if ($direction == '') {
2141
+			$direction = 0;
2142
+		}
2013 2143
 		$direction_array = array();
2014 2144
 		$temp_array = array();
2015 2145
 
@@ -2098,7 +2228,9 @@  discard block
 block discarded – undo
2098 2228
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2099 2229
 	
2100 2230
 		$Connection = new Connection($this->db);
2101
-		if (!$Connection->tableExists('countries')) return '';
2231
+		if (!$Connection->tableExists('countries')) {
2232
+			return '';
2233
+		}
2102 2234
 	
2103 2235
 		try {
2104 2236
 			/*
@@ -2118,9 +2250,13 @@  discard block
 block discarded – undo
2118 2250
 			$sth->closeCursor();
2119 2251
 			if (count($row) > 0) {
2120 2252
 				return $row;
2121
-			} else return '';
2253
+			} else {
2254
+				return '';
2255
+			}
2122 2256
 		} catch (PDOException $e) {
2123
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
2257
+			if (isset($globalDebug) && $globalDebug) {
2258
+				echo 'Error : '.$e->getMessage()."\n";
2259
+			}
2124 2260
 			return '';
2125 2261
 		}
2126 2262
 	
@@ -2138,7 +2274,9 @@  discard block
 block discarded – undo
2138 2274
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
2139 2275
 	
2140 2276
 		$Connection = new Connection($this->db);
2141
-		if (!$Connection->tableExists('countries')) return '';
2277
+		if (!$Connection->tableExists('countries')) {
2278
+			return '';
2279
+		}
2142 2280
 	
2143 2281
 		try {
2144 2282
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -2150,9 +2288,13 @@  discard block
 block discarded – undo
2150 2288
 			$sth->closeCursor();
2151 2289
 			if (count($row) > 0) {
2152 2290
 				return $row;
2153
-			} else return '';
2291
+			} else {
2292
+				return '';
2293
+			}
2154 2294
 		} catch (PDOException $e) {
2155
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
2295
+			if (isset($globalDebug) && $globalDebug) {
2296
+				echo 'Error : '.$e->getMessage()."\n";
2297
+			}
2156 2298
 			return '';
2157 2299
 		}
2158 2300
 	
@@ -2170,7 +2312,9 @@  discard block
 block discarded – undo
2170 2312
 	{
2171 2313
 		global $globalBitlyAccessToken;
2172 2314
 		
2173
-		if ($globalBitlyAccessToken == '') return $url;
2315
+		if ($globalBitlyAccessToken == '') {
2316
+			return $url;
2317
+		}
2174 2318
         
2175 2319
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
2176 2320
 		
@@ -2246,7 +2390,9 @@  discard block
 block discarded – undo
2246 2390
 			}
2247 2391
 		}
2248 2392
 		$query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC";
2249
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
2393
+		if ($limit) {
2394
+			$query .= " LIMIT 10 OFFSET 0";
2395
+		}
2250 2396
 		$sth = $this->db->prepare($query);
2251 2397
 		$sth->execute($query_values);
2252 2398
 		$marine_array = array();
@@ -2284,9 +2430,15 @@  discard block
 block discarded – undo
2284 2430
 				foreach ($q_array as $q_item){
2285 2431
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
2286 2432
 					$additional_query .= " AND (";
2287
-					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
2288
-					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
2289
-					if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR ";
2433
+					if (is_int($q_item)) {
2434
+						$additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
2435
+					}
2436
+					if (is_int($q_item)) {
2437
+						$additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
2438
+					}
2439
+					if (is_int($q_item)) {
2440
+						$additional_query .= "(marine_output.imo = '".$q_item."') OR ";
2441
+					}
2290 2442
 					$additional_query .= "(marine_output.ident like '%".$q_item."%') OR ";
2291 2443
 					$additional_query .= ")";
2292 2444
 				}
@@ -2334,7 +2486,9 @@  discard block
 block discarded – undo
2334 2486
 				date_default_timezone_set($globalTimezone);
2335 2487
 				$datetime = new DateTime();
2336 2488
 				$offset = $datetime->format('P');
2337
-			} else $offset = '+00:00';
2489
+			} else {
2490
+				$offset = '+00:00';
2491
+			}
2338 2492
 			if ($date_array[1] != "")
2339 2493
 			{
2340 2494
 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
@@ -2361,8 +2515,12 @@  discard block
 block discarded – undo
2361 2515
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
2362 2516
 			{
2363 2517
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
2364
-			} else $limit_query = "";
2365
-		} else $limit_query = "";
2518
+			} else {
2519
+				$limit_query = "";
2520
+			}
2521
+		} else {
2522
+			$limit_query = "";
2523
+		}
2366 2524
 		if ($sort != "")
2367 2525
 		{
2368 2526
 			$search_orderby_array = $this->getOrderBy();
@@ -2428,8 +2586,11 @@  discard block
 block discarded – undo
2428 2586
 		$sth = $this->db->prepare($query);
2429 2587
 		$sth->execute(array(':race_name' => $race_name));
2430 2588
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2431
-		if (isset($result[0])) return $result[0];
2432
-		else return array();
2589
+		if (isset($result[0])) {
2590
+			return $result[0];
2591
+		} else {
2592
+			return array();
2593
+		}
2433 2594
 	}
2434 2595
 
2435 2596
 	/**
@@ -2445,8 +2606,11 @@  discard block
 block discarded – undo
2445 2606
 		$sth = $this->db->prepare($query);
2446 2607
 		$sth->execute(array(':race_id' => $race_id));
2447 2608
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2448
-		if (isset($result[0])) return $result[0];
2449
-		else return array();
2609
+		if (isset($result[0])) {
2610
+			return $result[0];
2611
+		} else {
2612
+			return array();
2613
+		}
2450 2614
 	}
2451 2615
 
2452 2616
 	/**
Please login to merge, or discard this patch.