Completed
Push — master ( 14281c...6f3189 )
by Yannick
30:26
created
require/class.NOTAM.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 		try {
989 989
 			$sth = $this->db->prepare($query);
990 990
 			$sth->execute($query_values);
991
-		} catch(PDOException $e) {
991
+		} catch (PDOException $e) {
992 992
 			echo "error : ".$e->getMessage();
993 993
 		}
994 994
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1005,19 +1005,19 @@  discard block
 block discarded – undo
1005 1005
 		try {
1006 1006
 			$sth = $this->db->prepare($query);
1007 1007
 			$sth->execute($query_values);
1008
-		} catch(PDOException $e) {
1008
+		} catch (PDOException $e) {
1009 1009
 			echo "error : ".$e->getMessage();
1010 1010
 		}
1011 1011
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1012 1012
 		return $all;
1013 1013
 	}
1014 1014
 	public function getAllNOTAMtext() {
1015
-		$query  = 'SELECT full_notam FROM notam';
1015
+		$query = 'SELECT full_notam FROM notam';
1016 1016
 		$query_values = array();
1017 1017
 		try {
1018 1018
 			$sth = $this->db->prepare($query);
1019 1019
 			$sth->execute($query_values);
1020
-		} catch(PDOException $e) {
1020
+		} catch (PDOException $e) {
1021 1021
 			echo "error : ".$e->getMessage();
1022 1022
 		}
1023 1023
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1026,12 +1026,12 @@  discard block
 block discarded – undo
1026 1026
 	public function createNOTAMtextFile($filename) {
1027 1027
 		$allnotam_result = $this->getAllNOTAMtext();
1028 1028
 		$notamtext = '';
1029
-		foreach($allnotam_result as $notam) {
1029
+		foreach ($allnotam_result as $notam) {
1030 1030
 			$notamtext .= '%%'."\n";
1031 1031
 			$notamtext .= $notam['full_notam'];
1032 1032
 			$notamtext .= "\n".'%%'."\n";
1033 1033
 		}
1034
-		file_put_contents($filename,$notamtext);
1034
+		file_put_contents($filename, $notamtext);
1035 1035
 	}
1036 1036
 	public function parseNOTAMtextFile($filename) {
1037 1037
 		$data = file_get_contents($filename);
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
 		try {
1051 1051
 			$sth = $this->db->prepare($query);
1052 1052
 			$sth->execute($query_values);
1053
-		} catch(PDOException $e) {
1053
+		} catch (PDOException $e) {
1054 1054
 			echo "error : ".$e->getMessage();
1055 1055
 		}
1056 1056
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1059,10 +1059,10 @@  discard block
 block discarded – undo
1059 1059
 	public function getAllNOTAMbyCoord($coord) {
1060 1060
 		global $globalDBdriver;
1061 1061
 		if (is_array($coord)) {
1062
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1063
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1064
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1065
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1062
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1063
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1064
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1065
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1066 1066
 			if ($minlat > $maxlat) {
1067 1067
 				$tmplat = $minlat;
1068 1068
 				$minlat = $maxlat;
@@ -1083,19 +1083,19 @@  discard block
 block discarded – undo
1083 1083
 		try {
1084 1084
 			$sth = $this->db->prepare($query);
1085 1085
 			$sth->execute($query_values);
1086
-		} catch(PDOException $e) {
1086
+		} catch (PDOException $e) {
1087 1087
 			echo "error : ".$e->getMessage();
1088 1088
 		}
1089 1089
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1090 1090
 		return $all;
1091 1091
 	}
1092
-	public function getAllNOTAMbyCoordScope($coord,$scope) {
1092
+	public function getAllNOTAMbyCoordScope($coord, $scope) {
1093 1093
 		global $globalDBdriver;
1094 1094
 		if (is_array($coord)) {
1095
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1096
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1097
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1098
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1095
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1096
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1097
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1098
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1099 1099
 		} else return array();
1100 1100
 		if ($globalDBdriver == 'mysql') {
1101 1101
 			$query  = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope';
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 		try {
1107 1107
 			$sth = $this->db->prepare($query);
1108 1108
 			$sth->execute($query_values);
1109
-		} catch(PDOException $e) {
1109
+		} catch (PDOException $e) {
1110 1110
 			echo "error : ".$e->getMessage();
1111 1111
 		}
1112 1112
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 		try {
1119 1119
 			$sth = $this->db->prepare($query);
1120 1120
 			$sth->execute($query_values);
1121
-		} catch(PDOException $e) {
1121
+		} catch (PDOException $e) {
1122 1122
 			return "error : ".$e->getMessage();
1123 1123
 		}
1124 1124
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1126,13 +1126,13 @@  discard block
 block discarded – undo
1126 1126
 		else return array();
1127 1127
 	}
1128 1128
 
1129
-	public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) {
1129
+	public function addNOTAM($ref, $title, $type, $fir, $code, $rules, $scope, $lower_limit, $upper_limit, $center_latitude, $center_longitude, $radius, $date_begin, $date_end, $permanent, $text, $full_notam) {
1130 1130
 		$query = "INSERT INTO notam (ref,title,notam_type,fir,code,rules,scope,lower_limit,upper_limit,center_latitude,center_longitude,radius,date_begin,date_end,permanent,notam_text,full_notam) VALUES (:ref,:title,:type,:fir,:code,:rules,:scope,:lower_limit,:upper_limit,:center_latitude,:center_longitude,:radius,:date_begin,:date_end,:permanent,:text,:full_notam)";
1131
-		$query_values = array(':ref' => $ref,':title' => $title,':type' => $type,':fir' => $fir,':code' => $code,':rules' => $rules,':scope' => $scope,':lower_limit' => $lower_limit,':upper_limit' => $upper_limit,':center_latitude' => $center_latitude,':center_longitude' => $center_longitude,':radius' => $radius,':date_begin' => $date_begin,':date_end' => $date_end,':permanent' => $permanent,':text' => $text,':full_notam' => $full_notam);
1131
+		$query_values = array(':ref' => $ref, ':title' => $title, ':type' => $type, ':fir' => $fir, ':code' => $code, ':rules' => $rules, ':scope' => $scope, ':lower_limit' => $lower_limit, ':upper_limit' => $upper_limit, ':center_latitude' => $center_latitude, ':center_longitude' => $center_longitude, ':radius' => $radius, ':date_begin' => $date_begin, ':date_end' => $date_end, ':permanent' => $permanent, ':text' => $text, ':full_notam' => $full_notam);
1132 1132
 		try {
1133 1133
 			$sth = $this->db->prepare($query);
1134 1134
 			$sth->execute($query_values);
1135
-		} catch(PDOException $e) {
1135
+		} catch (PDOException $e) {
1136 1136
 			return "error : ".$e->getMessage();
1137 1137
 		}
1138 1138
 	}
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
 		try {
1144 1144
 			$sth = $this->db->prepare($query);
1145 1145
 			$sth->execute($query_values);
1146
-		} catch(PDOException $e) {
1146
+		} catch (PDOException $e) {
1147 1147
 			return "error : ".$e->getMessage();
1148 1148
 		}
1149 1149
 	}
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
 		try {
1159 1159
 			$sth = $this->db->prepare($query);
1160 1160
 			$sth->execute($query_values);
1161
-		} catch(PDOException $e) {
1161
+		} catch (PDOException $e) {
1162 1162
 			return "error : ".$e->getMessage();
1163 1163
 		}
1164 1164
 	}
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
 		try {
1169 1169
 			$sth = $this->db->prepare($query);
1170 1170
 			$sth->execute($query_values);
1171
-		} catch(PDOException $e) {
1171
+		} catch (PDOException $e) {
1172 1172
 			return "error : ".$e->getMessage();
1173 1173
 		}
1174 1174
 	}
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
 		try {
1178 1178
 			$sth = $this->db->prepare($query);
1179 1179
 			$sth->execute();
1180
-		} catch(PDOException $e) {
1180
+		} catch (PDOException $e) {
1181 1181
 			return "error : ".$e->getMessage();
1182 1182
 		}
1183 1183
 	}
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 		try {
1187 1187
 			$sth = $this->db->prepare($query);
1188 1188
 			$sth->execute();
1189
-		} catch(PDOException $e) {
1189
+		} catch (PDOException $e) {
1190 1190
 			return "error : ".$e->getMessage();
1191 1191
 		}
1192 1192
 	}
@@ -1194,14 +1194,14 @@  discard block
 block discarded – undo
1194 1194
 	public function updateNOTAM() {
1195 1195
 		global $globalNOTAMAirports;
1196 1196
 		if (isset($globalNOTAMAirports) && is_array($globalNOTAMAirports) && count($globalNOTAMAirports) > 0) {
1197
-			foreach (array_chunk($globalNOTAMAirports,10) as $airport) {
1198
-				$airport_icao = implode(',',$airport);
1197
+			foreach (array_chunk($globalNOTAMAirports, 10) as $airport) {
1198
+				$airport_icao = implode(',', $airport);
1199 1199
 				$alldata = $this->downloadNOTAM($airport_icao);
1200 1200
 				if (count($alldata) > 0) {
1201 1201
 					foreach ($alldata as $initial_data) {
1202 1202
 						$data = $this->parse($initial_data);
1203 1203
 						$notamref = $this->getNOTAMbyRef($data['ref']);
1204
-						if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1204
+						if (count($notamref) == 0) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1205 1205
 					}
1206 1206
 				}
1207 1207
 			}
@@ -1218,8 +1218,8 @@  discard block
 block discarded – undo
1218 1218
 				$j++;
1219 1219
 				$data = $this->parse($initial_data);
1220 1220
 				$notamref = $this->getNOTAMbyRef($data['ref']);
1221
-				if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1222
-				if ($globalTransaction && $j % 1000 == 0) {
1221
+				if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1222
+				if ($globalTransaction && $j%1000 == 0) {
1223 1223
 					$this->db->commit();
1224 1224
 					if ($globalDebug) echo '.';
1225 1225
 					$this->db->beginTransaction();
@@ -1233,12 +1233,12 @@  discard block
 block discarded – undo
1233 1233
 		global $globalTransaction;
1234 1234
 		$Spotter = new Spotter($this->db);
1235 1235
 		$allairports = $Spotter->getAllAirportInfo();
1236
-		foreach (array_chunk($allairports,20) as $airport) {
1236
+		foreach (array_chunk($allairports, 20) as $airport) {
1237 1237
 			$airports_icao = array();
1238
-			foreach($airport as $icao) {
1238
+			foreach ($airport as $icao) {
1239 1239
 				if (isset($icao['icao'])) $airports_icao[] = $icao['icao'];
1240 1240
 			}
1241
-			$airport_icao = implode(',',$airports_icao);
1241
+			$airport_icao = implode(',', $airports_icao);
1242 1242
 			$alldata = $this->downloadNOTAM($airport_icao);
1243 1243
 			if ($globalTransaction) $this->db->beginTransaction();
1244 1244
 			if (count($alldata) > 0) {
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
 						if (count($notamref) == 0) {
1252 1252
 							if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']);
1253 1253
 							if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']);
1254
-							elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1254
+							elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'], '', '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1255 1255
 						}
1256 1256
 					}
1257 1257
 				}
@@ -1265,7 +1265,7 @@  discard block
 block discarded – undo
1265 1265
 		date_default_timezone_set("UTC");
1266 1266
 		$Common = new Common();
1267 1267
 		//$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1268
-		$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1268
+		$url = str_replace('{icao}', $icao, 'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1269 1269
 		$data = $Common->getData($url);
1270 1270
 		preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches);
1271 1271
 		//print_r($matches);
@@ -1282,8 +1282,8 @@  discard block
 block discarded – undo
1282 1282
 		$result['permanent'] = '';
1283 1283
 		$result['date_begin'] = NULL;
1284 1284
 		$result['date_end'] = NULL;
1285
-		$data = str_ireplace(array("\r","\n",'\r','\n'),' ',$data);
1286
-		$data = preg_split('#\s(?=([A-Z]\)\s))#',$data);
1285
+		$data = str_ireplace(array("\r", "\n", '\r', '\n'), ' ', $data);
1286
+		$data = preg_split('#\s(?=([A-Z]\)\s))#', $data);
1287 1287
 		$q = false;
1288 1288
 		$a = false;
1289 1289
 		$b = false;
@@ -1291,9 +1291,9 @@  discard block
 block discarded – undo
1291 1291
 		$e = false;
1292 1292
 		foreach ($data as $line) {
1293 1293
 			$line = trim($line);
1294
-			if (preg_match('#(^|\s)Q\) (.*)#',$line,$matches) && $q === false) {
1295
-				$line = str_replace(' ','',$line);
1296
-				if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#',$line,$matches)) {
1294
+			if (preg_match('#(^|\s)Q\) (.*)#', $line, $matches) && $q === false) {
1295
+				$line = str_replace(' ', '', $line);
1296
+				if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#', $line, $matches)) {
1297 1297
 				//if (preg_match('#Q\)([A-Z]{4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3})#',$line,$matches)) {
1298 1298
 					$result['fir'] = $matches[1];
1299 1299
 					$result['code'] = $matches[2];
@@ -1338,9 +1338,9 @@  discard block
 block discarded – undo
1338 1338
 					elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning';
1339 1339
 					$result['lower_limit'] = $matches[6];
1340 1340
 					$result['upper_limit'] = $matches[7];
1341
-					$latitude = $Common->convertDec($matches[8],'latitude');
1341
+					$latitude = $Common->convertDec($matches[8], 'latitude');
1342 1342
 					if ($matches[9] == 'S') $latitude = -$latitude;
1343
-					$longitude = $Common->convertDec($matches[10],'longitude');
1343
+					$longitude = $Common->convertDec($matches[10], 'longitude');
1344 1344
 					if ($matches[11] == 'W') $longitude = -$longitude;
1345 1345
 					$result['latitude'] = $latitude;
1346 1346
 					$result['longitude'] = $longitude;
@@ -1352,24 +1352,24 @@  discard block
 block discarded – undo
1352 1352
 					echo "Can't parse : ".$line."\n";
1353 1353
 				}
1354 1354
 			}
1355
-			elseif (preg_match('#(^|\s)A\) (.*)#',$line,$matches) && $a === false) {
1355
+			elseif (preg_match('#(^|\s)A\) (.*)#', $line, $matches) && $a === false) {
1356 1356
 				$result['icao'] = $matches[2];
1357 1357
 				$a = true;
1358 1358
 			}
1359
-			elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches) && $b === false) {
1359
+			elseif (preg_match('#(^|\s)B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#', $line, $matches) && $b === false) {
1360 1360
 				if ($matches[1] > 50) $year = '19'.$matches[2];
1361 1361
 				else $year = '20'.$matches[2];
1362 1362
 				$result['date_begin'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6];
1363 1363
 				$b = true;
1364 1364
 			}
1365
-			elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches) && $c === false) {
1365
+			elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $line, $matches) && $c === false) {
1366 1366
 				if ($matches[2] > 50) $year = '19'.$matches[2];
1367 1367
 				else $year = '20'.$matches[2];
1368 1368
 				$result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6];
1369 1369
 				$result['permanent'] = 0;
1370 1370
 				$c = true;
1371 1371
 			}
1372
-			elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches) && $c === false) {
1372
+			elseif (preg_match('#(^|\s)C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#', $line, $matches) && $c === false) {
1373 1373
 				if ($matches[2] > 50) $year = '19'.$matches[2];
1374 1374
 				else $year = '20'.$matches[2];
1375 1375
 				$result['date_end'] = $year.'/'.$matches[3].'/'.$matches[4].' '.$matches[5].':'.$matches[6];
@@ -1379,7 +1379,7 @@  discard block
 block discarded – undo
1379 1379
 				else $result['permanent'] = 0;
1380 1380
 				$c = true;
1381 1381
 			}
1382
-			elseif (preg_match('#(^|\s)C\) (EST|PERM)$#',$line,$matches) && $c === false) {
1382
+			elseif (preg_match('#(^|\s)C\) (EST|PERM)$#', $line, $matches) && $c === false) {
1383 1383
 				$result['date_end'] = '2030/12/20 12:00';
1384 1384
 				if ($matches[2] == 'EST') $result['estimated'] = 1;
1385 1385
 				else $result['estimated'] = 0;
@@ -1387,20 +1387,20 @@  discard block
 block discarded – undo
1387 1387
 				else $result['permanent'] = 0;
1388 1388
 				$c = true;
1389 1389
 			}
1390
-			elseif (preg_match('#(^|\s)E\) (.*)#',$line,$matches) && $e === false) {
1390
+			elseif (preg_match('#(^|\s)E\) (.*)#', $line, $matches) && $e === false) {
1391 1391
 				$rtext = array();
1392
-				$text = explode(' ',$matches[2]);
1392
+				$text = explode(' ', $matches[2]);
1393 1393
 				foreach ($text as $word) {
1394 1394
 					if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]);
1395
-					elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3);
1395
+					elseif (ctype_digit(strval(substr($word, 3))) && isset($this->abbr[substr($word, 0, 3)])) $rtext[] = strtoupper($this->abbr[substr($word, 0, 3)]).' '.substr($word, 3);
1396 1396
 					else $rtext[] = $word;
1397 1397
 				}
1398
-				$result['text'] = implode(' ',$rtext);
1398
+				$result['text'] = implode(' ', $rtext);
1399 1399
 				$e = true;
1400 1400
 			//} elseif (preg_match('#F\) (.*)#',$line,$matches)) {
1401 1401
 			//} elseif (preg_match('#G\) (.*)#',$line,$matches)) {
1402
-			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) {
1403
-				$text = explode(' ',$line);
1402
+			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#', $line, $matches)) {
1403
+				$text = explode(' ', $line);
1404 1404
 				$result['ref'] = $text[0];
1405 1405
 				if ($matches[1] == 'NOTAMN') $result['type'] = 'new';
1406 1406
 				if ($matches[1] == 'NOTAMC') {
Please login to merge, or discard this patch.
require/class.Accident.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -42,20 +42,20 @@  discard block
 block discarded – undo
42 42
 	* @param String $date get data for a date
43 43
 	* @return Array Return Accidents data in array
44 44
 	*/
45
-	public function getAccidentData($limit = '',$type = '',$date = '') {
45
+	public function getAccidentData($limit = '', $type = '', $date = '') {
46 46
 		global $globalURL, $globalDBdriver;
47 47
 		$Image = new Image($this->db);
48 48
 		$Spotter = new Spotter($this->db);
49 49
 		$Translation = new Translation($this->db);
50
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
50
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
51 51
 		date_default_timezone_set('UTC');
52 52
 		$result = array();
53 53
 		$limit_query = '';
54 54
 		if ($limit != "")
55 55
 		{
56 56
 			$limit_array = explode(",", $limit);
57
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
58
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
57
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
58
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
59 59
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
60 60
 			{
61 61
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -64,29 +64,29 @@  discard block
 block discarded – undo
64 64
 
65 65
 		if ($type != '') {
66 66
 			if ($date != '') {
67
-				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) {
67
+				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) {
68 68
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
69 69
 					//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
70
-					$query_values = array(':type' => $type,':date' => $date);
71
-				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) {
70
+					$query_values = array(':type' => $type, ':date' => $date);
71
+				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) {
72 72
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date BETWEEN :dated AND :datef GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
73
-					$query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31');
74
-				} elseif (preg_match("/^[0-9]{4}$/",$date)) {
73
+					$query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31');
74
+				} elseif (preg_match("/^[0-9]{4}$/", $date)) {
75 75
 					if ($globalDBdriver == 'mysql') {
76 76
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND YEAR(date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
77 77
 					} else {
78 78
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND EXTRACT(YEAR FROM date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
79 79
 					}
80
-					$query_values = array(':type' => $type,':date' => $date);
80
+					$query_values = array(':type' => $type, ':date' => $date);
81 81
 				} else {
82 82
 					$date = $date.'%';
83 83
 					if ($globalDBdriver == 'mysql') {
84 84
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND DATE_FORMAT(date,'%Y-%m-%d') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
85
-						$query_values = array(':type' => $type,':date' => $date);
85
+						$query_values = array(':type' => $type, ':date' => $date);
86 86
 					} else {
87 87
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
88 88
 						//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
89
-						$query_values = array(':type' => $type,':date' => $date);
89
+						$query_values = array(':type' => $type, ':date' => $date);
90 90
 					}
91 91
 				}
92 92
 			} else {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			}
98 98
 		} else {
99 99
 			if ($date != '') {
100
-				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) {
100
+				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) {
101 101
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
102 102
 					//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
103 103
 				} else {
@@ -116,17 +116,17 @@  discard block
 block discarded – undo
116 116
 		try {
117 117
 			$sth = $this->db->prepare($query);
118 118
 			$sth->execute($query_values);
119
-		} catch(PDOException $e) {
119
+		} catch (PDOException $e) {
120 120
 			echo "error : ".$e->getMessage();
121 121
 		}
122 122
 		$i = 0;
123 123
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
124
-			if (preg_match('/^[\w\-]+$/',$row['registration'])) {
124
+			if (preg_match('/^[\w\-]+$/', $row['registration'])) {
125 125
 				$data = array();
126 126
 				if ($row['registration'] != '') {
127 127
 					$image_array = $Image->getSpotterImage($row['registration']);
128
-					if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
129
-					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
128
+					if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
129
+					else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
130 130
 					$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
131 131
 					$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
132 132
 					if (!empty($aircraft_info)) {
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 						$data['aircraft_name'] = $aircraft_info[0]['type'];
135 135
 						$data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer'];
136 136
 					} else {
137
-						$data = array_merge($data,array('aircraft_type' => 'NA'));
137
+						$data = array_merge($data, array('aircraft_type' => 'NA'));
138 138
 					}
139 139
 					$owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']);
140 140
 					if (!empty($owner_data)) {
@@ -142,18 +142,18 @@  discard block
 block discarded – undo
142 142
 						$data['aircraft_base'] = $owner_data['base'];
143 143
 						$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
144 144
 					}
145
-				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
145
+				} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
146 146
 				if ($row['registration'] == '') $row['registration'] = 'NA';
147 147
 				if ($row['ident'] == '') $row['ident'] = 'NA';
148
-				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
148
+				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3));
149 149
 				if (isset($identicao[0])) {
150
-					if (substr($row['ident'],0,2) == 'AF') {
151
-						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
152
-						else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
153
-					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
154
-					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
150
+					if (substr($row['ident'], 0, 2) == 'AF') {
151
+						if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
152
+						else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
153
+					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
154
+					$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
155 155
 				} else $icao = $row['ident'];
156
-				$icao = $Translation->checkTranslation($icao,false);
156
+				$icao = $Translation->checkTranslation($icao, false);
157 157
 				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
158 158
 				if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
159 159
 					//echo 'Check airline info... for '.$row['airline_name'].' ';
@@ -162,16 +162,16 @@  discard block
 block discarded – undo
162 162
 					if (!empty($airline_info)) {
163 163
 						//echo 'data found !'."\n";
164 164
 						//print_r($airline_info);
165
-						$data = array_merge($data,$airline_info);
165
+						$data = array_merge($data, $airline_info);
166 166
 					} 
167 167
 					//else echo 'No data...'."\n";
168 168
 				}
169
-				$data = array_merge($row,$data);
169
+				$data = array_merge($row, $data);
170 170
 				if ($data['ident'] == null) $data['ident'] = $icao;
171 171
 				if ($data['title'] == null) {
172 172
 					$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
173 173
 				} else $data['message'] = strtolower($data['title']);
174
-				$ids = $Spotter->getAllIDByRegistration($data['registration'],true);
174
+				$ids = $Spotter->getAllIDByRegistration($data['registration'], true);
175 175
 				$date = $data['date'];
176 176
 				if (isset($ids[$date])) {
177 177
 					$data['spotted'] = TRUE;
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 		try {
204 204
 			$sth = $this->db->prepare($query);
205 205
 			$sth->execute();
206
-		} catch(PDOException $e) {
206
+		} catch (PDOException $e) {
207 207
 			echo "Error : ".$e->getMessage();
208 208
 		}
209 209
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 		try {
224 224
 			$sth = $this->db->prepare($query);
225 225
 			$sth->execute();
226
-		} catch(PDOException $e) {
226
+		} catch (PDOException $e) {
227 227
 			echo "Error : ".$e->getMessage();
228 228
 		}
229 229
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -238,15 +238,15 @@  discard block
 block discarded – undo
238 238
 		if ($globalDebug) echo 'Import '.$file."\n";
239 239
 		$result = array();
240 240
 		if (file_exists($file)) {
241
-			if (($handle = fopen($file,'r')) !== FALSE) {
242
-				while (($data = fgetcsv($handle,2000,",")) !== FALSE) {
241
+			if (($handle = fopen($file, 'r')) !== FALSE) {
242
+				while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) {
243 243
 					if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') {
244
-						$result[] = array('registration' => $data[0],'date' => strtotime($data[1]),'url' => $data[2],'country' => $data[3],'place' => $data[4],'title' => $data[5],'fatalities' => $data[6],'latitude' => $data[7],'longitude' => $data[8],'type' => $data[9],'ident' => $data[10],'aircraft_manufacturer' => $data[11],'aircraft_name' => $data[12],'operator' => $data[13],'source' => 'website_fam');
244
+						$result[] = array('registration' => $data[0], 'date' => strtotime($data[1]), 'url' => $data[2], 'country' => $data[3], 'place' => $data[4], 'title' => $data[5], 'fatalities' => $data[6], 'latitude' => $data[7], 'longitude' => $data[8], 'type' => $data[9], 'ident' => $data[10], 'aircraft_manufacturer' => $data[11], 'aircraft_name' => $data[12], 'operator' => $data[13], 'source' => 'website_fam');
245 245
 					}
246 246
 				}
247 247
 				fclose($handle);
248 248
 			}
249
-			if (!empty($result)) $this->add($result,true);
249
+			if (!empty($result)) $this->add($result, true);
250 250
 			elseif ($globalDebug) echo 'Nothing to import';
251 251
 		}
252 252
 	}
@@ -262,8 +262,8 @@  discard block
 block discarded – undo
262 262
 		$all_md5_new = array();
263 263
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
264 264
 			if ($this->check_accidents_nb() > 0) {
265
-				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
266
-					while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
265
+				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
266
+					while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
267 267
 						if (isset($data[1])) {
268 268
 							$year = $data[0];
269 269
 							$all_md5[$year] = $data[1];
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
 				}
274 274
 			}
275 275
 		}
276
-		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5');
276
+		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5');
277 277
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
278
-			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
279
-				while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
278
+			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
279
+				while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
280 280
 					if (isset($data[1])) {
281 281
 						$year = $data[0];
282 282
 						$all_md5_new[$year] = $data[1];
@@ -285,10 +285,10 @@  discard block
 block discarded – undo
285 285
 				fclose($handle);
286 286
 			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
287 287
 		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
288
-		$result = $Common->arr_diff($all_md5_new,$all_md5);
288
+		$result = $Common->arr_diff($all_md5_new, $all_md5);
289 289
 		if (empty($result) && $globalDebug) echo 'Nothing to update';
290 290
 		foreach ($result as $file => $md5) {
291
-			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
291
+			$Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file);
292 292
 			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
293 293
 			elseif ($globalDebug) echo 'Download '.$file.' failed';
294 294
 		}
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	* Add data to DB
299 299
 	* @param Array $crash An array with accidents/incidents data
300 300
 	*/
301
-	public function add($crash,$new = false) {
301
+	public function add($crash, $new = false) {
302 302
 		global $globalTransaction, $globalDebug, $globalAircraftImageFetch;
303 303
 		require_once('class.Connection.php');
304 304
 		require_once('class.Image.php');
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 			$sthd->execute(array(':source' => $crash[0]['source']));
315 315
 		}
316 316
 		if ($globalTransaction) $Connection->db->beginTransaction();
317
-		$initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null);
317
+		$initial_array = array('ident' => null, 'type' => 'accident', 'url' => null, 'registration' => null, 'date' => null, 'place' => null, 'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '', 'source' => '', 'aircraft_manufacturer' => null, 'aircraft_name' => null, 'operator' => null);
318 318
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
319 319
 		$sth_check = $Connection->db->prepare($query_check);
320 320
 		$query = 'INSERT INTO accidents (aircraft_manufacturer,aircraft_name,ident,registration,date,url,country,place,title,fatalities,latitude,longitude,type,airline_name,source) VALUES (:aircraft_manufacturer,:aircraft_name,:ident,:registration,:date,:url,:country,:place,:title,:fatalities,:latitude,:longitude,:type,:airline_name,:source)';
@@ -327,15 +327,15 @@  discard block
 block discarded – undo
327 327
 				$cr = array_map(function($value) {
328 328
 					return $value === "" ? NULL : $value;
329 329
 				}, $cr);
330
-				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
331
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
332
-					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
330
+				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) {
331
+					if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
332
+					$query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']);
333 333
 					$sth_check->execute($query_check_values);
334 334
 					$result_check = $sth_check->fetchAll(PDO::FETCH_ASSOC);
335 335
 					if ($result_check[0]['nb'] == 0) {
336
-						$query_values = array(':registration' => trim($cr['registration']),':date' => date('Y-m-d',$cr['date']),':url' => $cr['url'],':country' => $cr['country'],':place' => $cr['place'],':title' => $cr['title'],':fatalities' => $cr['fatalities'],':latitude' => $cr['latitude'],':longitude' => $cr['longitude'],':type' => $cr['type'],':source' => $cr['source'],':ident' => $cr['ident'],':aircraft_manufacturer' => $cr['aircraft_manufacturer'],':aircraft_name' => $cr['aircraft_name'],':airline_name' => $cr['operator']);
336
+						$query_values = array(':registration' => trim($cr['registration']), ':date' => date('Y-m-d', $cr['date']), ':url' => $cr['url'], ':country' => $cr['country'], ':place' => $cr['place'], ':title' => $cr['title'], ':fatalities' => $cr['fatalities'], ':latitude' => $cr['latitude'], ':longitude' => $cr['longitude'], ':type' => $cr['type'], ':source' => $cr['source'], ':ident' => $cr['ident'], ':aircraft_manufacturer' => $cr['aircraft_manufacturer'], ':aircraft_name' => $cr['aircraft_name'], ':airline_name' => $cr['operator']);
337 337
 						$sth->execute($query_values);
338
-						if ($globalAircraftImageFetch && $cr['date'] > time()-(30*86400)) {
338
+						if ($globalAircraftImageFetch && $cr['date'] > time() - (30*86400)) {
339 339
 							$imgchk = $Image->getSpotterImage($cr['registration']);
340 340
 							if (empty($imgchk)) {
341 341
 								if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...';
@@ -345,16 +345,16 @@  discard block
 block discarded – undo
345 345
 							// elseif ($globalDebug) echo 'Image already in DB'."\n";
346 346
 						}
347 347
 						if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type'];
348
-						$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
348
+						$Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date']));
349 349
 					}
350 350
 				}
351
-				if ($globalTransaction && $j % 1000 == 0) {
351
+				if ($globalTransaction && $j%1000 == 0) {
352 352
 					$Connection->db->commit();
353 353
 					$Connection->db->beginTransaction();
354 354
 				}
355 355
 			}
356 356
 			if ($globalTransaction) $Connection->db->commit();
357
-		} catch(PDOException $e) {
357
+		} catch (PDOException $e) {
358 358
 			if ($globalTransaction) $Connection->db->rollBack();
359 359
 			echo $e->getMessage();
360 360
 		}
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 			$Connection = new Connection();
373 373
 			$sth = $Connection->db->prepare($query);
374 374
 			$sth->execute();
375
-		} catch(PDOException $e) {
375
+		} catch (PDOException $e) {
376 376
 			return "error : ".$e->getMessage();
377 377
 		}
378 378
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 			$Connection = new Connection();
391 391
 			$sth = $Connection->db->prepare($query);
392 392
 			$sth->execute();
393
-		} catch(PDOException $e) {
393
+		} catch (PDOException $e) {
394 394
 			return "error : ".$e->getMessage();
395 395
 		}
396 396
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 			$Connection = new Connection();
406 406
 			$sth = $Connection->db->prepare($query);
407 407
 			$sth->execute();
408
-		} catch(PDOException $e) {
408
+		} catch (PDOException $e) {
409 409
 			return "error : ".$e->getMessage();
410 410
 		}
411 411
 	}
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Spacing   +402 added lines, -402 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();
1298
-                } catch(PDOException $e) {
1298
+                } catch (PDOException $e) {
1299 1299
                         return "error : ".$e->getMessage();
1300 1300
                 }
1301 1301
 
@@ -1316,8 +1316,8 @@  discard block
 block discarded – undo
1316 1316
 					$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)';
1317 1317
 					try {
1318 1318
 						$sth = $Connection->db->prepare($query);
1319
-						$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]));
1320
-					} catch(PDOException $e) {
1319
+						$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]));
1320
+					} catch (PDOException $e) {
1321 1321
 						return "error : ".$e->getMessage();
1322 1322
 					}
1323 1323
 				}
@@ -1336,7 +1336,7 @@  discard block
 block discarded – undo
1336 1336
 			$Connection = new Connection();
1337 1337
 			$sth = $Connection->db->prepare($query);
1338 1338
 			$sth->execute();
1339
-		} catch(PDOException $e) {
1339
+		} catch (PDOException $e) {
1340 1340
 			return "error : ".$e->getMessage();
1341 1341
 		}
