Code Duplication    Length = 16-27 lines in 6 locations

install/class.update_db.php 6 locations

@@ 1194-1209 (lines=16) @@
1191
		return '';
1192
	}
1193
1194
	public static function update_routes() {
1195
		global $tmp_dir, $globalDebug;
1196
		$error = '';
1197
		if ($globalDebug) echo "Routes : Download...";
1198
		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1199
		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1200
			if ($globalDebug) echo "Gunzip...";
1201
			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
1202
			if ($globalDebug) echo "Add to DB...";
1203
			$error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb');
1204
		} else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed.";
1205
		if ($error != '') {
1206
			return $error;
1207
		} elseif ($globalDebug) echo "Done\n";
1208
		return '';
1209
	}
1210
	public static function update_oneworld() {
1211
		global $tmp_dir, $globalDebug;
1212
		$error = '';
@@ 1210-1225 (lines=16) @@
1207
		} elseif ($globalDebug) echo "Done\n";
1208
		return '';
1209
	}
1210
	public static function update_oneworld() {
1211
		global $tmp_dir, $globalDebug;
1212
		$error = '';
1213
		if ($globalDebug) echo "Schedules Oneworld : Download...";
1214
		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1215
		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1216
			if ($globalDebug) echo "Gunzip...";
1217
			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
1218
			if ($globalDebug) echo "Add to DB...";
1219
			$error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv');
1220
		} else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed.";
1221
		if ($error != '') {
1222
			return $error;
1223
		} elseif ($globalDebug) echo "Done\n";
1224
		return '';
1225
	}
1226
	public static function update_skyteam() {
1227
		global $tmp_dir, $globalDebug;
1228
		$error = '';
@@ 1226-1241 (lines=16) @@
1223
		} elseif ($globalDebug) echo "Done\n";
1224
		return '';
1225
	}
1226
	public static function update_skyteam() {
1227
		global $tmp_dir, $globalDebug;
1228
		$error = '';
1229
		if ($globalDebug) echo "Schedules Skyteam : Download...";
1230
		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1231
		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1232
			if ($globalDebug) echo "Gunzip...";
1233
			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
1234
			if ($globalDebug) echo "Add to DB...";
1235
			$error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv');
1236
		} else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed.";
1237
		if ($error != '') {
1238
			return $error;
1239
		} elseif ($globalDebug) echo "Done\n";
1240
		return '';
1241
	}
1242
	public static function update_ModeS() {
1243
		global $tmp_dir, $globalDebug;
1244
/*
@@ 1242-1268 (lines=27) @@
1239
		} elseif ($globalDebug) echo "Done\n";
1240
		return '';
1241
	}
1242
	public static function update_ModeS() {
1243
		global $tmp_dir, $globalDebug;
1244
/*
1245
		if ($globalDebug) echo "Modes : Download...";
1246
		update_db::download('http://pp-sqb.mantma.co.uk/basestation_latest.zip',$tmp_dir.'basestation_latest.zip');
1247
		if ($globalDebug) echo "Unzip...";
1248
		update_db::unzip($tmp_dir.'basestation_latest.zip');
1249
		if ($globalDebug) echo "Add to DB...";
1250
		$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'/basestation_latest/basestation.sqb');
1251
		if ($error != true) {
1252
			echo $error;
1253
			exit;
1254
		} elseif ($globalDebug) echo "Done\n";
1255
*/
1256
		if ($globalDebug) echo "Modes : Download...";
1257
		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1258
		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1259
			if ($globalDebug) echo "Unzip...";
1260
			update_db::unzip($tmp_dir.'basestation_latest.zip');
1261
			if ($globalDebug) echo "Add to DB...";
1262
			$error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb');
1263
		} else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed.";
1264
		if ($error != '') {
1265
			return $error;
1266
		} elseif ($globalDebug) echo "Done\n";
1267
		return '';
1268
	}
1269
1270
	public static function update_ModeS_flarm() {
1271
		global $tmp_dir, $globalDebug;
@@ 1476-1491 (lines=16) @@
1473
		return '';
1474
	}
1475
1476
	public static function update_translation() {
1477
		global $tmp_dir, $globalDebug;
1478
		$error = '';
1479
		if ($globalDebug) echo "Translation : Download...";
1480
		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1481
		if (file_exists($tmp_dir.'translation.zip')) {
1482
			if ($globalDebug) echo "Unzip...";
1483
			update_db::unzip($tmp_dir.'translation.zip');
1484
			if ($globalDebug) echo "Add to DB...";
1485
			$error = update_db::translation();
1486
		} else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed.";
1487
		if ($error != '') {
1488
			return $error;
1489
		} elseif ($globalDebug) echo "Done\n";
1490
		return '';
1491
	}
1492
1493
	public static function update_translation_fam() {
1494
		global $tmp_dir, $globalDebug;
@@ 1493-1508 (lines=16) @@
1490
		return '';
1491
	}
1492
1493
	public static function update_translation_fam() {
1494
		global $tmp_dir, $globalDebug;
1495
		$error = '';
1496
		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1497
		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1498
		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1499
			if ($globalDebug) echo "Gunzip...";
1500
			update_db::gunzip($tmp_dir.'translation.tsv.gz');
1501
			if ($globalDebug) echo "Add to DB...";
1502
			$error = update_db::translation_fam();
1503
		} else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed.";
1504
		if ($error != '') {
1505
			return $error;
1506
		} elseif ($globalDebug) echo "Done\n";
1507
		return '';
1508
	}
1509
1510
	public static function update_models() {
1511
		global $tmp_dir, $globalDebug;