1342 1342
 		$delimiter = "\t";
@@ -1353,8 +1353,8 @@  discard block
 block discarded – undo
1353 1353
 					    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)';
1354 1354
 					try {
1355 1355
 						$sth = $Connection->db->prepare($query);
1356
-						$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]));
1357
-					} catch(PDOException $e) {
1356
+						$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]));
1357
+					} catch (PDOException $e) {
1358 1358
 						return "error : ".$e->getMessage();
1359 1359
 					}
1360 1360
 				}
@@ -1373,7 +1373,7 @@  discard block
 block discarded – undo
1373 1373
 			$Connection = new Connection();
1374 1374
 			$sth = $Connection->db->prepare($query);
1375 1375
 			$sth->execute();
1376
-		} catch(PDOException $e) {
1376
+		} catch (PDOException $e) {
1377 1377
 			return "error : ".$e->getMessage();
1378 1378
 		}
1379 1379
 
@@ -1389,7 +1389,7 @@  discard block
 block discarded – undo
1389 1389
 					try {
1390 1390
 						$sth = $Connection->db->prepare($query);
1391 1391
 						$sth->execute(array(':icao' => $icao));
1392
-					} catch(PDOException $e) {
1392
+					} catch (PDOException $e) {
1393 1393
 						return "error : ".$e->getMessage();
1394 1394
 					}
1395 1395
 				}
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 		return '';
1401 1401
         }
1402 1402
 
1403
-	public static function tle($filename,$tletype) {
1403
+	public static function tle($filename, $tletype) {
1404 1404
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1405 1405
 		global $tmp_dir, $globalTransaction;
1406 1406
 		//$Spotter = new Spotter();
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
 			$Connection = new Connection();
1411 1411
 			$sth = $Connection->db->prepare($query);
1412 1412
                         $sth->execute(array(':source' => $filename));
1413
-                } catch(PDOException $e) {
1413
+                } catch (PDOException $e) {
1414 1414
                         return "error : ".$e->getMessage();
1415 1415
                 }
1416 1416
 		
@@ -1435,8 +1435,8 @@  discard block
 block discarded – undo
1435 1435
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1436 1436
 					try {
1437 1437
 						$sth = $Connection->db->prepare($query);
1438
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1439
-					} catch(PDOException $e) {
1438
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1439
+					} catch (PDOException $e) {
1440 1440
 						return "error : ".$e->getMessage();
1441 1441
 					}
1442 1442
 
@@ -1456,7 +1456,7 @@  discard block
 block discarded – undo
1456 1456
 			$Connection = new Connection();
1457 1457
 			$sth = $Connection->db->prepare($query);
1458 1458
 			$sth->execute(array(':source' => $filename));
1459
-		} catch(PDOException $e) {
1459
+		} catch (PDOException $e) {
1460 1460
 			return "error : ".$e->getMessage();
1461 1461
 		}
1462 1462
 		
@@ -1466,13 +1466,13 @@  discard block
 block discarded – undo
1466 1466
 			$i = 0;
1467 1467
 			//$Connection->db->setAttribute(PDO::ATTR_AUTOCOMMIT, FALSE);
1468 1468
 			//$Connection->db->beginTransaction();
1469
-			while (($data = fgetcsv($handle, 1000,"\t")) !== FALSE)
1469
+			while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE)
1470 1470
 			{
1471 1471
 				if ($i > 0 && $data[0] != '') {
1472 1472
 					$sources = trim($data[28].' '.$data[29].' '.$data[30].' '.$data[31].' '.$data[32].' '.$data[33]);
1473
-					$period = str_replace(',','',$data[14]);
1474
-					if (!empty($period) && strpos($period,'days')) $period = str_replace(' days','',$period)*24*60;
1475
-					if ($data[18] != '') $launch_date = date('Y-m-d',strtotime($data[18]));
1473
+					$period = str_replace(',', '', $data[14]);
1474
+					if (!empty($period) && strpos($period, 'days')) $period = str_replace(' days', '', $period)*24*60;
1475
+					if ($data[18] != '') $launch_date = date('Y-m-d', strtotime($data[18]));
1476 1476
 					else $launch_date = NULL;
1477 1477
 					$data = array_map(function($value) {
1478 1478
 						return trim($value) === '' ? null : $value;
@@ -1482,8 +1482,8 @@  discard block
 block discarded – undo
1482 1482
 					    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)';
1483 1483
 					try {
1484 1484
 						$sth = $Connection->db->prepare($query);
1485
-						$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));
1486
-					} catch(PDOException $e) {
1485
+						$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));
1486
+					} catch (PDOException $e) {
1487 1487
 						return "error : ".$e->getMessage();
1488 1488
 					}
1489 1489
 				}
@@ -1523,7 +1523,7 @@  discard block
 block discarded – undo
1523 1523
 			'EGYP' => array('country' => 'Egypt', 'owner' => ''),
1524 1524
 			'ESA' => array('country' => 'Multinational', 'owner' => 'European Space Agency'),
1525 1525
 			'ESRO' => array('country' => 'Multinational', 'owner' => 'European Space Research Organization'),
1526
-			'EST' => array('country' => 'Estonia','owner' => ''),
1526
+			'EST' => array('country' => 'Estonia', 'owner' => ''),
1527 1527
 			'EUME' => array('country' => 'Multinational', 'owner' => 'EUMETSAT (European Organization for the Exploitation of Meteorological Satellites)'),
1528 1528
 			'EUTE' => array('country' => 'Multinational', 'owner' => 'European Telecommunications Satellite Consortium (EUTELSAT)'),
1529 1529
 			'FGER' => array('country' => 'France/Germany', 'owner' => ''),
@@ -1647,10 +1647,10 @@  discard block
 block discarded – undo
1647 1647
 			{
1648 1648
 				if ($data != '') {
1649 1649
 				$result = array();
1650
-				$result['cospar'] = trim(substr($data,0,11));
1651
-				$result['norad'] = trim(substr($data,13,6));
1652
-				$result['operational'] = trim(substr($data,21,1));
1653
-				$result['name'] = trim(substr($data,23,24));
1650
+				$result['cospar'] = trim(substr($data, 0, 11));
1651
+				$result['norad'] = trim(substr($data, 13, 6));
1652
+				$result['operational'] = trim(substr($data, 21, 1));
1653
+				$result['name'] = trim(substr($data, 23, 24));
1654 1654
 				/*
1655 1655
 				    * R/B(1) = Rocket body, first stage
1656 1656
 				    * R/B(2) = Rocket body, second stage
@@ -1662,29 +1662,29 @@  discard block
 block discarded – undo
1662 1662
 				    * An ampersand (&) indicates two or more objects are attached
1663 1663
 				*/
1664 1664
 				
1665
-				$owner_code = trim(substr($data,49,5));
1665
+				$owner_code = trim(substr($data, 49, 5));
1666 1666
 				
1667 1667
 				if (!isset($satcat_sources[$owner_code])) {
1668 1668
 					echo $data;
1669 1669
 					echo 'owner_code: '.$owner_code."\n";
1670 1670
 				}
1671
-				if (!isset($satcat_launch_site[trim(substr($data,68,5))])) {
1672
-					echo 'launch_site_code: '.trim(substr($data,68,5))."\n";
1671
+				if (!isset($satcat_launch_site[trim(substr($data, 68, 5))])) {
1672
+					echo 'launch_site_code: '.trim(substr($data, 68, 5))."\n";
1673 1673
 				}
1674 1674
 				
1675
-				if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data,68,5))])) {
1675
+				if ($owner_code != 'TBD' && isset($satcat_sources[$owner_code]) && isset($satcat_launch_site[trim(substr($data, 68, 5))])) {
1676 1676
 					$result['country_owner'] = $satcat_sources[$owner_code]['country'];
1677 1677
 					$result['owner'] = $satcat_sources[$owner_code]['owner'];
1678
-					$result['launch_date'] = trim(substr($data,56,10));
1679
-					$launch_site_code = trim(substr($data,68,5));
1678
+					$result['launch_date'] = trim(substr($data, 56, 10));
1679
+					$launch_site_code = trim(substr($data, 68, 5));
1680 1680
 					$result['launch_site'] = $satcat_launch_site[$launch_site_code];
1681
-					$result['lifetime'] = trim(substr($data,75,10));
1682
-					$result['period'] = trim(substr($data,87,7));
1683
-					$result['inclination'] = trim(substr($data,96,5));
1684
-					$result['apogee'] = trim(substr($data,103,6));
1685
-					$result['perigee'] = trim(substr($data,111,6));
1681
+					$result['lifetime'] = trim(substr($data, 75, 10));
1682
+					$result['period'] = trim(substr($data, 87, 7));
1683
+					$result['inclination'] = trim(substr($data, 96, 5));
1684
+					$result['apogee'] = trim(substr($data, 103, 6));
1685
+					$result['perigee'] = trim(substr($data, 111, 6));
1686 1686
 					//$result['radarcross'] = trim(substr($data,119,8));
1687
-					$result['status'] = trim(substr($data,129,3));
1687
+					$result['status'] = trim(substr($data, 129, 3));
1688 1688
 					//print_r($result);
1689 1689
 					$result = array_map(function($value) {
1690 1690
 						return trim($value) === '' ? null : $value;
@@ -1697,7 +1697,7 @@  discard block
 block discarded – undo
1697 1697
 							$sth = $Connection->db->prepare($query);
1698 1698
 							$sth->execute(array(':cospar' => $result['cospar']));
1699 1699
 							$exist = $sth->fetchAll(PDO::FETCH_ASSOC);
1700
-						} catch(PDOException $e) {
1700
+						} catch (PDOException $e) {
1701 1701
 							return "error : ".$e->getMessage();
1702 1702
 						}
1703 1703
 						if (empty($exist)) {
@@ -1709,10 +1709,10 @@  discard block
 block discarded – undo
1709 1709
 								    ':name' => $result['name'], ':name_alternate' => '', ':country_un' => '', ':country_owner' => $result['country_owner'], ':owner' => $result['owner'], ':users' => '', ':purpose' => '', ':purpose_detailed' => '', ':orbit' => $result['status'],
1710 1710
 								    ':type' => '', ':longitude_geo' => NULL, ':perigee' => !empty($result['perigee']) ? $result['perigee'] : NULL, ':apogee' => !empty($result['apogee']) ? $result['apogee'] : NULL, ':eccentricity' => NULL, ':inclination' => $result['inclination'],
1711 1711
 								    ':period' => !empty($result['period']) ? $result['period'] : NULL, ':launch_mass' => NULL, ':dry_mass' => NULL, ':power' => NULL, ':launch_date' => $result['launch_date'], ':lifetime' => $result['lifetime'], 
1712
-								    ':contractor' => '',':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1712
+								    ':contractor' => '', ':country_contractor' => '', ':launch_site' => $result['launch_site'], ':launch_vehicule' => '', ':cospar' => $result['cospar'], ':norad' => $result['norad'], ':comments' => '', ':source_orbital' => '', ':sources' => ''
1713 1713
 								    )
1714 1714
 								);
1715
-							} catch(PDOException $e) {
1715
+							} catch (PDOException $e) {
1716 1716
 								return "error : ".$e->getMessage();
1717 1717
 							}
1718 1718
 						} elseif ($exist[0]['name'] != $result['name'] && $exist[0]['name_alternate'] != $result['name']) {
@@ -1720,8 +1720,8 @@  discard block
 block discarded – undo
1720 1720
 							try {
1721 1721
 								$Connection = new Connection();
1722 1722
 								$sth = $Connection->db->prepare($query);
1723
-								$sth->execute(array(':name_alternate' => $result['name'],':cospar' => $result['cospar']));
1724
-							} catch(PDOException $e) {
1723
+								$sth->execute(array(':name_alternate' => $result['name'], ':cospar' => $result['cospar']));
1724
+							} catch (PDOException $e) {
1725 1725
 								return "error : ".$e->getMessage();
1726 1726
 							}
1727 1727
 						}
@@ -1840,13 +1840,13 @@  discard block
 block discarded – undo
1840 1840
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1841 1841
 			{
1842 1842
 				$i++;
1843
-				if($i > 3 && count($row) > 2) {
1843
+				if ($i > 3 && count($row) > 2) {
1844 1844
 					$data = array_values(array_filter($row));
1845 1845
 					$cntdata = count($data);
1846 1846
 					if ($cntdata > 10) {
1847 1847
 						$value = $data[9];
1848 1848
 						
1849
-						for ($i =10;$i < $cntdata;$i++) {
1849
+						for ($i = 10; $i < $cntdata; $i++) {
1850 1850
 							$value .= ' '.$data[$i];
1851 1851
 						}
1852 1852
 						$data[9] = $value;
@@ -1856,8 +1856,8 @@  discard block
 block discarded – undo
1856 1856
 						$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)';
1857 1857
 						try {
1858 1858
 							$sth = $Connection->db->prepare($query);
1859
-							$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]));
1860
-						} catch(PDOException $e) {
1859
+							$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]));
1860
+						} catch (PDOException $e) {
1861 1861
 							return "error : ".$e->getMessage();
1862 1862
 						}
1863 1863
 					}
@@ -1874,16 +1874,16 @@  discard block
 block discarded – undo
1874 1874
 		require_once(dirname(__FILE__).'/../require/class.Source.php');
1875 1875
 		$delimiter = ',';
1876 1876
 		$Common = new Common();
1877
-		$Common->download('http://firms.modaps.eosdis.nasa.gov/active_fire/viirs/text/VNP14IMGTDL_NRT_Global_24h.csv',$tmp_dir.'fires.csv');
1877
+		$Common->download('http://firms.modaps.eosdis.nasa.gov/active_fire/viirs/text/VNP14IMGTDL_NRT_Global_24h.csv', $tmp_dir.'fires.csv');
1878 1878
 		$Connection = new Connection();
1879 1879
 		$Source = new Source();
1880 1880
 		$Source->deleteLocationByType('fires');
1881 1881
 		$i = 0;
1882
-		if (($handle = fopen($tmp_dir.'fires.csv','r')) !== false) {
1883
-			while (($row = fgetcsv($handle,1000)) !== false) {
1882
+		if (($handle = fopen($tmp_dir.'fires.csv', 'r')) !== false) {
1883
+			while (($row = fgetcsv($handle, 1000)) !== false) {
1884 1884
 				if ($i > 0 && $row[0] != '' && $row[8] != 'low') {
1885
-					$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]);
1886
-					$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));
1885
+					$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]);
1886
+					$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));
1887 1887
 				}
1888 1888
 				$i++;
1889 1889
 			}
@@ -1899,7 +1899,7 @@  discard block
 block discarded – undo
1899 1899
 			$Connection = new Connection();
1900 1900
 			$sth = $Connection->db->prepare($query);
1901 1901
 			$sth->execute();
1902
-		} catch(PDOException $e) {
1902
+		} catch (PDOException $e) {
1903 1903
 			return "error : ".$e->getMessage();
1904 1904
 		}
1905 1905
 		$header = NULL;
@@ -1910,12 +1910,12 @@  discard block
 block discarded – undo
1910 1910
 			if ($globalTransaction) $Connection->db->beginTransaction();
1911 1911
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1912 1912
 			{
1913
-				if(count($row) > 1) {
1913
+				if (count($row) > 1) {
1914 1914
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1915 1915
 					try {
1916 1916
 						$sth = $Connection->db->prepare($query);
1917
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1918
-					} catch(PDOException $e) {
1917
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1918
+					} catch (PDOException $e) {
1919 1919
 						return "error : ".$e->getMessage();
1920 1920
 					}
1921 1921
 				}
@@ -1935,21 +1935,21 @@  discard block
 block discarded – undo
1935 1935
 			try {
1936 1936
 				$sth = $Connection->db->prepare($query);
1937 1937
                     		$sth->execute();
1938
-	                } catch(PDOException $e) {
1938
+	                } catch (PDOException $e) {
1939 1939
 				return "error : ".$e->getMessage();
1940 1940
 	                }
1941 1941
 	        }
1942 1942
 
1943 1943
 
1944
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1944
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1945 1945
 		else {
1946
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1946
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1947 1947
 			$query = "CREATE EXTENSION postgis";
1948
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1948
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1949 1949
 			try {
1950 1950
 				$sth = $Connection->db->prepare($query);
1951 1951
 				$sth->execute();
1952
-			} catch(PDOException $e) {
1952
+			} catch (PDOException $e) {
1953 1953
 				return "error : ".$e->getMessage();
1954 1954
 			}
1955 1955
 		}
@@ -1962,13 +1962,13 @@  discard block
 block discarded – undo
1962 1962
 		include_once('class.create_db.php');
1963 1963
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1964 1964
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1965
-		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5',$tmp_dir.'notam.txt.gz.md5');
1965
+		update_db::download('http://data.flightairmap.com/data/notam.txt.gz.md5', $tmp_dir.'notam.txt.gz.md5');
1966 1966
 		$error = '';
1967 1967
 		if (file_exists($tmp_dir.'notam.txt.gz.md5')) {
1968
-			$notam_md5_file = explode(' ',file_get_contents($tmp_dir.'notam.txt.gz.md5'));
1968
+			$notam_md5_file = explode(' ', file_get_contents($tmp_dir.'notam.txt.gz.md5'));
1969 1969
 			$notam_md5 = $notam_md5_file[0];
1970 1970
 			if (!update_db::check_notam_version($notam_md5)) {
1971
-				update_db::download('http://data.flightairmap.com/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1971
+				update_db::download('http://data.flightairmap.com/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1972 1972
 				if (file_exists($tmp_dir.'notam.txt.gz')) {
1973 1973
 					if (md5_file($tmp_dir.'notam.txt.gz') == $notam_md5) {
1974 1974
 						if ($globalDebug) echo "Gunzip...";
@@ -2004,14 +2004,14 @@  discard block
 block discarded – undo
2004 2004
 			try {
2005 2005
 				$sth = $Connection->db->prepare($query);
2006 2006
             	        	$sth->execute();
2007
-	                } catch(PDOException $e) {
2007
+	                } catch (PDOException $e) {
2008 2008
     	                	echo "error : ".$e->getMessage();
2009 2009
 	                }
2010 2010
 		}
2011 2011
 		if ($globalDBdriver == 'mysql') {
2012
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
2012
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
2013 2013
 		} else {
2014
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
2014
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
2015 2015
 		}
2016 2016
 		$error = create_db::import_file($tmp_dir.'countries.sql');
2017 2017
 		return $error;
@@ -2024,7 +2024,7 @@  discard block
 block discarded – undo
2024 2024
 //		update_db::unzip($tmp_dir.'AptNav.zip');
2025 2025
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
2026 2026
 //		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');
2027
-		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');
2027
+		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');
2028 2028
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
2029 2029
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
2030 2030
 		return $error;
@@ -2045,7 +2045,7 @@  discard block
 block discarded – undo
2045 2045
 				update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
2046 2046
 				if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
2047 2047
 				if (is_writable(dirname(__FILE__).'/../images/airlines')) {
2048
-					if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2048
+					if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
2049 2049
 				} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
2050 2050
 			} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
2051 2051
 		} else $error = "ZIP module not loaded but required for IVAO.";
@@ -2059,7 +2059,7 @@  discard block
 block discarded – undo
2059 2059
 		global $tmp_dir, $globalDebug;
2060 2060
 		$error = '';
2061 2061
 		if ($globalDebug) echo "Routes : Download...";
2062
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
2062
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
2063 2063
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
2064 2064
 			if ($globalDebug) echo "Gunzip...";
2065 2065
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -2075,7 +2075,7 @@  discard block
 block discarded – undo
2075 2075
 		global $tmp_dir, $globalDebug;
2076 2076
 		$error = '';
2077 2077
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
2078
-		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
2078
+		update_db::download('http://data.flightairmap.com/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
2079 2079
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
2080 2080
 			if ($globalDebug) echo "Gunzip...";
2081 2081
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -2091,7 +2091,7 @@  discard block
 block discarded – undo
2091 2091
 		global $tmp_dir, $globalDebug;
2092 2092
 		$error = '';
2093 2093
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
2094
-		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
2094
+		update_db::download('http://data.flightairmap.com/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
2095 2095
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
2096 2096
 			if ($globalDebug) echo "Gunzip...";
2097 2097
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -2119,7 +2119,7 @@  discard block
 block discarded – undo
2119 2119
 */
2120 2120
 		if ($globalDebug) echo "Modes : Download...";
2121 2121
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
2122
-		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
2122
+		update_db::download('http://data.flightairmap.com/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
2123 2123
 
2124 2124
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
2125 2125
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -2139,7 +2139,7 @@  discard block
 block discarded – undo
2139 2139
 	public static function update_ModeS_faa() {
2140 2140
 		global $tmp_dir, $globalDebug;
2141 2141
 		if ($globalDebug) echo "Modes FAA: Download...";
2142
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
2142
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
2143 2143
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
2144 2144
 			if ($globalDebug) echo "Unzip...";
2145 2145
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -2155,7 +2155,7 @@  discard block
 block discarded – undo
2155 2155
 	public static function update_ModeS_flarm() {
2156 2156
 		global $tmp_dir, $globalDebug;
2157 2157
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
2158
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
2158
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
2159 2159
 		if (file_exists($tmp_dir.'data.fln')) {
2160 2160
 			if ($globalDebug) echo "Add to DB...";
2161 2161
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -2169,7 +2169,7 @@  discard block
 block discarded – undo
2169 2169
 	public static function update_ModeS_ogn() {
2170 2170
 		global $tmp_dir, $globalDebug;
2171 2171
 		if ($globalDebug) echo "Modes OGN: Download...";
2172
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
2172
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
2173 2173
 		if (file_exists($tmp_dir.'ogn.csv')) {
2174 2174
 			if ($globalDebug) echo "Add to DB...";
2175 2175
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -2184,201 +2184,201 @@  discard block
 block discarded – undo
2184 2184
 		global $tmp_dir, $globalDebug, $globalMasterSource;
2185 2185
 		
2186 2186
 		if ($globalDebug) echo "Owner France: Download...";
2187
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
2187
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
2188 2188
 		if (file_exists($tmp_dir.'owner_f.csv')) {
2189 2189
 			if ($globalDebug) echo "Add to DB...";
2190
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
2190
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
2191 2191
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
2192 2192
 		if ($error != '') {
2193 2193
 			return $error;
2194 2194
 		} elseif ($globalDebug) echo "Done\n";
2195 2195
 		
2196 2196
 		if ($globalDebug) echo "Owner Ireland: Download...";
2197
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
2197
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
2198 2198
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
2199 2199
 			if ($globalDebug) echo "Add to DB...";
2200
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
2200
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
2201 2201
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
2202 2202
 		if ($error != '') {
2203 2203
 			return $error;
2204 2204
 		} elseif ($globalDebug) echo "Done\n";
2205 2205
 		if ($globalDebug) echo "Owner Switzerland: Download...";
2206
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
2206
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
2207 2207
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
2208 2208
 			if ($globalDebug) echo "Add to DB...";
2209
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
2209
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
2210 2210
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
2211 2211
 		if ($error != '') {
2212 2212
 			return $error;
2213 2213
 		} elseif ($globalDebug) echo "Done\n";
2214 2214
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
2215
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
2215
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
2216 2216
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
2217 2217
 			if ($globalDebug) echo "Add to DB...";
2218
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
2218
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
2219 2219
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
2220 2220
 		if ($error != '') {
2221 2221
 			return $error;
2222 2222
 		} elseif ($globalDebug) echo "Done\n";
2223 2223
 		if ($globalDebug) echo "Owner Australia: Download...";
2224
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
2224
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
2225 2225
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
2226 2226
 			if ($globalDebug) echo "Add to DB...";
2227
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
2227
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
2228 2228
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
2229 2229
 		if ($error != '') {
2230 2230
 			return $error;
2231 2231
 		} elseif ($globalDebug) echo "Done\n";
2232 2232
 		if ($globalDebug) echo "Owner Austria: Download...";
2233
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
2233
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
2234 2234
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
2235 2235
 			if ($globalDebug) echo "Add to DB...";
2236
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
2236
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
2237 2237
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
2238 2238
 		if ($error != '') {
2239 2239
 			return $error;
2240 2240
 		} elseif ($globalDebug) echo "Done\n";
2241 2241
 		if ($globalDebug) echo "Owner Chile: Download...";
2242
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
2242
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
2243 2243
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
2244 2244
 			if ($globalDebug) echo "Add to DB...";
2245
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
2245
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
2246 2246
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
2247 2247
 		if ($error != '') {
2248 2248
 			return $error;
2249 2249
 		} elseif ($globalDebug) echo "Done\n";
2250 2250
 		if ($globalDebug) echo "Owner Colombia: Download...";
2251
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
2251
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
2252 2252
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
2253 2253
 			if ($globalDebug) echo "Add to DB...";
2254
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
2254
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
2255 2255
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
2256 2256
 		if ($error != '') {
2257 2257
 			return $error;
2258 2258
 		} elseif ($globalDebug) echo "Done\n";
2259 2259
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
2260
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
2260
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
2261 2261
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
2262 2262
 			if ($globalDebug) echo "Add to DB...";
2263
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
2263
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
2264 2264
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
2265 2265
 		if ($error != '') {
2266 2266
 			return $error;
2267 2267
 		} elseif ($globalDebug) echo "Done\n";
2268 2268
 		if ($globalDebug) echo "Owner Brazil: Download...";
2269
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
2269
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
2270 2270
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
2271 2271
 			if ($globalDebug) echo "Add to DB...";
2272
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
2272
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
2273 2273
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
2274 2274
 		if ($error != '') {
2275 2275
 			return $error;
2276 2276
 		} elseif ($globalDebug) echo "Done\n";
2277 2277
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
2278
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
2278
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
2279 2279
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
2280 2280
 			if ($globalDebug) echo "Add to DB...";
2281
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
2281
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
2282 2282
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
2283 2283
 		if ($error != '') {
2284 2284
 			return $error;
2285 2285
 		} elseif ($globalDebug) echo "Done\n";
2286 2286
 		if ($globalDebug) echo "Owner Croatia: Download...";
2287
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
2287
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
2288 2288
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
2289 2289
 			if ($globalDebug) echo "Add to DB...";
2290
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
2290
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
2291 2291
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
2292 2292
 		if ($error != '') {
2293 2293
 			return $error;
2294 2294
 		} elseif ($globalDebug) echo "Done\n";
2295 2295
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
2296
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
2296
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
2297 2297
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
2298 2298
 			if ($globalDebug) echo "Add to DB...";
2299
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
2299
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
2300 2300
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
2301 2301
 		if ($error != '') {
2302 2302
 			return $error;
2303 2303
 		} elseif ($globalDebug) echo "Done\n";
2304 2304
 		if ($globalDebug) echo "Owner Maldives: Download...";
2305
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
2305
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
2306 2306
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
2307 2307
 			if ($globalDebug) echo "Add to DB...";
2308
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
2308
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
2309 2309
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
2310 2310
 		if ($error != '') {
2311 2311
 			return $error;
2312 2312
 		} elseif ($globalDebug) echo "Done\n";
2313 2313
 		if ($globalDebug) echo "Owner New Zealand: Download...";
2314
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
2314
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
2315 2315
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
2316 2316
 			if ($globalDebug) echo "Add to DB...";
2317
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
2317
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
2318 2318
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
2319 2319
 		if ($error != '') {
2320 2320
 			return $error;
2321 2321
 		} elseif ($globalDebug) echo "Done\n";
2322 2322
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
2323
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
2323
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
2324 2324
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
2325 2325
 			if ($globalDebug) echo "Add to DB...";
2326
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
2326
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
2327 2327
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
2328 2328
 		if ($error != '') {
2329 2329
 			return $error;
2330 2330
 		} elseif ($globalDebug) echo "Done\n";
2331 2331
 		if ($globalDebug) echo "Owner Slovakia: Download...";
2332
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
2332
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
2333 2333
 		if (file_exists($tmp_dir.'owner_om.csv')) {
2334 2334
 			if ($globalDebug) echo "Add to DB...";
2335
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
2335
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
2336 2336
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
2337 2337
 		if ($error != '') {
2338 2338
 			return $error;
2339 2339
 		} elseif ($globalDebug) echo "Done\n";
2340 2340
 		if ($globalDebug) echo "Owner Ecuador: Download...";
2341
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
2341
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
2342 2342
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
2343 2343
 			if ($globalDebug) echo "Add to DB...";
2344
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
2344
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
2345 2345
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
2346 2346
 		if ($error != '') {
2347 2347
 			return $error;
2348 2348
 		} elseif ($globalDebug) echo "Done\n";
2349 2349
 		if ($globalDebug) echo "Owner Iceland: Download...";
2350
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
2350
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
2351 2351
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
2352 2352
 			if ($globalDebug) echo "Add to DB...";
2353
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
2353
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
2354 2354
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
2355 2355
 		if ($error != '') {
2356 2356
 			return $error;
2357 2357
 		} elseif ($globalDebug) echo "Done\n";
2358 2358
 		if ($globalDebug) echo "Owner Isle of Man: Download...";
2359
-		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
2359
+		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv');
2360 2360
 		if (file_exists($tmp_dir.'owner_m.csv')) {
2361 2361
 			if ($globalDebug) echo "Add to DB...";
2362
-			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
2362
+			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M');
2363 2363
 		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
2364 2364
 		if ($error != '') {
2365 2365
 			return $error;
2366 2366
 		} elseif ($globalDebug) echo "Done\n";
2367 2367
 		if ($globalMasterSource) {
2368 2368
 			if ($globalDebug) echo "ModeS Netherlands: Download...";
2369
-			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
2369
+			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv');
2370 2370
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
2371 2371
 				if ($globalDebug) echo "Add to DB...";
2372
-				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
2372
+				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH');
2373 2373
 			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
2374 2374
 			if ($error != '') {
2375 2375
 				return $error;
2376 2376
 			} elseif ($globalDebug) echo "Done\n";
2377 2377
 			if ($globalDebug) echo "ModeS Denmark: Download...";
2378
-			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
2378
+			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv');
2379 2379
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
2380 2380
 				if ($globalDebug) echo "Add to DB...";
2381
-				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
2381
+				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY');
2382 2382
 			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
2383 2383
 			if ($error != '') {
2384 2384
 				return $error;
@@ -2391,7 +2391,7 @@  discard block
 block discarded – undo
2391 2391
 		global $tmp_dir, $globalDebug;
2392 2392
 		$error = '';
2393 2393
 		if ($globalDebug) echo "Translation : Download...";
2394
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
2394
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
2395 2395
 		if (file_exists($tmp_dir.'translation.zip')) {
2396 2396
 			if ($globalDebug) echo "Unzip...";
2397 2397
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -2408,10 +2408,10 @@  discard block
 block discarded – undo
2408 2408
 		global $tmp_dir, $globalDebug;
2409 2409
 		$error = '';
2410 2410
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
2411
-		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
2412
-		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5',$tmp_dir.'translation.tsv.gz.md5');
2411
+		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
2412
+		update_db::download('http://data.flightairmap.com/data/translation.tsv.gz.md5', $tmp_dir.'translation.tsv.gz.md5');
2413 2413
 		if (file_exists($tmp_dir.'translation.tsv.gz') && file_exists($tmp_dir.'translation.tsv.gz')) {
2414
-			$translation_md5_file = explode(' ',file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2414
+			$translation_md5_file = explode(' ', file_get_contents($tmp_dir.'translation.tsv.gz.md5'));
2415 2415
 			$translation_md5 = $translation_md5_file[0];
2416 2416
 			if (md5_file($tmp_dir.'translation.tsv.gz') == $translation_md5) {
2417 2417
 				if ($globalDebug) echo "Gunzip...";
@@ -2429,10 +2429,10 @@  discard block
 block discarded – undo
2429 2429
 		global $tmp_dir, $globalDebug;
2430 2430
 		$error = '';
2431 2431
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
2432
-		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
2433
-		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5',$tmp_dir.'modes.tsv.gz.md5');
2432
+		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
2433
+		update_db::download('http://data.flightairmap.com/data/modes.tsv.gz.md5', $tmp_dir.'modes.tsv.gz.md5');
2434 2434
 		if (file_exists($tmp_dir.'modes.tsv.gz') && file_exists($tmp_dir.'modes.tsv.gz.md5')) {
2435
-			$modes_md5_file = explode(' ',file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2435
+			$modes_md5_file = explode(' ', file_get_contents($tmp_dir.'modes.tsv.gz.md5'));
2436 2436
 			$modes_md5 = $modes_md5_file[0];
2437 2437
 			if (md5_file($tmp_dir.'modes.tsv.gz') == $modes_md5) {
2438 2438
 				if ($globalDebug) echo "Gunzip...";
@@ -2451,12 +2451,12 @@  discard block
 block discarded – undo
2451 2451
 		global $tmp_dir, $globalDebug;
2452 2452
 		$error = '';
2453 2453
 		if ($globalDebug) echo "Airlines from FlightAirMap website : Download...";
2454
-		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5',$tmp_dir.'airlines.tsv.gz.md5');
2454
+		update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz.md5', $tmp_dir.'airlines.tsv.gz.md5');
2455 2455
 		if (file_exists($tmp_dir.'airlines.tsv.gz.md5')) {
2456
-			$airlines_md5_file = explode(' ',file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
2456
+			$airlines_md5_file = explode(' ', file_get_contents($tmp_dir.'airlines.tsv.gz.md5'));
2457 2457
 			$airlines_md5 = $airlines_md5_file[0];
2458 2458
 			if (!update_db::check_airlines_version($airlines_md5)) {
2459
-				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz',$tmp_dir.'airlines.tsv.gz');
2459
+				update_db::download('http://data.flightairmap.com/data/airlines.tsv.gz', $tmp_dir.'airlines.tsv.gz');
2460 2460
 				if (file_exists($tmp_dir.'airlines.tsv.gz')) {
2461 2461
 					if (md5_file($tmp_dir.'airlines.tsv.gz') == $airlines_md5) {
2462 2462
 						if ($globalDebug) echo "Gunzip...";
@@ -2481,14 +2481,14 @@  discard block
 block discarded – undo
2481 2481
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
2482 2482
 		$error = '';
2483 2483
 		if ($globalOwner === TRUE) {
2484
-			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
2485
-			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5');
2484
+			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
2485
+			update_db::download('http://data.flightairmap.com/data/owners_all.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5');
2486 2486
 		} else {
2487
-			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
2488
-			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5',$tmp_dir.'owners.tsv.gz.md5');
2487
+			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
2488
+			update_db::download('http://data.flightairmap.com/data/owners.tsv.gz.md5', $tmp_dir.'owners.tsv.gz.md5');
2489 2489
 		}
2490 2490
 		if (file_exists($tmp_dir.'owners.tsv.gz') && file_exists($tmp_dir.'owners.tsv.gz.md5')) {
2491
-			$owners_md5_file = explode(' ',file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2491
+			$owners_md5_file = explode(' ', file_get_contents($tmp_dir.'owners.tsv.gz.md5'));
2492 2492
 			$owners_md5 = $owners_md5_file[0];
2493 2493
 			if (md5_file($tmp_dir.'owners.tsv.gz') == $owners_md5) {
2494 2494
 				if ($globalDebug) echo "Gunzip...";
@@ -2505,10 +2505,10 @@  discard block
 block discarded – undo
2505 2505
 	public static function update_routes_fam() {
2506 2506
 		global $tmp_dir, $globalDebug;
2507 2507
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2508
-		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2509
-		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5',$tmp_dir.'routes.tsv.gz.md5');
2508
+		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
2509
+		update_db::download('http://data.flightairmap.com/data/routes.tsv.gz.md5', $tmp_dir.'routes.tsv.gz.md5');
2510 2510
 		if (file_exists($tmp_dir.'routes.tsv.gz') && file_exists($tmp_dir.'routes.tsv.gz.md5')) {
2511
-			$routes_md5_file = explode(' ',file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2511
+			$routes_md5_file = explode(' ', file_get_contents($tmp_dir.'routes.tsv.gz.md5'));
2512 2512
 			$routes_md5 = $routes_md5_file[0];
2513 2513
 			if (md5_file($tmp_dir.'routes.tsv.gz') == $routes_md5) {
2514 2514
 				if ($globalDebug) echo "Gunzip...";
@@ -2524,13 +2524,13 @@  discard block
 block discarded – undo
2524 2524
 	}
2525 2525
 	public static function update_marine_identity_fam() {
2526 2526
 		global $tmp_dir, $globalDebug;
2527
-		update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5');
2527
+		update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5');
2528 2528
 		if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) {
2529
-			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2529
+			$marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2530 2530
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2531 2531
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2532 2532
 				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2533
-				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2533
+				update_db::download('http://data.flightairmap.com/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz');
2534 2534
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2535 2535
 					if (md5_file($tmp_dir.'marine_identity.tsv.gz') == $marine_identity_md5) {
2536 2536
 						if ($globalDebug) echo "Gunzip...";
@@ -2552,13 +2552,13 @@  discard block
 block discarded – undo
2552 2552
 
2553 2553
 	public static function update_satellite_fam() {
2554 2554
 		global $tmp_dir, $globalDebug;
2555
-		update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5',$tmp_dir.'satellite.tsv.gz.md5');
2555
+		update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz.md5', $tmp_dir.'satellite.tsv.gz.md5');
2556 2556
 		if (file_exists($tmp_dir.'satellite.tsv.gz.md5')) {
2557
-			$satellite_md5_file = explode(' ',file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2557
+			$satellite_md5_file = explode(' ', file_get_contents($tmp_dir.'satellite.tsv.gz.md5'));
2558 2558
 			$satellite_md5 = $satellite_md5_file[0];
2559 2559
 			if (!update_db::check_satellite_version($satellite_md5)) {
2560 2560
 				if ($globalDebug) echo "Satellite from FlightAirMap website : Download...";
2561
-				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz',$tmp_dir.'satellite.tsv.gz');
2561
+				update_db::download('http://data.flightairmap.com/data/satellite.tsv.gz', $tmp_dir.'satellite.tsv.gz');
2562 2562
 				if (file_exists($tmp_dir.'satellite.tsv.gz')) {
2563 2563
 					if (md5_file($tmp_dir.'satellite.tsv.gz') == $satellite_md5) {
2564 2564
 						if ($globalDebug) echo "Gunzip...";
@@ -2580,7 +2580,7 @@  discard block
 block discarded – undo
2580 2580
 	public static function update_banned_fam() {
2581 2581
 		global $tmp_dir, $globalDebug;
2582 2582
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2583
-		update_db::download('http://data.flightairmap.com/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2583
+		update_db::download('http://data.flightairmap.com/data/ban-eu.csv', $tmp_dir.'ban_eu.csv');
2584 2584
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2585 2585
 			//if ($globalDebug) echo "Gunzip...";
2586 2586
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -2599,18 +2599,18 @@  discard block
 block discarded – undo
2599 2599
 		$error = '';
2600 2600
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2601 2601
 		if ($globalDBdriver == 'mysql') {
2602
-			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2602
+			update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2603 2603
 		} else {
2604
-			update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2604
+			update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2605 2605
 		}
2606 2606
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
2607
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2607
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2608 2608
 			$airspace_md5 = $airspace_md5_file[0];
2609 2609
 			if (!update_db::check_airspace_version($airspace_md5)) {
2610 2610
 				if ($globalDBdriver == 'mysql') {
2611
-					update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
2611
+					update_db::download('http://data.flightairmap.com/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
2612 2612
 				} else {
2613
-					update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2613
+					update_db::download('http://data.flightairmap.com/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
2614 2614
 				}
2615 2615
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2616 2616
 					if (md5_file($tmp_dir.'airspace.sql.gz') == $airspace_md5) {
@@ -2623,7 +2623,7 @@  discard block
 block discarded – undo
2623 2623
 							try {
2624 2624
 								$sth = $Connection->db->prepare($query);
2625 2625
 								$sth->execute();
2626
-							} catch(PDOException $e) {
2626
+							} catch (PDOException $e) {
2627 2627
 								return "error : ".$e->getMessage();
2628 2628
 							}
2629 2629
 						}
@@ -2643,16 +2643,16 @@  discard block
 block discarded – undo
2643 2643
 		global $tmp_dir, $globalDebug, $globalGeoidSource;
2644 2644
 		$error = '';
2645 2645
 		if ($globalDebug) echo "Geoid from FlightAirMap website : Download...";
2646
-		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5',$tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2646
+		update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz.md5', $tmp_dir.$globalGeoidSource.'.pgm.gz.md5');
2647 2647
 		if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz.md5')) {
2648
-			$geoid_md5_file = explode(' ',file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2648
+			$geoid_md5_file = explode(' ', file_get_contents($tmp_dir.$globalGeoidSource.'.pgm.gz.md5'));
2649 2649
 			$geoid_md5 = $geoid_md5_file[0];
2650 2650
 			if (!update_db::check_geoid_version($geoid_md5)) {
2651
-				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz',$tmp_dir.$globalGeoidSource.'.pgm.gz');
2651
+				update_db::download('http://data.flightairmap.com/data/geoid/'.$globalGeoidSource.'.pgm.gz', $tmp_dir.$globalGeoidSource.'.pgm.gz');
2652 2652
 				if (file_exists($tmp_dir.$globalGeoidSource.'.pgm.gz')) {
2653 2653
 					if (md5_file($tmp_dir.$globalGeoidSource.'.pgm.gz') == $geoid_md5) {
2654 2654
 						if ($globalDebug) echo "Gunzip...";
2655
-						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz',dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2655
+						update_db::gunzip($tmp_dir.$globalGeoidSource.'.pgm.gz', dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm');
2656 2656
 						if (file_exists(dirname(__FILE__).'/../data/'.$globalGeoidSource.'.pgm')) {
2657 2657
 							update_db::insert_geoid_version($geoid_md5);
2658 2658
 						}
@@ -2669,15 +2669,15 @@  discard block
 block discarded – undo
2669 2669
 	public static function update_tle() {
2670 2670
 		global $tmp_dir, $globalDebug;
2671 2671
 		if ($globalDebug) echo "Download TLE : Download...";
2672
-		$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',
2673
-		'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',
2674
-		'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');
2672
+		$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',
2673
+		'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',
2674
+		'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');
2675 2675
 		foreach ($alltle as $filename) {
2676 2676
 			if ($globalDebug) echo "downloading ".$filename.'...';
2677
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2677
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
2678 2678
 			if (file_exists($tmp_dir.$filename)) {
2679 2679
 				if ($globalDebug) echo "Add to DB ".$filename."...";
2680
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2680
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
2681 2681
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2682 2682
 			if ($error != '') {
2683 2683
 				echo $error."\n";
@@ -2689,7 +2689,7 @@  discard block
 block discarded – undo
2689 2689
 	public static function update_ucsdb() {
2690 2690
 		global $tmp_dir, $globalDebug;
2691 2691
 		if ($globalDebug) echo "Download UCS DB : Download...";
2692
-		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt',$tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2692
+		update_db::download('https://s3.amazonaws.com/ucs-documents/nuclear-weapons/sat-database/4-11-17-update/UCS_Satellite_Database_officialname_1-1-17.txt', $tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
2693 2693
 		if (file_exists($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt')) {
2694 2694
 			if ($globalDebug) echo "Add to DB...";
2695 2695
 			$error = update_db::satellite_ucsdb($tmp_dir.'UCS_Satellite_Database_officialname_1-1-17.txt');
@@ -2703,7 +2703,7 @@  discard block
 block discarded – undo
2703 2703
 	public static function update_celestrak() {
2704 2704
 		global $tmp_dir, $globalDebug;
2705 2705
 		if ($globalDebug) echo "Download Celestrak DB : Download...";
2706
-		update_db::download('http://celestrak.com/pub/satcat.txt',$tmp_dir.'satcat.txt');
2706
+		update_db::download('http://celestrak.com/pub/satcat.txt', $tmp_dir.'satcat.txt');
2707 2707
 		if (file_exists($tmp_dir.'satcat.txt')) {
2708 2708
 			if ($globalDebug) echo "Add to DB...";
2709 2709
 			$error = update_db::satellite_celestrak($tmp_dir.'satcat.txt');
@@ -2718,63 +2718,63 @@  discard block
 block discarded – undo
2718 2718
 		global $tmp_dir, $globalDebug;
2719 2719
 		$error = '';
2720 2720
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2721
-		update_db::download('http://data.flightairmap.com/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2721
+		update_db::download('http://data.flightairmap.com/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2722 2722
 		if (file_exists($tmp_dir.'models.md5sum')) {
2723 2723
 			if ($globalDebug) echo "Check files...\n";
2724 2724
 			$newmodelsdb = array();
2725
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2726
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2725
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2726
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2727 2727
 					$model = trim($row[2]);
2728 2728
 					$newmodelsdb[$model] = trim($row[0]);
2729 2729
 				}
2730 2730
 			}
2731 2731
 			$modelsdb = array();
2732 2732
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2733
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2734
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2733
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2734
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2735 2735
 						$model = trim($row[2]);
2736 2736
 						$modelsdb[$model] = trim($row[0]);
2737 2737
 					}
2738 2738
 				}
2739 2739
 			}
2740
-			$diff = array_diff($newmodelsdb,$modelsdb);
2740
+			$diff = array_diff($newmodelsdb, $modelsdb);
2741 2741
 			foreach ($diff as $key => $value) {
2742 2742
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2743
-				update_db::download('http://data.flightairmap.com/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2743
+				update_db::download('http://data.flightairmap.com/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2744 2744
 				
2745 2745
 			}
2746
-			update_db::download('http://data.flightairmap.com/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2746
+			update_db::download('http://data.flightairmap.com/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2747 2747
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2748 2748
 		if ($error != '') {
2749 2749
 			return $error;
2750 2750
 		} elseif ($globalDebug) echo "Done\n";
2751 2751
 		if ($globalDebug) echo "glTF 2.0 Models from FlightAirMap website : Download...";
2752
-		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',$tmp_dir.'modelsgltf2.md5sum');
2752
+		update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum', $tmp_dir.'modelsgltf2.md5sum');
2753 2753
 		if (file_exists($tmp_dir.'modelsgltf2.md5sum')) {
2754 2754
 			if ($globalDebug) echo "Check files...\n";
2755 2755
 			$newmodelsdb = array();
2756
-			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum','r')) !== FALSE) {
2757
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2756
+			if (($handle = fopen($tmp_dir.'modelsgltf2.md5sum', 'r')) !== FALSE) {
2757
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2758 2758
 					$model = trim($row[2]);
2759 2759
 					$newmodelsdb[$model] = trim($row[0]);
2760 2760
 				}
2761 2761
 			}
2762 2762
 			$modelsdb = array();
2763 2763
 			if (file_exists(dirname(__FILE__).'/../models/gltf2/models.md5sum')) {
2764
-				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/models.md5sum','r')) !== FALSE) {
2765
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2764
+				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/models.md5sum', 'r')) !== FALSE) {
2765
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2766 2766
 						$model = trim($row[2]);
2767 2767
 						$modelsdb[$model] = trim($row[0]);
2768 2768
 					}
2769 2769
 				}
2770 2770
 			}
2771
-			$diff = array_diff($newmodelsdb,$modelsdb);
2771
+			$diff = array_diff($newmodelsdb, $modelsdb);
2772 2772
 			foreach ($diff as $key => $value) {
2773 2773
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2774
-				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key,dirname(__FILE__).'/../models/gltf2/'.$key);
2774
+				update_db::download('http://data.flightairmap.com/data/models/gltf2/'.$key, dirname(__FILE__).'/../models/gltf2/'.$key);
2775 2775
 				
2776 2776
 			}
2777
-			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum',dirname(__FILE__).'/../models/gltf2/models.md5sum');
2777
+			update_db::download('http://data.flightairmap.com/data/models/gltf2/models.md5sum', dirname(__FILE__).'/../models/gltf2/models.md5sum');
2778 2778
 		} else $error = "File ".$tmp_dir.'modelsgltf2.md5sum'." doesn't exist. Download failed.";
2779 2779
 		if ($error != '') {
2780 2780
 			return $error;
@@ -2786,32 +2786,32 @@  discard block
 block discarded – undo
2786 2786
 		global $tmp_dir, $globalDebug;
2787 2787
 		$error = '';
2788 2788
 		if ($globalDebug) echo "Liveries from FlightAirMap website : Download...";
2789
-		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',$tmp_dir.'liveries.md5sum');
2789
+		update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum', $tmp_dir.'liveries.md5sum');
2790 2790
 		if (file_exists($tmp_dir.'liveries.md5sum')) {
2791 2791
 			if ($globalDebug) echo "Check files...\n";
2792 2792
 			$newmodelsdb = array();
2793
-			if (($handle = fopen($tmp_dir.'liveries.md5sum','r')) !== FALSE) {
2794
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2793
+			if (($handle = fopen($tmp_dir.'liveries.md5sum', 'r')) !== FALSE) {
2794
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2795 2795
 					$model = trim($row[2]);
2796 2796
 					$newmodelsdb[$model] = trim($row[0]);
2797 2797
 				}
2798 2798
 			}
2799 2799
 			$modelsdb = array();
2800 2800
 			if (file_exists(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum')) {
2801
-				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum','r')) !== FALSE) {
2802
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2801
+				if (($handle = fopen(dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum', 'r')) !== FALSE) {
2802
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2803 2803
 						$model = trim($row[2]);
2804 2804
 						$modelsdb[$model] = trim($row[0]);
2805 2805
 					}
2806 2806
 				}
2807 2807
 			}
2808
-			$diff = array_diff($newmodelsdb,$modelsdb);
2808
+			$diff = array_diff($newmodelsdb, $modelsdb);
2809 2809
 			foreach ($diff as $key => $value) {
2810 2810
 				if ($globalDebug) echo 'Downloading liveries '.$key.' ...'."\n";
2811
-				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key,dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2811
+				update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/'.$key, dirname(__FILE__).'/../models/gltf2/liveries/'.$key);
2812 2812
 				
2813 2813
 			}
2814
-			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum',dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2814
+			update_db::download('http://data.flightairmap.com/data/models/gltf2/liveries/liveries.md5sum', dirname(__FILE__).'/../models/gltf2/liveries/liveries.md5sum');
2815 2815
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2816 2816
 		if ($error != '') {
2817 2817
 			return $error;
@@ -2823,32 +2823,32 @@  discard block
 block discarded – undo
2823 2823
 		global $tmp_dir, $globalDebug;
2824 2824
 		$error = '';
2825 2825
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2826
-		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2826
+		update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
2827 2827
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2828 2828
 			if ($globalDebug) echo "Check files...\n";
2829 2829
 			$newmodelsdb = array();
2830
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2831
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2830
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
2831
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2832 2832
 					$model = trim($row[2]);
2833 2833
 					$newmodelsdb[$model] = trim($row[0]);
2834 2834
 				}
2835 2835
 			}
2836 2836
 			$modelsdb = array();
2837 2837
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
2838
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
2839
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2838
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
2839
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2840 2840
 						$model = trim($row[2]);
2841 2841
 						$modelsdb[$model] = trim($row[0]);
2842 2842
 					}
2843 2843
 				}
2844 2844
 			}
2845
-			$diff = array_diff($newmodelsdb,$modelsdb);
2845
+			$diff = array_diff($newmodelsdb, $modelsdb);
2846 2846
 			foreach ($diff as $key => $value) {
2847 2847
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2848
-				update_db::download('http://data.flightairmap.com/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2848
+				update_db::download('http://data.flightairmap.com/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2849 2849
 				
2850 2850
 			}
2851
-			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2851
+			update_db::download('http://data.flightairmap.com/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2852 2852
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2853 2853
 		if ($error != '') {
2854 2854
 			return $error;
@@ -2860,32 +2860,32 @@  discard block
 block discarded – undo
2860 2860
 		global $tmp_dir, $globalDebug;
2861 2861
 		$error = '';
2862 2862
 		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2863
-		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2863
+		update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum');
2864 2864
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2865 2865
 			if ($globalDebug) echo "Check files...\n";
2866 2866
 			$newmodelsdb = array();
2867
-			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2868
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2867
+			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) {
2868
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2869 2869
 					$model = trim($row[2]);
2870 2870
 					$newmodelsdb[$model] = trim($row[0]);
2871 2871
 				}
2872 2872
 			}
2873 2873
 			$modelsdb = array();
2874 2874
 			if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) {
2875
-				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) {
2876
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2875
+				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) {
2876
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2877 2877
 						$model = trim($row[2]);
2878 2878
 						$modelsdb[$model] = trim($row[0]);
2879 2879
 					}
2880 2880
 				}
2881 2881
 			}
2882
-			$diff = array_diff($newmodelsdb,$modelsdb);
2882
+			$diff = array_diff($newmodelsdb, $modelsdb);
2883 2883
 			foreach ($diff as $key => $value) {
2884 2884
 				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2885
-				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2885
+				update_db::download('http://data.flightairmap.com/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key);
2886 2886
 				
2887 2887
 			}
2888
-			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2888
+			update_db::download('http://data.flightairmap.com/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2889 2889
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2890 2890
 		if ($error != '') {
2891 2891
 			return $error;
@@ -2897,8 +2897,8 @@  discard block
 block discarded – undo
2897 2897
 		global $tmp_dir, $globalDebug;
2898 2898
 		date_default_timezone_set('UTC');
2899 2899
 		$Common = new Common();
2900
-		$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);
2901
-		$all = json_decode($data,true);
2900
+		$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);
2901
+		$all = json_decode($data, true);
2902 2902
 		$Connection = new Connection();
2903 2903
 		$querychk = "SELECT COUNT(1) as nb FROM aircraft WHERE icao = :icao";
2904 2904
 		$sth = $Connection->db->prepare($querychk);
@@ -2910,8 +2910,8 @@  discard block
 block discarded – undo
2910 2910
 		foreach ($all as $model) {
2911 2911
 			$icao = $model['Designator'];
2912 2912
 			if (!isset($allicao[$icao])) {
2913
-				$aircraft_shadow = 'generic_'.substr($model['EngineType'],0,1).$model['EngineCount'].$model['WTC'].'.png';
2914
-				$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']);
2913
+				$aircraft_shadow = 'generic_'.substr($model['EngineType'], 0, 1).$model['EngineCount'].$model['WTC'].'.png';
2914
+				$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']);
2915 2915
 			} else {
2916 2916
 				$allicao[$icao][':type'] = $allicao[$icao][':type'].'/'.$model['ModelFullName'];
2917 2917
 			}
@@ -2923,9 +2923,9 @@  discard block
 block discarded – undo
2923 2923
 				if ($exist[0]['nb'] == 0) {
2924 2924
 					$sthins->execute($airdata);
2925 2925
 				} else {
2926
-					$sthup->execute(array(':type' => $airdata[':type'],':icao' => $icao));
2926
+					$sthup->execute(array(':type' => $airdata[':type'], ':icao' => $icao));
2927 2927
 				}
2928
-			} catch(PDOException $e) {
2928
+			} catch (PDOException $e) {
2929 2929
 				return "error : ".$e->getMessage();
2930 2930
 			}
2931 2931
 		}
@@ -2957,23 +2957,23 @@  discard block
 block discarded – undo
2957 2957
 			$Connection = new Connection();
2958 2958
 			$sth = $Connection->db->prepare($query);
2959 2959
                         $sth->execute();
2960
-                } catch(PDOException $e) {
2960
+                } catch (PDOException $e) {
2961 2961
                         return "error : ".$e->getMessage();
2962 2962
                 }
2963 2963
 
2964 2964
 		$error = '';
2965 2965
 		if ($globalDebug) echo "Notam : Download...";
2966
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2966
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
2967 2967
 		if (file_exists($tmp_dir.'notam.rss')) {
2968
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
2968
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
2969 2969
 			foreach ($notams['channel']['item'] as $notam) {
2970
-				$title = explode(':',$notam['title']);
2970
+				$title = explode(':', $notam['title']);
2971 2971
 				$data['ref'] = trim($title[0]);
2972 2972
 				unset($title[0]);
2973
-				$data['title'] = trim(implode(':',$title));
2974
-				$description = strip_tags($notam['description'],'<pre>');
2975
-				preg_match(':^(.*?)<pre>:',$description,$match);
2976
-				$q = explode('/',$match[1]);
2973
+				$data['title'] = trim(implode(':', $title));
2974
+				$description = strip_tags($notam['description'], '<pre>');
2975
+				preg_match(':^(.*?)<pre>:', $description, $match);
2976
+				$q = explode('/', $match[1]);
2977 2977
 				$data['fir'] = $q[0];
2978 2978
 				$data['code'] = $q[1];
2979 2979
 				$ifrvfr = $q[2];
@@ -2989,30 +2989,30 @@  discard block
 block discarded – undo
2989 2989
 				$data['lower_limit'] = $q[5];
2990 2990
 				$data['upper_limit'] = $q[6];
2991 2991
 				$latlonrad = $q[7];
2992
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2993
-				$latitude = $Common->convertDec($las,'latitude');
2994
-				$longitude = $Common->convertDec($lns,'longitude');
2992
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
2993
+				$latitude = $Common->convertDec($las, 'latitude');
2994
+				$longitude = $Common->convertDec($lns, 'longitude');
2995 2995
 				if ($lac == 'S') $latitude = '-'.$latitude;
2996 2996
 				if ($lnc == 'W') $longitude = '-'.$longitude;
2997 2997
 				$data['center_latitude'] = $latitude;
2998 2998
 				$data['center_longitude'] = $longitude;
2999 2999
 				$data['radius'] = intval($radius);
3000 3000
 				
3001
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
3001
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
3002 3002
 				$data['text'] = $match[1];
3003
-				preg_match(':</pre>(.*?)$:',$description,$match);
3003
+				preg_match(':</pre>(.*?)$:', $description, $match);
3004 3004
 				$fromto = $match[1];
3005
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
3005
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
3006 3006
 				$fromall = trim($match[1]);
3007
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
3007
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
3008 3008
 				$from = trim($match[1]);
3009
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
3010
-				preg_match('#TO:(.*?)$#',$fromto,$match);
3009
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
3010
+				preg_match('#TO:(.*?)$#', $fromto, $match);
3011 3011
 				$toall = trim($match[1]);
3012
-				if (!preg_match(':Permanent:',$toall)) {
3013
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
3012
+				if (!preg_match(':Permanent:', $toall)) {
3013
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
3014 3014
 					$to = trim($match[1]);
3015
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
3015
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
3016 3016
 					$data['permanent'] = 0;
3017 3017
 				} else {
3018 3018
 				    $data['date_end'] = NULL;
@@ -3020,7 +3020,7 @@  discard block
 block discarded – undo
3020 3020
 				}
3021 3021
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
3022 3022
 				$NOTAM = new NOTAM();
3023
-				$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']);
3023
+				$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']);
3024 3024
 				unset($data);
3025 3025
 			} 
3026 3026
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -3043,16 +3043,16 @@  discard block
 block discarded – undo
3043 3043
 				$Connection = new Connection();
3044 3044
 				$sth = $Connection->db->prepare($query);
3045 3045
 				$sth->execute();
3046
-			} catch(PDOException $e) {
3046
+			} catch (PDOException $e) {
3047 3047
 				return "error : ".$e->getMessage();
3048 3048
 			}
3049 3049
 		}
3050 3050
 		$Common = new Common();
3051 3051
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
3052
-		$airspace_json = json_decode($airspace_lst,true);
3052
+		$airspace_json = json_decode($airspace_lst, true);
3053 3053
 		foreach ($airspace_json['records'] as $airspace) {
3054 3054
 			if ($globalDebug) echo $airspace['name']."...\n";
3055
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
3055
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
3056 3056
 			if (file_exists($tmp_dir.$airspace['name'])) {
3057 3057
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
3058 3058
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -3074,7 +3074,7 @@  discard block
 block discarded – undo
3074 3074
 				$Connection = new Connection();
3075 3075
 				$sth = $Connection->db->prepare($query);
3076 3076
 				$sth->execute(array(':new' => $new, ':old' => $old));
3077
-			} catch(PDOException $e) {
3077
+			} catch (PDOException $e) {
3078 3078
 				return "error : ".$e->getMessage();
3079 3079
 			}
3080 3080
 		}
@@ -3091,7 +3091,7 @@  discard block
 block discarded – undo
3091 3091
 			$Connection = new Connection();
3092 3092
 			$sth = $Connection->db->prepare($query);
3093 3093
                         $sth->execute();
3094
-                } catch(PDOException $e) {
3094
+                } catch (PDOException $e) {
3095 3095
                         return "error : ".$e->getMessage();
3096 3096
                 }
3097 3097
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3106,7 +3106,7 @@  discard block
 block discarded – undo
3106 3106
 			$Connection = new Connection();
3107 3107
 			$sth = $Connection->db->prepare($query);
3108 3108
                         $sth->execute();
3109
-                } catch(PDOException $e) {
3109
+                } catch (PDOException $e) {
3110 3110
                         return "error : ".$e->getMessage();
3111 3111
                 }
3112 3112
 	}
@@ -3117,7 +3117,7 @@  discard block
 block discarded – undo
3117 3117
 			$Connection = new Connection();
3118 3118
 			$sth = $Connection->db->prepare($query);
3119 3119
                         $sth->execute(array(':version' => $version));
3120
-                } catch(PDOException $e) {
3120
+                } catch (PDOException $e) {
3121 3121
                         return "error : ".$e->getMessage();
3122 3122
                 }
3123 3123
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3131,7 +3131,7 @@  discard block
 block discarded – undo
3131 3131
 			$Connection = new Connection();
3132 3132
 			$sth = $Connection->db->prepare($query);
3133 3133
                         $sth->execute(array(':version' => $version));
3134
-                } catch(PDOException $e) {
3134
+                } catch (PDOException $e) {
3135 3135
                         return "error : ".$e->getMessage();
3136 3136
                 }
3137 3137
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3145,7 +3145,7 @@  discard block
 block discarded – undo
3145 3145
 			$Connection = new Connection();
3146 3146
 			$sth = $Connection->db->prepare($query);
3147 3147
 			$sth->execute(array(':version' => $version));
3148
-		} catch(PDOException $e) {
3148
+		} catch (PDOException $e) {
3149 3149
 			return "error : ".$e->getMessage();
3150 3150
 		}
3151 3151
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3159,7 +3159,7 @@  discard block
 block discarded – undo
3159 3159
 			$Connection = new Connection();
3160 3160
 			$sth = $Connection->db->prepare($query);
3161 3161
 			$sth->execute(array(':version' => $version));
3162
-		} catch(PDOException $e) {
3162
+		} catch (PDOException $e) {
3163 3163
 			return "error : ".$e->getMessage();
3164 3164
 		}
3165 3165
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3173,7 +3173,7 @@  discard block
 block discarded – undo
3173 3173
 			$Connection = new Connection();
3174 3174
 			$sth = $Connection->db->prepare($query);
3175 3175
 			$sth->execute(array(':version' => $version));
3176
-		} catch(PDOException $e) {
3176
+		} catch (PDOException $e) {
3177 3177
 			return "error : ".$e->getMessage();
3178 3178
 		}
3179 3179
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3187,7 +3187,7 @@  discard block
 block discarded – undo
3187 3187
 			$Connection = new Connection();
3188 3188
 			$sth = $Connection->db->prepare($query);
3189 3189
 			$sth->execute(array(':version' => $version));
3190
-		} catch(PDOException $e) {
3190
+		} catch (PDOException $e) {
3191 3191
 			return "error : ".$e->getMessage();
3192 3192
 		}
3193 3193
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3202,7 +3202,7 @@  discard block
 block discarded – undo
3202 3202
 			$Connection = new Connection();
3203 3203
 			$sth = $Connection->db->prepare($query);
3204 3204
 			$sth->execute(array(':version' => $version));
3205
-		} catch(PDOException $e) {
3205
+		} catch (PDOException $e) {
3206 3206
 			return "error : ".$e->getMessage();
3207 3207
 		}
3208 3208
 	}
@@ -3214,7 +3214,7 @@  discard block
 block discarded – undo
3214 3214
 			$Connection = new Connection();
3215 3215
 			$sth = $Connection->db->prepare($query);
3216 3216
 			$sth->execute(array(':version' => $version));
3217
-		} catch(PDOException $e) {
3217
+		} catch (PDOException $e) {
3218 3218
 			return "error : ".$e->getMessage();
3219 3219
 		}
3220 3220
 	}
@@ -3226,7 +3226,7 @@  discard block
 block discarded – undo
3226 3226
 			$Connection = new Connection();
3227 3227
 			$sth = $Connection->db->prepare($query);
3228 3228
 			$sth->execute(array(':version' => $version));
3229
-		} catch(PDOException $e) {
3229
+		} catch (PDOException $e) {
3230 3230
 			return "error : ".$e->getMessage();
3231 3231
 		}
3232 3232
 	}
@@ -3238,7 +3238,7 @@  discard block
 block discarded – undo
3238 3238
 			$Connection = new Connection();
3239 3239
 			$sth = $Connection->db->prepare($query);
3240 3240
                         $sth->execute(array(':version' => $version));
3241
-                } catch(PDOException $e) {
3241
+                } catch (PDOException $e) {
3242 3242
                         return "error : ".$e->getMessage();
3243 3243
                 }
3244 3244
 	}
@@ -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
 	}
@@ -3262,7 +3262,7 @@  discard block
 block discarded – undo
3262 3262
 			$Connection = new Connection();
3263 3263
 			$sth = $Connection->db->prepare($query);
3264 3264
 			$sth->execute(array(':version' => $version));
3265
-		} catch(PDOException $e) {
3265
+		} catch (PDOException $e) {
3266 3266
 			return "error : ".$e->getMessage();
3267 3267
 		}
3268 3268
 	}
@@ -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();
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();
3296
-                } catch(PDOException $e) {
3296
+                } catch (PDOException $e) {
3297 3297
                         return "error : ".$e->getMessage();
3298 3298
                 }
3299 3299
 	}
@@ -3309,7 +3309,7 @@  discard block
 block discarded – undo
3309 3309
 			$Connection = new Connection();
3310 3310
 			$sth = $Connection->db->prepare($query);
3311 3311
                         $sth->execute();
3312
-                } catch(PDOException $e) {
3312
+                } catch (PDOException $e) {
3313 3313
                         return "error : ".$e->getMessage();
3314 3314
                 }
3315 3315
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3324,7 +3324,7 @@  discard block
 block discarded – undo
3324 3324
 			$Connection = new Connection();
3325 3325
 			$sth = $Connection->db->prepare($query);
3326 3326
                         $sth->execute();
3327
-                } catch(PDOException $e) {
3327
+                } catch (PDOException $e) {
3328 3328
                         return "error : ".$e->getMessage();
3329 3329
                 }
3330 3330
 	}
@@ -3340,7 +3340,7 @@  discard block
 block discarded – undo
3340 3340
 			$Connection = new Connection();
3341 3341
 			$sth = $Connection->db->prepare($query);
3342 3342
                         $sth->execute();
3343
-                } catch(PDOException $e) {
3343
+                } catch (PDOException $e) {
3344 3344
                         return "error : ".$e->getMessage();
3345 3345
                 }
3346 3346
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3355,7 +3355,7 @@  discard block
 block discarded – undo
3355 3355
 			$Connection = new Connection();
3356 3356
 			$sth = $Connection->db->prepare($query);
3357 3357
                         $sth->execute();
3358
-                } catch(PDOException $e) {
3358
+                } catch (PDOException $e) {
3359 3359
                         return "error : ".$e->getMessage();
3360 3360
                 }
3361 3361
 	}
@@ -3371,7 +3371,7 @@  discard block
 block discarded – undo
3371 3371
 			$Connection = new Connection();
3372 3372
 			$sth = $Connection->db->prepare($query);
3373 3373
 			$sth->execute();
3374
-		} catch(PDOException $e) {
3374
+		} catch (PDOException $e) {
3375 3375
 			return "error : ".$e->getMessage();
3376 3376
 		}
3377 3377
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3386,7 +3386,7 @@  discard block
 block discarded – undo
3386 3386
 			$Connection = new Connection();
3387 3387
 			$sth = $Connection->db->prepare($query);
3388 3388
 			$sth->execute();
3389
-		} catch(PDOException $e) {
3389
+		} catch (PDOException $e) {
3390 3390
 			return "error : ".$e->getMessage();
3391 3391
 		}
3392 3392
 	}
@@ -3402,7 +3402,7 @@  discard block
 block discarded – undo
3402 3402
 			$Connection = new Connection();
3403 3403
 			$sth = $Connection->db->prepare($query);
3404 3404
 			$sth->execute();
3405
-		} catch(PDOException $e) {
3405
+		} catch (PDOException $e) {
3406 3406
 			return "error : ".$e->getMessage();
3407 3407
 		}
3408 3408
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3417,7 +3417,7 @@  discard block
 block discarded – undo
3417 3417
 			$Connection = new Connection();
3418 3418
 			$sth = $Connection->db->prepare($query);
3419 3419
 			$sth->execute();
3420
-		} catch(PDOException $e) {
3420
+		} catch (PDOException $e) {
3421 3421
 			return "error : ".$e->getMessage();
3422 3422
 		}
3423 3423
 	}
@@ -3433,7 +3433,7 @@  discard block
 block discarded – undo
3433 3433
 			$Connection = new Connection();
3434 3434
 			$sth = $Connection->db->prepare($query);
3435 3435
 			$sth->execute();
3436
-		} catch(PDOException $e) {
3436
+		} catch (PDOException $e) {
3437 3437
 			return "error : ".$e->getMessage();
3438 3438
 		}
3439 3439
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3448,7 +3448,7 @@  discard block
 block discarded – undo
3448 3448
 			$Connection = new Connection();
3449 3449
 			$sth = $Connection->db->prepare($query);
3450 3450
 			$sth->execute();
3451
-		} catch(PDOException $e) {
3451
+		} catch (PDOException $e) {
3452 3452
 			return "error : ".$e->getMessage();
3453 3453
 		}
3454 3454
 	}
@@ -3464,7 +3464,7 @@  discard block
 block discarded – undo
3464 3464
 			$Connection = new Connection();
3465 3465
 			$sth = $Connection->db->prepare($query);
3466 3466
                         $sth->execute();
3467
-                } catch(PDOException $e) {
3467
+                } catch (PDOException $e) {
3468 3468
                         return "error : ".$e->getMessage();
3469 3469
                 }
3470 3470
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3479,7 +3479,7 @@  discard block
 block discarded – undo
3479 3479
 			$Connection = new Connection();
3480 3480
 			$sth = $Connection->db->prepare($query);
3481 3481
 			$sth->execute();
3482
-		} catch(PDOException $e) {
3482
+		} catch (PDOException $e) {
3483 3483
 			return "error : ".$e->getMessage();
3484 3484
 		}
3485 3485
 	}
@@ -3495,7 +3495,7 @@  discard block
 block discarded – undo
3495 3495
 			$Connection = new Connection();
3496 3496
 			$sth = $Connection->db->prepare($query);
3497 3497
 			$sth->execute();
3498
-		} catch(PDOException $e) {
3498
+		} catch (PDOException $e) {
3499 3499
 			return "error : ".$e->getMessage();
3500 3500
 		}
3501 3501
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3510,7 +3510,7 @@  discard block
 block discarded – undo
3510 3510
 			$Connection = new Connection();
3511 3511
 			$sth = $Connection->db->prepare($query);
3512 3512
 			$sth->execute();
3513
-		} catch(PDOException $e) {
3513
+		} catch (PDOException $e) {
3514 3514
 			return "error : ".$e->getMessage();
3515 3515
 		}
3516 3516
 	}
@@ -3526,7 +3526,7 @@  discard block
 block discarded – undo
3526 3526
 			$Connection = new Connection();
3527 3527
 			$sth = $Connection->db->prepare($query);
3528 3528
 			$sth->execute();
3529
-		} catch(PDOException $e) {
3529
+		} catch (PDOException $e) {
3530 3530
 			return "error : ".$e->getMessage();
3531 3531
 		}
3532 3532
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3541,7 +3541,7 @@  discard block
 block discarded – undo
3541 3541
 			$Connection = new Connection();
3542 3542
 			$sth = $Connection->db->prepare($query);
3543 3543
 			$sth->execute();
3544
-		} catch(PDOException $e) {
3544
+		} catch (PDOException $e) {
3545 3545
 			return "error : ".$e->getMessage();
3546 3546
 		}
3547 3547
 	}
@@ -3557,7 +3557,7 @@  discard block
 block discarded – undo
3557 3557
 			$Connection = new Connection();
3558 3558
 			$sth = $Connection->db->prepare($query);
3559 3559
 			$sth->execute();
3560
-		} catch(PDOException $e) {
3560
+		} catch (PDOException $e) {
3561 3561
 			return "error : ".$e->getMessage();
3562 3562
 		}
3563 3563
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3572,7 +3572,7 @@  discard block
 block discarded – undo
3572 3572
 			$Connection = new Connection();
3573 3573
 			$sth = $Connection->db->prepare($query);
3574 3574
 			$sth->execute();
3575
-		} catch(PDOException $e) {
3575
+		} catch (PDOException $e) {
3576 3576
 			return "error : ".$e->getMessage();
3577 3577
 		}
3578 3578
 	}
@@ -3588,7 +3588,7 @@  discard block
 block discarded – undo
3588 3588
 			$Connection = new Connection();
3589 3589
 			$sth = $Connection->db->prepare($query);
3590 3590
 			$sth->execute();
3591
-		} catch(PDOException $e) {
3591
+		} catch (PDOException $e) {
3592 3592
 			return "error : ".$e->getMessage();
3593 3593
 		}
3594 3594
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3607,7 +3607,7 @@  discard block
 block discarded – undo
3607 3607
 			$Connection = new Connection();
3608 3608
 			$sth = $Connection->db->prepare($query);
3609 3609
 			$sth->execute();
3610
-		} catch(PDOException $e) {
3610
+		} catch (PDOException $e) {
3611 3611
 			return "error : ".$e->getMessage();
3612 3612
 		}
3613 3613
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -3622,7 +3622,7 @@  discard block
 block discarded – undo
3622 3622
 			$Connection = new Connection();
3623 3623
 			$sth = $Connection->db->prepare($query);
3624 3624
 			$sth->execute();
3625
-		} catch(PDOException $e) {
3625
+		} catch (PDOException $e) {
3626 3626
 			return "error : ".$e->getMessage();
3627 3627
 		}
3628 3628
 	}
@@ -3634,7 +3634,7 @@  discard block
 block discarded – undo
3634 3634
 			$Connection = new Connection();
3635 3635
 			$sth = $Connection->db->prepare($query);
3636 3636
 			$sth->execute();
3637
-		} catch(PDOException $e) {
3637
+		} catch (PDOException $e) {
3638 3638
 			return "error : ".$e->getMessage();
3639 3639
 		}
3640 3640
 	}
@@ -3650,7 +3650,7 @@  discard block
 block discarded – undo
3650 3650
 			$Connection = new Connection();
3651 3651
 			$sth = $Connection->db->prepare($query);
3652 3652
                         $sth->execute();
3653
-                } catch(PDOException $e) {
3653
+                } catch (PDOException $e) {
3654 3654
                         return "error : ".$e->getMessage();
3655 3655
                 }
3656 3656
 	}
@@ -3665,7 +3665,7 @@  discard block
 block discarded – undo
3665 3665
 			$Connection = new Connection();
3666 3666
 			$sth = $Connection->db->prepare($query);
3667 3667
                         $sth->execute();
3668
-                } catch(PDOException $e) {
3668
+                } catch (PDOException $e) {
3669 3669
                         return "error : ".$e->getMessage();
3670 3670
                 }
3671 3671
 	}
Please login to merge, or discard this patch.