Completed
Push — master ( 98152f...ecdb7d )
by Yannick
32:15
created
install/index.php 1 patch
Spacing   +248 added lines, -248 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 require_once(dirname(__FILE__).'/class.create_db.php');
12 12
 require_once(dirname(__FILE__).'/class.update_schema.php');
13 13
 require_once(dirname(__FILE__).'/class.settings.php');
14
-$title="Install";
14
+$title = "Install";
15 15
 require(dirname(__FILE__).'/../require/settings.php');
16 16
 require(dirname(__FILE__).'/../require/class.Common.php');
17 17
 require(dirname(__FILE__).'/header.php');
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
 	if (!extension_loaded('curl')) {
81 81
 		$error[] = "Curl is not loaded.";
82 82
 	}
83
-	if(function_exists('apache_get_modules') ){
84
-		if(!in_array('mod_rewrite',apache_get_modules())) {
83
+	if (function_exists('apache_get_modules')) {
84
+		if (!in_array('mod_rewrite', apache_get_modules())) {
85 85
 			$error[] = "mod_rewrite is not available.";
86 86
 		}
87 87
 	/*
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 	print '<div class="info column"><p><strong>If you use MySQL or MariaDB, check that <i>max_allowed_packet</i> >= 8M, else import of some table can fail.</strong></p></div>';
98 98
 	if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) {
99 99
 		if (function_exists('get_headers')) {
100
-			$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/','search',str_replace('index.php',$_SERVER["REQUEST_URI"])));
101
-			if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
100
+			$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/', 'search', str_replace('index.php', $_SERVER["REQUEST_URI"])));
101
+			if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
102 102
 				print '<div class="info column"><p><strong>Check your configuration, rewrite don\'t seems to work.</strong></p></div>';
103 103
 			}
104 104
 		}
@@ -469,13 +469,13 @@  discard block
 block discarded – undo
469 469
 ?>
470 470
 							<tr>
471 471
 								<?php
472
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
472
+								    if (filter_var($source['host'], FILTER_VALIDATE_URL)) {
473 473
 								?>
474 474
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
475 475
 								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
476 476
 								<?php
477 477
 								    } else {
478
-									$hostport = explode(':',$source['host']);
478
+									$hostport = explode(':', $source['host']);
479 479
 									if (isset($hostport[1])) {
480 480
 										$host = $hostport[0];
481 481
 										$port = $hostport[1];
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 									<select name="timezones[]" id="timezones">
523 523
 								<?php
524 524
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
525
-									foreach($timezonelist as $timezones){
525
+									foreach ($timezonelist as $timezones) {
526 526
 										if (isset($source['timezone']) && $source['timezone'] == $timezones) {
527 527
 											print '<option selected>'.$timezones.'</option>';
528 528
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 									<select name="timezones[]" id="timezones">
575 575
 								<?php
576 576
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
577
-									foreach($timezonelist as $timezones){
577
+									foreach ($timezonelist as $timezones) {
578 578
 										if ($timezones == 'UTC') {
579 579
 											print '<option selected>'.$timezones.'</option>';
580 580
 										} else print '<option>'.$timezones.'</option>';
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 			<br />
897 897
 			<p>
898 898
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
899
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
899
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" />
900 900
 			</p>
901 901
 			<br />
902 902
 			<p>
@@ -952,14 +952,14 @@  discard block
 block discarded – undo
952 952
 $error = '';
953 953
 
954 954
 if (isset($_POST['dbtype'])) {
955
-	$dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING);
956
-	$dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING);
957
-	$dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING);
958
-	$dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING);
959
-	$dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING);
960
-	$dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING);
961
-	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
962
-	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
955
+	$dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING);
956
+	$dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING);
957
+	$dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING);
958
+	$dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING);
959
+	$dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING);
960
+	$dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING);
961
+	$dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING);
962
+	$dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING);
963 963
 
964 964
 	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
965 965
 	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
@@ -979,49 +979,49 @@  discard block
 block discarded – undo
979 979
 	} else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
980 980
 	*/
981 981
 	
982
-	$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
982
+	$settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname));
983 983
 
984
-	$sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING);
985
-	$siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING);
986
-	$timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING);
987
-	$language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING);
988
-	$settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language));
984
+	$sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING);
985
+	$siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING);
986
+	$timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING);
987
+	$language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
988
+	$settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language));
989 989
 
990
-	$mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING);
991
-	$mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING);
992
-	$mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING);
993
-	$googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING);
994
-	$bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING);
995
-	$openweathermapkey = filter_input(INPUT_POST,'openweathermapkey',FILTER_SANITIZE_STRING);
996
-	$mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING);
997
-	$hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING);
998
-	$hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING);
999
-	$settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey,'globalOpenWeatherMapKey' => $openweathermapkey));
990
+	$mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING);
991
+	$mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING);
992
+	$mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING);
993
+	$googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING);
994
+	$bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING);
995
+	$openweathermapkey = filter_input(INPUT_POST, 'openweathermapkey', FILTER_SANITIZE_STRING);
996
+	$mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING);
997
+	$hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING);
998
+	$hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING);
999
+	$settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey, 'globalOpenWeatherMapKey' => $openweathermapkey));
1000 1000
 	
1001
-	$latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING);
1002
-	$latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING);
1003
-	$longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING);
1004
-	$longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING);
1005
-	$livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT);
1006
-	$settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom));
1001
+	$latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING);
1002
+	$latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING);
1003
+	$longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING);
1004
+	$longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING);
1005
+	$livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT);
1006
+	$settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom));
1007 1007
 
1008
-	$squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING);
1009
-	$settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country));
1008
+	$squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING);
1009
+	$settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country));
1010 1010
 
1011
-	$latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING);
1012
-	$longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING);
1013
-	$settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter));
1011
+	$latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING);
1012
+	$longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING);
1013
+	$settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter));
1014 1014
 
1015
-	$acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING);
1015
+	$acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING);
1016 1016
 	if ($acars == 'acars') {
1017
-		$settings = array_merge($settings,array('globalACARS' => 'TRUE'));
1017
+		$settings = array_merge($settings, array('globalACARS' => 'TRUE'));
1018 1018
 	} else {
1019
-		$settings = array_merge($settings,array('globalACARS' => 'FALSE'));
1019
+		$settings = array_merge($settings, array('globalACARS' => 'FALSE'));
1020 1020
 	}
1021 1021
 
1022
-	$flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING);
1023
-	$flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING);
1024
-	$settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword));
1022
+	$flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING);
1023
+	$flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING);
1024
+	$settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword));
1025 1025
 	
1026 1026
 	$source_name = $_POST['source_name'];
1027 1027
 	$source_latitude = $_POST['source_latitude'];
@@ -1035,8 +1035,8 @@  discard block
 block discarded – undo
1035 1035
 	
1036 1036
 	$sources = array();
1037 1037
 	foreach ($source_name as $keys => $name) {
1038
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1039
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1038
+	    if (isset($source_id[$keys])) $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'id' => $source_id[$keys], 'source' => $source_ref[$keys]);
1039
+	    else $sources[] = array('name' => $name, 'latitude' => $source_latitude[$keys], 'longitude' => $source_longitude[$keys], 'altitude' => $source_altitude[$keys], 'city' => $source_city[$keys], 'country' => $source_country[$keys], 'source' => $source_ref[$keys]);
1040 1040
 	}
1041 1041
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1042 1042
 
@@ -1049,27 +1049,27 @@  discard block
 block discarded – undo
1049 1049
 	$sbsurl = $_POST['sbsurl'];
1050 1050
 	*/
1051 1051
 
1052
-	$globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING);
1053
-	$globalva = filter_input(INPUT_POST,'globalva',FILTER_SANITIZE_STRING);
1054
-	$globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING);
1055
-	$globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING);
1056
-	$globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING);
1057
-	$globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING);
1058
-	$globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING);
1059
-	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1052
+	$globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING);
1053
+	$globalva = filter_input(INPUT_POST, 'globalva', FILTER_SANITIZE_STRING);
1054
+	$globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING);
1055
+	$globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING);
1056
+	$globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING);
1057
+	$globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING);
1058
+	$globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING);
1059
+	$datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING);
1060 1060
 
1061
-	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1062
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1063
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1064
-	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1065
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1066
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1067
-	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1068
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1069
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1070
-	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1071
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1072
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1061
+	$globalaircraft = filter_input(INPUT_POST, 'globalaircraft', FILTER_SANITIZE_STRING);
1062
+	if ($globalaircraft == 'aircraft') $settings = array_merge($settings, array('globalAircraft' => 'TRUE'));
1063
+	else $settings = array_merge($settings, array('globalAircraft' => 'FALSE'));
1064
+	$globaltracker = filter_input(INPUT_POST, 'globaltracker', FILTER_SANITIZE_STRING);
1065
+	if ($globaltracker == 'tracker') $settings = array_merge($settings, array('globalTracker' => 'TRUE'));
1066
+	else $settings = array_merge($settings, array('globalTracker' => 'FALSE'));
1067
+	$globalmarine = filter_input(INPUT_POST, 'globalmarine', FILTER_SANITIZE_STRING);
1068
+	if ($globalmarine == 'marine') $settings = array_merge($settings, array('globalMarine' => 'TRUE'));
1069
+	else $settings = array_merge($settings, array('globalMarine' => 'FALSE'));
1070
+	$globalsatellite = filter_input(INPUT_POST, 'globalsatellite', FILTER_SANITIZE_STRING);
1071
+	if ($globalsatellite == 'satellite') $settings = array_merge($settings, array('globalSatellite' => 'TRUE'));
1072
+	else $settings = array_merge($settings, array('globalSatellite' => 'FALSE'));
1073 1073
 
1074 1074
 /*	
1075 1075
 	$globalSBS1Hosts = array();
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
 	}
1086 1086
 	$settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts));
1087 1087
 */
1088
-	$settings_comment = array_merge($settings_comment,array('globalSBS1Hosts'));
1088
+	$settings_comment = array_merge($settings_comment, array('globalSBS1Hosts'));
1089 1089
 	$host = $_POST['host'];
1090 1090
 	$port = $_POST['port'];
1091 1091
 	$name = $_POST['name'];
@@ -1102,107 +1102,107 @@  discard block
 block discarded – undo
1102 1102
 		else $cov = 'FALSE';
1103 1103
 		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1104 1104
 		else $arch = 'FALSE';
1105
-		if (strpos($format[$key],'_callback')) {
1106
-			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1105
+		if (strpos($format[$key], '_callback')) {
1106
+			$gSources[] = array('host' => $h, 'pass' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezones[$key], 'callback' => 'TRUE');
1107 1107
 		} elseif ($h != '' || $name[$key] != '') {
1108
-			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1108
+			$gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezones[$key], 'callback' => 'FALSE');
1109 1109
 		}
1110 1110
 		if ($format[$key] == 'airwhere') $forcepilots = true;
1111 1111
 	}
1112
-	$settings = array_merge($settings,array('globalSources' => $gSources));
1112
+	$settings = array_merge($settings, array('globalSources' => $gSources));
1113 1113
 
1114 1114
 /*
1115 1115
 	$sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT);
1116 1116
 	$settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout));
1117 1117
 */
1118
-	$acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING);
1119
-	$acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT);
1120
-	$settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport));
1118
+	$acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING);
1119
+	$acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT);
1120
+	$settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport));
1121 1121
 
1122
-	$bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING);
1123
-	$settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly));
1122
+	$bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING);
1123
+	$settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly));
1124 1124
 
1125
-	$customcss = filter_input(INPUT_POST,'customcss',FILTER_SANITIZE_STRING);
1126
-	$settings = array_merge($settings,array('globalCustomCSS' => $customcss));
1125
+	$customcss = filter_input(INPUT_POST, 'customcss', FILTER_SANITIZE_STRING);
1126
+	$settings = array_merge($settings, array('globalCustomCSS' => $customcss));
1127 1127
 
1128
-	$map3dtile = filter_input(INPUT_POST,'map3dtileset',FILTER_SANITIZE_STRING);
1129
-	$settings = array_merge($settings,array('globalMap3DTiles' => $map3dtile));
1128
+	$map3dtile = filter_input(INPUT_POST, 'map3dtileset', FILTER_SANITIZE_STRING);
1129
+	$settings = array_merge($settings, array('globalMap3DTiles' => $map3dtile));
1130 1130
 
1131
-	$notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING);
1132
-	$settings = array_merge($settings,array('globalNOTAMSource' => $notamsource));
1133
-	$metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING);
1134
-	$settings = array_merge($settings,array('globalMETARurl' => $metarsource));
1131
+	$notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING);
1132
+	$settings = array_merge($settings, array('globalNOTAMSource' => $notamsource));
1133
+	$metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING);
1134
+	$settings = array_merge($settings, array('globalMETARurl' => $metarsource));
1135 1135
 
1136
-	$zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING);
1137
-	$zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING);
1138
-	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1136
+	$zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING);
1137
+	$zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING);
1138
+	$zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT);
1139 1139
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1140
-		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1141
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1140
+		$settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance)));
1141
+	} else $settings = array_merge($settings, array('globalDistanceIgnore' => array()));
1142 1142
 
1143
-	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1144
-	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
1145
-	$maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT);
1146
-	$settings = array_merge($settings,array('globalMapRefresh' => $maprefresh));
1147
-	$mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT);
1148
-	$settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle));
1149
-	$closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT);
1150
-	$settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist));
1143
+	$refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT);
1144
+	$settings = array_merge($settings, array('globalLiveInterval' => $refresh));
1145
+	$maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT);
1146
+	$settings = array_merge($settings, array('globalMapRefresh' => $maprefresh));
1147
+	$mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT);
1148
+	$settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle));
1149
+	$closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT);
1150
+	$settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist));
1151 1151
 
1152
-	$aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT);
1153
-	$settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize));
1152
+	$aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT);
1153
+	$settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize));
1154 1154
 
1155
-	$archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT);
1156
-	$settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths));
1155
+	$archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT);
1156
+	$settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths));
1157 1157
 	
1158
-	$archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING);
1158
+	$archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING);
1159 1159
 	if ($archiveyear == "archiveyear") {
1160
-		$settings = array_merge($settings,array('globalArchiveYear' => 'TRUE'));
1160
+		$settings = array_merge($settings, array('globalArchiveYear' => 'TRUE'));
1161 1161
 	} else {
1162
-		$settings = array_merge($settings,array('globalArchiveYear' => 'FALSE'));
1162
+		$settings = array_merge($settings, array('globalArchiveYear' => 'FALSE'));
1163 1163
 	}
1164
-	$archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT);
1165
-	$settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths));
1166
-	$archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT);
1167
-	$settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1164
+	$archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT);
1165
+	$settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths));
1166
+	$archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT);
1167
+	$settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1168 1168
 
1169
-	$britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING);
1170
-	$settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways));
1171
-	$transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING);
1172
-	$settings = array_merge($settings,array('globalTransaviaKey' => $transavia));
1169
+	$britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING);
1170
+	$settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways));
1171
+	$transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING);
1172
+	$settings = array_merge($settings, array('globalTransaviaKey' => $transavia));
1173 1173
 
1174
-	$lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING);
1175
-	$lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING);
1176
-	$settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret)));
1174
+	$lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING);
1175
+	$lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING);
1176
+	$settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret)));
1177 1177
 
1178 1178
 	// Create in settings.php keys not yet configurable if not already here
1179 1179
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1180
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1180
+	if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE'));
1181 1181
 
1182
-	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1182
+	$resetyearstats = filter_input(INPUT_POST, 'resetyearstats', FILTER_SANITIZE_STRING);
1183 1183
 	if ($resetyearstats == 'resetyearstats') {
1184
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'TRUE'));
1184
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'TRUE'));
1185 1185
 	} else {
1186
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'FALSE'));
1186
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'FALSE'));
1187 1187
 	}
1188 1188
 
1189
-	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
1189
+	$archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING);
1190 1190
 	if ($archive == 'archive') {
1191
-		$settings = array_merge($settings,array('globalArchive' => 'TRUE'));
1191
+		$settings = array_merge($settings, array('globalArchive' => 'TRUE'));
1192 1192
 	} else {
1193
-		$settings = array_merge($settings,array('globalArchive' => 'FALSE'));
1193
+		$settings = array_merge($settings, array('globalArchive' => 'FALSE'));
1194 1194
 	}
1195
-	$daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING);
1195
+	$daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING);
1196 1196
 	if ($daemon == 'daemon') {
1197
-		$settings = array_merge($settings,array('globalDaemon' => 'TRUE'));
1197
+		$settings = array_merge($settings, array('globalDaemon' => 'TRUE'));
1198 1198
 	} else {
1199
-		$settings = array_merge($settings,array('globalDaemon' => 'FALSE'));
1199
+		$settings = array_merge($settings, array('globalDaemon' => 'FALSE'));
1200 1200
 	}
1201
-	$schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING);
1201
+	$schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING);
1202 1202
 	if ($schedules == 'schedules') {
1203
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE'));
1203
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE'));
1204 1204
 	} else {
1205
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE'));
1205
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE'));
1206 1206
 	}
1207 1207
 
1208 1208
 /*
@@ -1213,227 +1213,227 @@  discard block
 block discarded – undo
1213 1213
 		$settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE'));
1214 1214
 	}
1215 1215
 */
1216
-	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1217
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1218
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1219
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1220
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1216
+	$settings = array_merge($settings, array('globalFlightAware' => 'FALSE'));
1217
+	if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE'));
1218
+	else $settings = array_merge($settings, array('globalSBS1' => 'FALSE'));
1219
+	if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE'));
1220
+	else $settings = array_merge($settings, array('globalAPRS' => 'FALSE'));
1221 1221
 	$va = false;
1222 1222
 	if ($globalivao == 'ivao') {
1223
-		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1223
+		$settings = array_merge($settings, array('globalIVAO' => 'TRUE'));
1224 1224
 		$va = true;
1225
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1225
+	} else $settings = array_merge($settings, array('globalIVAO' => 'FALSE'));
1226 1226
 	if ($globalvatsim == 'vatsim') {
1227
-		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1227
+		$settings = array_merge($settings, array('globalVATSIM' => 'TRUE'));
1228 1228
 		$va = true;
1229
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1229
+	} else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE'));
1230 1230
 	if ($globalphpvms == 'phpvms') {
1231
-		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1231
+		$settings = array_merge($settings, array('globalphpVMS' => 'TRUE'));
1232 1232
 		$va = true;
1233
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1233
+	} else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE'));
1234 1234
 	if ($globalvam == 'vam') {
1235
-		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1235
+		$settings = array_merge($settings, array('globalVAM' => 'TRUE'));
1236 1236
 		$va = true;
1237
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1237
+	} else $settings = array_merge($settings, array('globalVAM' => 'FALSE'));
1238 1238
 	if ($va) {
1239
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1240
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1239
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE'));
1240
+	} else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE'));
1241 1241
 	if ($globalva == 'va' || $va) {
1242
-		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1243
-		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1242
+		$settings = array_merge($settings, array('globalVA' => 'TRUE'));
1243
+		$settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1244 1244
 	} else {
1245
-		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1246
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1247
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1245
+		$settings = array_merge($settings, array('globalVA' => 'FALSE'));
1246
+		if ($forcepilots) $settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1247
+		else $settings = array_merge($settings, array('globalUsePilot' => 'FALSE', 'globalUseOwner' => 'TRUE'));
1248 1248
 	}
1249 1249
 	
1250 1250
 	
1251 1251
 
1252
-	$notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING);
1252
+	$notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING);
1253 1253
 	if ($notam == 'notam') {
1254
-		$settings = array_merge($settings,array('globalNOTAM' => 'TRUE'));
1254
+		$settings = array_merge($settings, array('globalNOTAM' => 'TRUE'));
1255 1255
 	} else {
1256
-		$settings = array_merge($settings,array('globalNOTAM' => 'FALSE'));
1256
+		$settings = array_merge($settings, array('globalNOTAM' => 'FALSE'));
1257 1257
 	}
1258
-	$owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING);
1258
+	$owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING);
1259 1259
 	if ($owner == 'owner') {
1260
-		$settings = array_merge($settings,array('globalOwner' => 'TRUE'));
1260
+		$settings = array_merge($settings, array('globalOwner' => 'TRUE'));
1261 1261
 	} else {
1262
-		$settings = array_merge($settings,array('globalOwner' => 'FALSE'));
1262
+		$settings = array_merge($settings, array('globalOwner' => 'FALSE'));
1263 1263
 	}
1264
-	$map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING);
1264
+	$map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING);
1265 1265
 	if ($map3d == 'map3d') {
1266
-		$settings = array_merge($settings,array('globalMap3D' => 'TRUE'));
1266
+		$settings = array_merge($settings, array('globalMap3D' => 'TRUE'));
1267 1267
 	} else {
1268
-		$settings = array_merge($settings,array('globalMap3D' => 'FALSE'));
1268
+		$settings = array_merge($settings, array('globalMap3D' => 'FALSE'));
1269 1269
 	}
1270
-	$crash = filter_input(INPUT_POST,'crash',FILTER_SANITIZE_STRING);
1270
+	$crash = filter_input(INPUT_POST, 'crash', FILTER_SANITIZE_STRING);
1271 1271
 	if ($crash == 'crash') {
1272
-		$settings = array_merge($settings,array('globalAccidents' => 'TRUE'));
1272
+		$settings = array_merge($settings, array('globalAccidents' => 'TRUE'));
1273 1273
 	} else {
1274
-		$settings = array_merge($settings,array('globalAccidents' => 'FALSE'));
1274
+		$settings = array_merge($settings, array('globalAccidents' => 'FALSE'));
1275 1275
 	}
1276
-	$mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING);
1276
+	$mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING);
1277 1277
 	if ($mapsatellites == 'mapsatellites') {
1278
-		$settings = array_merge($settings,array('globalMapSatellites' => 'TRUE'));
1278
+		$settings = array_merge($settings, array('globalMapSatellites' => 'TRUE'));
1279 1279
 	} else {
1280
-		$settings = array_merge($settings,array('globalMapSatellites' => 'FALSE'));
1280
+		$settings = array_merge($settings, array('globalMapSatellites' => 'FALSE'));
1281 1281
 	}
1282
-	$map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING);
1282
+	$map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING);
1283 1283
 	if ($map3ddefault == 'map3ddefault') {
1284
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE'));
1284
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE'));
1285 1285
 	} else {
1286
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE'));
1286
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE'));
1287 1287
 	}
1288
-	$translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING);
1288
+	$translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING);
1289 1289
 	if ($translate == 'translate') {
1290
-		$settings = array_merge($settings,array('globalTranslate' => 'TRUE'));
1290
+		$settings = array_merge($settings, array('globalTranslate' => 'TRUE'));
1291 1291
 	} else {
1292
-		$settings = array_merge($settings,array('globalTranslate' => 'FALSE'));
1292
+		$settings = array_merge($settings, array('globalTranslate' => 'FALSE'));
1293 1293
 	}
1294
-	$realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING);
1294
+	$realairlines = filter_input(INPUT_POST, 'realairlines', FILTER_SANITIZE_STRING);
1295 1295
 	if ($realairlines == 'realairlines') {
1296
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE'));
1296
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'TRUE'));
1297 1297
 	} else {
1298
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE'));
1298
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'FALSE'));
1299 1299
 	}
1300
-	$estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING);
1300
+	$estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING);
1301 1301
 	if ($estimation == 'estimation') {
1302
-		$settings = array_merge($settings,array('globalMapEstimation' => 'TRUE'));
1302
+		$settings = array_merge($settings, array('globalMapEstimation' => 'TRUE'));
1303 1303
 	} else {
1304
-		$settings = array_merge($settings,array('globalMapEstimation' => 'FALSE'));
1304
+		$settings = array_merge($settings, array('globalMapEstimation' => 'FALSE'));
1305 1305
 	}
1306
-	$metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING);
1306
+	$metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING);
1307 1307
 	if ($metar == 'metar') {
1308
-		$settings = array_merge($settings,array('globalMETAR' => 'TRUE'));
1308
+		$settings = array_merge($settings, array('globalMETAR' => 'TRUE'));
1309 1309
 	} else {
1310
-		$settings = array_merge($settings,array('globalMETAR' => 'FALSE'));
1310
+		$settings = array_merge($settings, array('globalMETAR' => 'FALSE'));
1311 1311
 	}
1312
-	$metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING);
1312
+	$metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING);
1313 1313
 	if ($metarcycle == 'metarcycle') {
1314
-		$settings = array_merge($settings,array('globalMETARcycle' => 'TRUE'));
1314
+		$settings = array_merge($settings, array('globalMETARcycle' => 'TRUE'));
1315 1315
 	} else {
1316
-		$settings = array_merge($settings,array('globalMETARcycle' => 'FALSE'));
1316
+		$settings = array_merge($settings, array('globalMETARcycle' => 'FALSE'));
1317 1317
 	}
1318
-	$fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING);
1318
+	$fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING);
1319 1319
 	if ($fork == 'fork') {
1320
-		$settings = array_merge($settings,array('globalFork' => 'TRUE'));
1320
+		$settings = array_merge($settings, array('globalFork' => 'TRUE'));
1321 1321
 	} else {
1322
-		$settings = array_merge($settings,array('globalFork' => 'FALSE'));
1322
+		$settings = array_merge($settings, array('globalFork' => 'FALSE'));
1323 1323
 	}
1324 1324
 
1325
-	$colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING);
1325
+	$colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING);
1326 1326
 	if ($colormap == 'colormap') {
1327
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE'));
1327
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE'));
1328 1328
 	} else {
1329
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE'));
1329
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE'));
1330 1330
 	}
1331 1331
 	
1332 1332
 	if (isset($_POST['aircrafticoncolor'])) {
1333
-		$aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING);
1334
-		$settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1)));
1333
+		$aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING);
1334
+		$settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1)));
1335 1335
 	}
1336 1336
 
1337
-	$airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT);
1338
-	$settings = array_merge($settings,array('globalAirportZoom' => $airportzoom));
1337
+	$airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT);
1338
+	$settings = array_merge($settings, array('globalAirportZoom' => $airportzoom));
1339 1339
 
1340
-	$unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING);
1341
-	$settings = array_merge($settings,array('globalUnitDistance' => $unitdistance));
1342
-	$unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING);
1343
-	$settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude));
1344
-	$unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING);
1345
-	$settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed));
1340
+	$unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING);
1341
+	$settings = array_merge($settings, array('globalUnitDistance' => $unitdistance));
1342
+	$unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING);
1343
+	$settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude));
1344
+	$unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING);
1345
+	$settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed));
1346 1346
 
1347
-	$mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING);
1347
+	$mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING);
1348 1348
 	if ($mappopup == 'mappopup') {
1349
-		$settings = array_merge($settings,array('globalMapPopup' => 'TRUE'));
1349
+		$settings = array_merge($settings, array('globalMapPopup' => 'TRUE'));
1350 1350
 	} else {
1351
-		$settings = array_merge($settings,array('globalMapPopup' => 'FALSE'));
1351
+		$settings = array_merge($settings, array('globalMapPopup' => 'FALSE'));
1352 1352
 	}
1353
-	$airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING);
1353
+	$airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING);
1354 1354
 	if ($airportpopup == 'airportpopup') {
1355
-		$settings = array_merge($settings,array('globalAirportPopup' => 'TRUE'));
1355
+		$settings = array_merge($settings, array('globalAirportPopup' => 'TRUE'));
1356 1356
 	} else {
1357
-		$settings = array_merge($settings,array('globalAirportPopup' => 'FALSE'));
1357
+		$settings = array_merge($settings, array('globalAirportPopup' => 'FALSE'));
1358 1358
 	}
1359
-	$maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING);
1359
+	$maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING);
1360 1360
 	if ($maphistory == 'maphistory') {
1361
-		$settings = array_merge($settings,array('globalMapHistory' => 'TRUE'));
1361
+		$settings = array_merge($settings, array('globalMapHistory' => 'TRUE'));
1362 1362
 	} else {
1363
-		$settings = array_merge($settings,array('globalMapHistory' => 'FALSE'));
1363
+		$settings = array_merge($settings, array('globalMapHistory' => 'FALSE'));
1364 1364
 	}
1365
-	$maptooltip = filter_input(INPUT_POST,'maptooltip',FILTER_SANITIZE_STRING);
1365
+	$maptooltip = filter_input(INPUT_POST, 'maptooltip', FILTER_SANITIZE_STRING);
1366 1366
 	if ($maptooltip == 'maptooltip') {
1367
-		$settings = array_merge($settings,array('globalMapTooltip' => 'TRUE'));
1367
+		$settings = array_merge($settings, array('globalMapTooltip' => 'TRUE'));
1368 1368
 	} else {
1369
-		$settings = array_merge($settings,array('globalMapTooltip' => 'FALSE'));
1369
+		$settings = array_merge($settings, array('globalMapTooltip' => 'FALSE'));
1370 1370
 	}
1371
-	$flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING);
1371
+	$flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING);
1372 1372
 	if ($flightroute == 'flightroute') {
1373
-		$settings = array_merge($settings,array('globalMapRoute' => 'TRUE'));
1373
+		$settings = array_merge($settings, array('globalMapRoute' => 'TRUE'));
1374 1374
 	} else {
1375
-		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1375
+		$settings = array_merge($settings, array('globalMapRoute' => 'FALSE'));
1376 1376
 	}
1377
-	$flightremainingroute = filter_input(INPUT_POST,'flightremainingroute',FILTER_SANITIZE_STRING);
1377
+	$flightremainingroute = filter_input(INPUT_POST, 'flightremainingroute', FILTER_SANITIZE_STRING);
1378 1378
 	if ($flightremainingroute == 'flightremainingroute') {
1379
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'TRUE'));
1379
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'TRUE'));
1380 1380
 	} else {
1381
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'FALSE'));
1381
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'FALSE'));
1382 1382
 	}
1383
-	$allflights = filter_input(INPUT_POST,'allflights',FILTER_SANITIZE_STRING);
1383
+	$allflights = filter_input(INPUT_POST, 'allflights', FILTER_SANITIZE_STRING);
1384 1384
 	if ($allflights == 'allflights') {
1385
-		$settings = array_merge($settings,array('globalAllFlights' => 'TRUE'));
1385
+		$settings = array_merge($settings, array('globalAllFlights' => 'TRUE'));
1386 1386
 	} else {
1387
-		$settings = array_merge($settings,array('globalAllFlights' => 'FALSE'));
1387
+		$settings = array_merge($settings, array('globalAllFlights' => 'FALSE'));
1388 1388
 	}
1389
-	$bbox = filter_input(INPUT_POST,'bbox',FILTER_SANITIZE_STRING);
1389
+	$bbox = filter_input(INPUT_POST, 'bbox', FILTER_SANITIZE_STRING);
1390 1390
 	if ($bbox == 'bbox') {
1391
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'TRUE'));
1391
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'TRUE'));
1392 1392
 	} else {
1393
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'FALSE'));
1393
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'FALSE'));
1394 1394
 	}
1395
-	$groundaltitude = filter_input(INPUT_POST,'groundaltitude',FILTER_SANITIZE_STRING);
1395
+	$groundaltitude = filter_input(INPUT_POST, 'groundaltitude', FILTER_SANITIZE_STRING);
1396 1396
 	if ($groundaltitude == 'groundaltitude') {
1397
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'TRUE'));
1397
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'TRUE'));
1398 1398
 	} else {
1399
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'FALSE'));
1399
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'FALSE'));
1400 1400
 	}
1401
-	$waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING);
1401
+	$waypoints = filter_input(INPUT_POST, 'waypoints', FILTER_SANITIZE_STRING);
1402 1402
 	if ($waypoints == 'waypoints') {
1403
-		$settings = array_merge($settings,array('globalWaypoints' => 'TRUE'));
1403
+		$settings = array_merge($settings, array('globalWaypoints' => 'TRUE'));
1404 1404
 	} else {
1405
-		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1405
+		$settings = array_merge($settings, array('globalWaypoints' => 'FALSE'));
1406 1406
 	}
1407
-	$geoid = filter_input(INPUT_POST,'geoid',FILTER_SANITIZE_STRING);
1407
+	$geoid = filter_input(INPUT_POST, 'geoid', FILTER_SANITIZE_STRING);
1408 1408
 	if ($geoid == 'geoid') {
1409
-		$settings = array_merge($settings,array('globalGeoid' => 'TRUE'));
1409
+		$settings = array_merge($settings, array('globalGeoid' => 'TRUE'));
1410 1410
 	} else {
1411
-		$settings = array_merge($settings,array('globalGeoid' => 'FALSE'));
1411
+		$settings = array_merge($settings, array('globalGeoid' => 'FALSE'));
1412 1412
 	}
1413
-	$geoid_source = filter_input(INPUT_POST,'geoid_source',FILTER_SANITIZE_STRING);
1414
-	$settings = array_merge($settings,array('globalGeoidSource' => $geoid_source));
1413
+	$geoid_source = filter_input(INPUT_POST, 'geoid_source', FILTER_SANITIZE_STRING);
1414
+	$settings = array_merge($settings, array('globalGeoidSource' => $geoid_source));
1415 1415
 
1416
-	$noairlines = filter_input(INPUT_POST,'noairlines',FILTER_SANITIZE_STRING);
1416
+	$noairlines = filter_input(INPUT_POST, 'noairlines', FILTER_SANITIZE_STRING);
1417 1417
 	if ($noairlines == 'noairlines') {
1418
-		$settings = array_merge($settings,array('globalNoAirlines' => 'TRUE'));
1418
+		$settings = array_merge($settings, array('globalNoAirlines' => 'TRUE'));
1419 1419
 	} else {
1420
-		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1420
+		$settings = array_merge($settings, array('globalNoAirlines' => 'FALSE'));
1421 1421
 	}
1422 1422
 
1423
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1423
+	if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE'));
1424 1424
 
1425 1425
 	// Set some defaults values...
1426 1426
 	if (!isset($globalAircraftImageSources)) {
1427
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1428
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1427
+	    $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
1428
+	    $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources));
1429 1429
 	}
1430 1430
 
1431 1431
 	if (!isset($globalSchedulesSources)) {
1432
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1433
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1432
+	    $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1433
+    	    $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources));
1434 1434
     	}
1435 1435
 
1436
-	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1436
+	$settings = array_merge($settings, array('globalInstalled' => 'TRUE'));
1437 1437
 
1438 1438
 	if ($error == '') settings::modify_settings($settings);
1439 1439
 	if ($error == '') settings::comment_settings($settings_comment);
Please login to merge, or discard this patch.
require/class.Common.php 2 patches
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
 	* @param Array $headers header to submit with the form
15 15
 	* @return String the result
16 16
 	*/
17
-	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') {
17
+	public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '') {
18 18
 		global $globalProxy, $globalForceIPv4;
19 19
 		$ch = curl_init();
20 20
 		curl_setopt($ch, CURLOPT_URL, $url);
21 21
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
22
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
22
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
23 23
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
24 24
 			}
25 25
 		}
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
30 30
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
31 31
 		curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
32
-		curl_setopt($ch,CURLOPT_ENCODING , "gzip");
32
+		curl_setopt($ch, CURLOPT_ENCODING, "gzip");
33 33
 		//curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
34 34
 //		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0');
35 35
 		if ($useragent == '') {
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 		}
40 40
 		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41 41
 		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
42
-		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
42
+		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback"));
43 43
 		if ($type == 'post') {
44 44
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
45 45
 			if (is_array($data)) {
46 46
 				curl_setopt($ch, CURLOPT_POST, count($data));
47 47
 				$data_string = '';
48
-				foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
48
+				foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
49 49
 				rtrim($data_string, '&');
50 50
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
51 51
 			} else {
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		}
58 58
 		if ($cookie != '') {
59 59
 			if (is_array($cookie)) {
60
-				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';'));
60
+				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';'));
61 61
 			} else {
62 62
 				curl_setopt($ch, CURLOPT_COOKIE, $cookie);
63 63
 			}
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
 		$info = curl_getinfo($ch);
70 70
 		//var_dump($info);
71 71
 		curl_close($ch);
72
-		if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) {
72
+		if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) {
73 73
 			echo "Cloudflare Detected\n";
74 74
 			require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php');
75 75
 			$useragent = UAgent::random();
76 76
 			cloudflare::useUserAgent($useragent);
77 77
 			if ($clearanceCookie = cloudflare::bypass($url)) {
78
-				return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent);
78
+				return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent);
79 79
 			}
80 80
 		} else {
81 81
 			return $result;
@@ -106,20 +106,20 @@  discard block
 block discarded – undo
106 106
 		fclose($fp);
107 107
 	}
108 108
 
109
-	public static function gunzip($in_file,$out_file_name = '') {
109
+	public static function gunzip($in_file, $out_file_name = '') {
110 110
 		//echo $in_file.' -> '.$out_file_name."\n";
111 111
 		$buffer_size = 4096; // read 4kb at a time
112 112
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
113 113
 		if ($in_file != '' && file_exists($in_file)) {
114 114
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
115
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
116
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
115
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
116
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
117 117
 			else {
118 118
 				echo 'gzopen not available';
119 119
 				die;
120 120
 			}
121 121
 			$out_file = fopen($out_file_name, 'wb'); 
122
-			while(!gzeof($file)) {
122
+			while (!gzeof($file)) {
123 123
 				fwrite($out_file, gzread($file, $buffer_size));
124 124
 			}  
125 125
 			fclose($out_file);
@@ -127,19 +127,19 @@  discard block
 block discarded – undo
127 127
 		}
128 128
 	}
129 129
 
130
-	public static function bunzip2($in_file,$out_file_name = '') {
130
+	public static function bunzip2($in_file, $out_file_name = '') {
131 131
 		//echo $in_file.' -> '.$out_file_name."\n";
132 132
 		$buffer_size = 4096; // read 4kb at a time
133 133
 		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
134 134
 		if ($in_file != '' && file_exists($in_file)) {
135 135
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
136
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
136
+			if (function_exists('bzopen')) $file = bzopen($in_file, 'rb');
137 137
 			else {
138 138
 				echo 'bzopen not available';
139 139
 				die;
140 140
 			}
141 141
 			$out_file = fopen($out_file_name, 'wb'); 
142
-			while(!feof($file)) {
142
+			while (!feof($file)) {
143 143
 				fwrite($out_file, bzread($file, $buffer_size));
144 144
 			}  
145 145
 			fclose($out_file);
@@ -157,27 +157,27 @@  discard block
 block discarded – undo
157 157
 		if ($data == '') return array();
158 158
 		$html = str_get_html($data);
159 159
 		if ($html === false) return array();
160
-		$tabledata=array();
161
-		foreach($html->find('tr') as $element)
160
+		$tabledata = array();
161
+		foreach ($html->find('tr') as $element)
162 162
 		{
163 163
 			$td = array();
164
-			foreach( $element->find('th') as $row)
164
+			foreach ($element->find('th') as $row)
165 165
 			{
166 166
 				$td [] = trim($row->plaintext);
167 167
 			}
168
-			$td=array_filter($td);
168
+			$td = array_filter($td);
169 169
 			$tabledata[] = $td;
170 170
 
171 171
 			$td = array();
172 172
 			$tdi = array();
173
-			foreach( $element->find('td') as $row)
173
+			foreach ($element->find('td') as $row)
174 174
 			{
175 175
 				$td [] = trim($row->plaintext);
176 176
 				$tdi [] = trim($row->innertext);
177 177
 			}
178
-			$td=array_filter($td);
179
-			$tdi=array_filter($tdi);
180
-			$tabledata[]=array_merge($td,$tdi);
178
+			$td = array_filter($td);
179
+			$tdi = array_filter($tdi);
180
+			$tabledata[] = array_merge($td, $tdi);
181 181
 		}
182 182
 		$html->clear();
183 183
 		unset($html);
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 	public function text2array($data) {
193 193
 		$html = str_get_html($data);
194 194
 		if ($html === false) return array();
195
-		$tabledata=array();
196
-		foreach($html->find('p') as $element)
195
+		$tabledata = array();
196
+		foreach ($html->find('p') as $element)
197 197
 		{
198 198
 			$tabledata [] = trim($element->plaintext);
199 199
 		}
@@ -213,11 +213,11 @@  discard block
 block discarded – undo
213 213
 	*/
214 214
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
215 215
 		if ($lat == $latc && $lon == $lonc) return 0;
216
-		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
216
+		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc))) + cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon) - floatval($lonc)))))*60*1.1515;
217 217
 		if ($unit == "km") {
218
-			return round($dist * 1.609344);
218
+			return round($dist*1.609344);
219 219
 		} elseif ($unit == "m") {
220
-			return round($dist * 1.609344 * 1000);
220
+			return round($dist*1.609344*1000);
221 221
 		} elseif ($unit == "mile" || $unit == "mi") {
222 222
 			return round($dist);
223 223
 		} elseif ($unit == "nm") {
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	* @param float $distance distance covered
234 234
 	* @return whether distance is realistic
235 235
 	*/
236
-	public function withinThreshold ($timeDifference, $distance) {
236
+	public function withinThreshold($timeDifference, $distance) {
237 237
 		$x = abs($timeDifference);
238 238
 		$d = abs($distance);
239 239
 		if ($x == 0 || $d == 0) return true;
@@ -249,12 +249,12 @@  discard block
 block discarded – undo
249 249
 		return ($array !== array_values($array));
250 250
 	}
251 251
 
252
-	public function isInteger($input){
252
+	public function isInteger($input) {
253 253
 	    return(ctype_digit(strval($input)));
254 254
 	}
255 255
 
256 256
 
257
-	public function convertDec($dms,$latlong) {
257
+	public function convertDec($dms, $latlong) {
258 258
 		if ($latlong == 'latitude') {
259 259
 			$deg = substr($dms, 0, 2);
260 260
 			$min = substr($dms, 2, 4);
@@ -262,10 +262,10 @@  discard block
 block discarded – undo
262 262
 			$deg = substr($dms, 0, 3);
263 263
 			$min = substr($dms, 3, 5);
264 264
 		}
265
-		return $deg+(($min*60)/3600);
265
+		return $deg + (($min*60)/3600);
266 266
 	}
267 267
 	
268
-	public function convertDM($coord,$latlong) {
268
+	public function convertDM($coord, $latlong) {
269 269
 		if ($latlong == 'latitude') {
270 270
 			if ($coord < 0) $NSEW = 'S';
271 271
 			else $NSEW = 'N';
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 		}
276 276
 		$coord = abs($coord);
277 277
 		$deg = floor($coord);
278
-		$coord = ($coord-$deg)*60;
278
+		$coord = ($coord - $deg)*60;
279 279
 		$min = $coord;
280
-		return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW);
280
+		return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW);
281 281
 	}
282 282
 	
283 283
 	/**
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 	public function xcopy($source, $dest)
290 290
 	{
291 291
 		$files = glob($source.'*.*');
292
-		foreach($files as $file){
293
-			$file_to_go = str_replace($source,$dest,$file);
292
+		foreach ($files as $file) {
293
+			$file_to_go = str_replace($source, $dest, $file);
294 294
 			copy($file, $file_to_go);
295 295
 		}
296 296
 		return true;
@@ -301,9 +301,9 @@  discard block
 block discarded – undo
301 301
 	* @param	String $url url to check
302 302
 	* @return	bool Return true on succes false on failure
303 303
 	*/
304
-	public function urlexist($url){
305
-		$headers=get_headers($url);
306
-		return stripos($headers[0],"200 OK")?true:false;
304
+	public function urlexist($url) {
305
+		$headers = get_headers($url);
306
+		return stripos($headers[0], "200 OK") ? true : false;
307 307
 	}
308 308
 	
309 309
 	/**
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	public function hex2str($hex) {
315 315
 		$str = '';
316 316
 		$hexln = strlen($hex);
317
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
317
+		for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2)));
318 318
 		return $str;
319 319
 	}
320 320
 	
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	* @return	String Return result
325 325
 	*/
326 326
 	public function hex2rgb($hex) {
327
-		$hex = str_replace('#','',$hex);
327
+		$hex = str_replace('#', '', $hex);
328 328
 		return sscanf($hex, "%02x%02x%02x"); 
329 329
 	}
330 330
 	
@@ -332,33 +332,33 @@  discard block
 block discarded – undo
332 332
 		//difference in longitudinal coordinates
333 333
 		$dLon = deg2rad($lon2) - deg2rad($lon1);
334 334
 		//difference in the phi of latitudinal coordinates
335
-		$dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4));
335
+		$dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4));
336 336
 		//we need to recalculate $dLon if it is greater than pi
337
-		if(abs($dLon) > pi()) {
338
-			if($dLon > 0) {
339
-				$dLon = (2 * pi() - $dLon) * -1;
337
+		if (abs($dLon) > pi()) {
338
+			if ($dLon > 0) {
339
+				$dLon = (2*pi() - $dLon)*-1;
340 340
 			} else {
341
-				$dLon = 2 * pi() + $dLon;
341
+				$dLon = 2*pi() + $dLon;
342 342
 			}
343 343
 		}
344 344
 		//return the angle, normalized
345
-		return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360;
345
+		return (rad2deg(atan2($dLon, $dPhi)) + 360)%360;
346 346
 	}
347 347
 	
348
-	public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.2) {
348
+	public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.2) {
349 349
 		//$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1);
350
-		$a = -($lon2-$lon1);
350
+		$a = -($lon2 - $lon1);
351 351
 		$b = $lat2 - $lat1;
352
-		$c = -($a*$lat1+$b*$lon1);
353
-		$d = $a*$lat3+$b*$lon3+$c;
352
+		$c = -($a*$lat1 + $b*$lon1);
353
+		$d = $a*$lat3 + $b*$lon3 + $c;
354 354
 		if ($d > -$approx && $d < $approx) return true;
355 355
 		else return false;
356 356
 	}
357 357
 	
358 358
 	public function array_merge_noappend() {
359 359
 		$output = array();
360
-		foreach(func_get_args() as $array) {
361
-			foreach($array as $key => $value) {
360
+		foreach (func_get_args() as $array) {
361
+			foreach ($array as $key => $value) {
362 362
 				$output[$key] = isset($output[$key]) ?
363 363
 				array_merge($output[$key], $value) : $value;
364 364
 			}
@@ -422,34 +422,34 @@  discard block
 block discarded – undo
422 422
 		return $result;
423 423
 	}
424 424
 
425
-	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1){
425
+	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1) {
426 426
 		global $globalMapRefresh;
427 427
 		$distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000;
428 428
 		$r = 6378;
429 429
 		$latitude = deg2rad($latitude);
430 430
 		$longitude = deg2rad($longitude);
431 431
 		$bearing = deg2rad($heading); 
432
-		$latitude2 =  asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) );
433
-		$longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) );
434
-		return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.',''));
432
+		$latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing)));
433
+		$longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2)));
434
+		return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', ''));
435 435
 	}
436 436
 	
437
-	public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) {
437
+	public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) {
438 438
 		// distance in meter
439 439
 		$R = 6378.14;
440
-		$latitude1 = $latitude * (M_PI/180);
441
-		$longitude1 = $longitude * (M_PI/180);
442
-		$brng = $bearing * (M_PI/180);
440
+		$latitude1 = $latitude*(M_PI/180);
441
+		$longitude1 = $longitude*(M_PI/180);
442
+		$brng = $bearing*(M_PI/180);
443 443
 		$d = $distance;
444 444
 
445 445
 		$latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng));
446
-		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2));
446
+		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2));
447 447
 
448
-		$latitude2 = $latitude2 * (180/M_PI);
449
-		$longitude2 = $longitude2 * (180/M_PI);
448
+		$latitude2 = $latitude2*(180/M_PI);
449
+		$longitude2 = $longitude2*(180/M_PI);
450 450
 
451
-		$flat = round ($latitude2,6);
452
-		$flong = round ($longitude2,6);
451
+		$flat = round($latitude2, 6);
452
+		$flong = round($longitude2, 6);
453 453
 /*
454 454
 		$dx = $distance*cos($bearing);
455 455
 		$dy = $distance*sin($bearing);
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 		$flong = $longitude + $dlong;
459 459
 		$flat = $latitude + $dlat;
460 460
 */
461
-		return array('latitude' => $flat,'longitude' => $flong);
461
+		return array('latitude' => $flat, 'longitude' => $flong);
462 462
 	}
463 463
 
464 464
 	/**
@@ -472,14 +472,14 @@  discard block
 block discarded – undo
472 472
 	 * @param integer $level GZIP compression level (default: 9)
473 473
 	 * @return string New filename (with .gz appended) if success, or false if operation fails
474 474
 	 */
475
-	public function gzCompressFile($source, $level = 9){ 
476
-		$dest = $source . '.gz'; 
477
-		$mode = 'wb' . $level; 
475
+	public function gzCompressFile($source, $level = 9) { 
476
+		$dest = $source.'.gz'; 
477
+		$mode = 'wb'.$level; 
478 478
 		$error = false; 
479 479
 		if ($fp_out = gzopen($dest, $mode)) { 
480
-			if ($fp_in = fopen($source,'rb')) { 
480
+			if ($fp_in = fopen($source, 'rb')) { 
481 481
 				while (!feof($fp_in)) 
482
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
482
+					gzwrite($fp_out, fread($fp_in, 1024*512)); 
483 483
 				fclose($fp_in); 
484 484
 			} else {
485 485
 				$error = true; 
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 	} 
496 496
 	
497 497
 	public function remove_accents($string) {
498
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
498
+		if (!preg_match('/[\x80-\xff]/', $string)) return $string;
499 499
 		$chars = array(
500 500
 		    // Decompositions for Latin-1 Supplement
501 501
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
553 553
 		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
554 554
 		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
555
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
555
+		    chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij',
556 556
 		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
557 557
 		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
558 558
 		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
@@ -568,13 +568,13 @@  discard block
 block discarded – undo
568 568
 		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
569 569
 		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
570 570
 		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
571
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
572
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
573
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
574
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
575
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
576
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
577
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
571
+		    chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
572
+		    chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
573
+		    chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
574
+		    chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
575
+		    chr(197).chr(154) => 'S', chr(197).chr(155) => 's',
576
+		    chr(197).chr(156) => 'S', chr(197).chr(157) => 's',
577
+		    chr(197).chr(158) => 'S', chr(197).chr(159) => 's',
578 578
 		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
579 579
 		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
580 580
 		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 		for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) {
609 609
 			if (is_numeric($string[$i]) && $concat_flag) {
610 610
 				$int .= $string[$i];
611
-			} elseif(!$concat && $concat_flag && strlen($int) > 0) {
611
+			} elseif (!$concat && $concat_flag && strlen($int) > 0) {
612 612
 				$concat_flag = false;
613 613
 			}
614 614
 		}
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 			$slice = array_slice($arr, $offset + 1, $length);
655 655
 			return implode("", $slice);
656 656
 		} else {
657
-			return mb_substr($string,$offset,$length,'UTF-8');
657
+			return mb_substr($string, $offset, $length, 'UTF-8');
658 658
 		}
659 659
 	}
660 660
 
@@ -664,14 +664,14 @@  discard block
 block discarded – undo
664 664
 		//NOTE: use a trailing slash for folders!!!
665 665
 		//see http://bugs.php.net/bug.php?id=27609
666 666
 		//see http://bugs.php.net/bug.php?id=30931
667
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
667
+		if ($path{strlen($path) - 1} == '/') // recursively return a temporary file path
668 668
 			return is__writable($path.uniqid(mt_rand()).'.tmp');
669 669
 		else if (is_dir($path))
670 670
 			return is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
671 671
 		// check tmp file for read/write capabilities
672 672
 		$rm = file_exists($path);
673 673
 		$f = @fopen($path, 'a');
674
-		if ($f===false)
674
+		if ($f === false)
675 675
 			return false;
676 676
 		fclose($f);
677 677
 		if (!$rm)
Please login to merge, or discard this patch.
Braces   +98 added lines, -44 removed lines patch added patch discarded remove patch
@@ -37,8 +37,11 @@  discard block
 block discarded – undo
37 37
 		} else {
38 38
 			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
39 39
 		}
40
-		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41
-		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
40
+		if ($timeout == '') {
41
+			curl_setopt($ch, CURLOPT_TIMEOUT, 10);
42
+		} else {
43
+			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
44
+		}
42 45
 		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
43 46
 		if ($type == 'post') {
44 47
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@@ -85,8 +88,9 @@  discard block
 block discarded – undo
85 88
 	private function curlResponseHeaderCallback($ch, $headerLine) {
86 89
 		//global $cookies;
87 90
 		$cookies = array();
88
-		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
89
-			$cookies[] = $cookie;
91
+		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
92
+					$cookies[] = $cookie;
93
+		}
90 94
 		return strlen($headerLine); // Needed by curl
91 95
 	}
92 96
 
@@ -97,11 +101,15 @@  discard block
 block discarded – undo
97 101
 		curl_setopt($ch, CURLOPT_URL, $url);
98 102
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
99 103
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
100
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
104
+		if ($referer != '') {
105
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
106
+		}
101 107
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
102 108
 		curl_setopt($ch, CURLOPT_FILE, $fp);
103 109
 		curl_exec($ch);
104
-		if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch);
110
+		if (curl_errno($ch) && $globalDebug) {
111
+			echo 'Download error: '.curl_error($ch);
112
+		}
105 113
 		curl_close($ch);
106 114
 		fclose($fp);
107 115
 	}
@@ -109,12 +117,16 @@  discard block
 block discarded – undo
109 117
 	public static function gunzip($in_file,$out_file_name = '') {
110 118
 		//echo $in_file.' -> '.$out_file_name."\n";
111 119
 		$buffer_size = 4096; // read 4kb at a time
112
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
120
+		if ($out_file_name == '') {
121
+			$out_file_name = str_replace('.gz', '', $in_file);
122
+		}
113 123
 		if ($in_file != '' && file_exists($in_file)) {
114 124
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
115
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
116
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
117
-			else {
125
+			if (function_exists('gzopen')) {
126
+				$file = gzopen($in_file,'rb');
127
+			} elseif (function_exists('gzopen64')) {
128
+				$file = gzopen64($in_file,'rb');
129
+			} else {
118 130
 				echo 'gzopen not available';
119 131
 				die;
120 132
 			}
@@ -130,11 +142,14 @@  discard block
 block discarded – undo
130 142
 	public static function bunzip2($in_file,$out_file_name = '') {
131 143
 		//echo $in_file.' -> '.$out_file_name."\n";
132 144
 		$buffer_size = 4096; // read 4kb at a time
133
-		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
145
+		if ($out_file_name == '') {
146
+			$out_file_name = str_replace('.bz2', '', $in_file);
147
+		}
134 148
 		if ($in_file != '' && file_exists($in_file)) {
135 149
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
136
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
137
-			else {
150
+			if (function_exists('bzopen')) {
151
+				$file = bzopen($in_file,'rb');
152
+			} else {
138 153
 				echo 'bzopen not available';
139 154
 				die;
140 155
 			}
@@ -153,10 +168,16 @@  discard block
 block discarded – undo
153 168
 	* @return Array array of the tables in HTML page
154 169
 	*/
155 170
 	public function table2array($data) {
156
-		if (!is_string($data)) return array();
157
-		if ($data == '') return array();
171
+		if (!is_string($data)) {
172
+			return array();
173
+		}
174
+		if ($data == '') {
175
+			return array();
176
+		}
158 177
 		$html = str_get_html($data);
159
-		if ($html === false) return array();
178
+		if ($html === false) {
179
+			return array();
180
+		}
160 181
 		$tabledata=array();
161 182
 		foreach($html->find('tr') as $element)
162 183
 		{
@@ -191,7 +212,9 @@  discard block
 block discarded – undo
191 212
 	*/
192 213
 	public function text2array($data) {
193 214
 		$html = str_get_html($data);
194
-		if ($html === false) return array();
215
+		if ($html === false) {
216
+			return array();
217
+		}
195 218
 		$tabledata=array();
196 219
 		foreach($html->find('p') as $element)
197 220
 		{
@@ -212,7 +235,9 @@  discard block
 block discarded – undo
212 235
 	* @return Float Distance in $unit
213 236
 	*/
214 237
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
215
-		if ($lat == $latc && $lon == $lonc) return 0;
238
+		if ($lat == $latc && $lon == $lonc) {
239
+			return 0;
240
+		}
216 241
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
217 242
 		if ($unit == "km") {
218 243
 			return round($dist * 1.609344);
@@ -236,10 +261,16 @@  discard block
 block discarded – undo
236 261
 	public function withinThreshold ($timeDifference, $distance) {
237 262
 		$x = abs($timeDifference);
238 263
 		$d = abs($distance);
239
-		if ($x == 0 || $d == 0) return true;
264
+		if ($x == 0 || $d == 0) {
265
+			return true;
266
+		}
240 267
 		// may be due to Internet jitter; distance is realistic
241
-		if ($x < 0.7 && $d < 2000) return true;
242
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
268
+		if ($x < 0.7 && $d < 2000) {
269
+			return true;
270
+		} else {
271
+			return $d/$x < 1500*0.27778;
272
+		}
273
+		// 1500 km/h max
243 274
 	}
244 275
 
245 276
 
@@ -267,11 +298,17 @@  discard block
 block discarded – undo
267 298
 	
268 299
 	public function convertDM($coord,$latlong) {
269 300
 		if ($latlong == 'latitude') {
270
-			if ($coord < 0) $NSEW = 'S';
271
-			else $NSEW = 'N';
301
+			if ($coord < 0) {
302
+				$NSEW = 'S';
303
+			} else {
304
+				$NSEW = 'N';
305
+			}
272 306
 		} else {
273
-			if ($coord < 0) $NSEW = 'W';
274
-			else $NSEW = 'E';
307
+			if ($coord < 0) {
308
+				$NSEW = 'W';
309
+			} else {
310
+				$NSEW = 'E';
311
+			}
275 312
 		}
276 313
 		$coord = abs($coord);
277 314
 		$deg = floor($coord);
@@ -314,7 +351,9 @@  discard block
 block discarded – undo
314 351
 	public function hex2str($hex) {
315 352
 		$str = '';
316 353
 		$hexln = strlen($hex);
317
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
354
+		for($i=0;$i<$hexln;$i+=2) {
355
+			$str .= chr(hexdec(substr($hex,$i,2)));
356
+		}
318 357
 		return $str;
319 358
 	}
320 359
 	
@@ -351,8 +390,11 @@  discard block
 block discarded – undo
351 390
 		$b = $lat2 - $lat1;
352 391
 		$c = -($a*$lat1+$b*$lon1);
353 392
 		$d = $a*$lat3+$b*$lon3+$c;
354
-		if ($d > -$approx && $d < $approx) return true;
355
-		else return false;
393
+		if ($d > -$approx && $d < $approx) {
394
+			return true;
395
+		} else {
396
+			return false;
397
+		}
356 398
 	}
357 399
 	
358 400
 	public function array_merge_noappend() {
@@ -411,7 +453,9 @@  discard block
 block discarded – undo
411 453
 			return $result;
412 454
 		}
413 455
 		$handle = @opendir('./locale');
414
-		if ($handle === false) return $result;
456
+		if ($handle === false) {
457
+			return $result;
458
+		}
415 459
 		while (false !== ($file = readdir($handle))) {
416 460
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
417 461
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -478,8 +522,9 @@  discard block
 block discarded – undo
478 522
 		$error = false; 
479 523
 		if ($fp_out = gzopen($dest, $mode)) { 
480 524
 			if ($fp_in = fopen($source,'rb')) { 
481
-				while (!feof($fp_in)) 
482
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
525
+				while (!feof($fp_in)) {
526
+									gzwrite($fp_out, fread($fp_in, 1024 * 512));
527
+				}
483 528
 				fclose($fp_in); 
484 529
 			} else {
485 530
 				$error = true; 
@@ -488,14 +533,17 @@  discard block
 block discarded – undo
488 533
 		} else {
489 534
 			$error = true; 
490 535
 		}
491
-		if ($error)
492
-			return false; 
493
-		else
494
-			return $dest; 
536
+		if ($error) {
537
+					return false;
538
+		} else {
539
+					return $dest;
540
+		}
495 541
 	} 
496 542
 	
497 543
 	public function remove_accents($string) {
498
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
544
+		if ( !preg_match('/[\x80-\xff]/', $string) ) {
545
+			return $string;
546
+		}
499 547
 		$chars = array(
500 548
 		    // Decompositions for Latin-1 Supplement
501 549
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -619,7 +667,9 @@  discard block
 block discarded – undo
619 667
 		$ip = gethostbyname($host);
620 668
 		$s = socket_create(AF_INET, SOCK_STREAM, 0);
621 669
 		$r = @socket_connect($s, $ip, $port);
622
-		if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
670
+		if (!socket_set_nonblock($s)) {
671
+			echo "Unable to set nonblock on socket\n";
672
+		}
623 673
 		if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
624 674
 			return $s;
625 675
 		}
@@ -664,18 +714,22 @@  discard block
 block discarded – undo
664 714
 		//NOTE: use a trailing slash for folders!!!
665 715
 		//see http://bugs.php.net/bug.php?id=27609
666 716
 		//see http://bugs.php.net/bug.php?id=30931
667
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
717
+		if ($path{strlen($path)-1}=='/') {
718
+			// recursively return a temporary file path
668 719
 			return is__writable($path.uniqid(mt_rand()).'.tmp');
669
-		else if (is_dir($path))
670
-			return is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
720
+		} else if (is_dir($path)) {
721
+					return is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
722
+		}
671 723
 		// check tmp file for read/write capabilities
672 724
 		$rm = file_exists($path);
673 725
 		$f = @fopen($path, 'a');
674
-		if ($f===false)
675
-			return false;
726
+		if ($f===false) {
727
+					return false;
728
+		}
676 729
 		fclose($f);
677
-		if (!$rm)
678
-			unlink($path);
730
+		if (!$rm) {
731
+					unlink($path);
732
+		}
679 733
 		return true;
680 734
 	}
681 735
 }
Please login to merge, or discard this patch.
require/class.Scheduler.php 3 patches
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 class Schedule {
10 10
 	protected $cookies = array();
11
-        public $db;
11
+		public $db;
12 12
 	public function __construct($dbc = null) {
13 13
 		$Connection = new Connection($dbc);
14 14
 		$this->db = $Connection->db();
@@ -16,22 +16,22 @@  discard block
 block discarded – undo
16 16
 	}
17 17
 	
18 18
 	/**
19
-	* Add schedule data to database
20
-	* @param String $ident aircraft ident
21
-	* @param String $departure_airport_icao departure airport icao
22
-	* @param String $departure_airport_time departure airport time
23
-	* @param String $arrival_airport_icao arrival airport icao
24
-	* @param String $arrival_airport_time arrival airport time
19
+	 * Add schedule data to database
20
+	 * @param String $ident aircraft ident
21
+	 * @param String $departure_airport_icao departure airport icao
22
+	 * @param String $departure_airport_time departure airport time
23
+	 * @param String $arrival_airport_icao arrival airport icao
24
+	 * @param String $arrival_airport_time arrival airport time
25 25
 	/ @param String $source source of data
26
-	*/
26
+	 */
27 27
 	
28 28
 	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
29 29
 		date_default_timezone_set('UTC');
30 30
 		$date = date("Y-m-d H:i:s",time());
31
-	        //if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
32
-	        //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
33
-	        $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
34
-	        $query_values = array(':ident' => $ident);
31
+			//if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
32
+			//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
33
+			$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
34
+			$query_values = array(':ident' => $ident);
35 35
 		 try {
36 36
 			$sth = $this->db->prepare($query);
37 37
 			$sth->execute($query_values);
@@ -40,18 +40,18 @@  discard block
 block discarded – undo
40 40
 		}
41 41
 		if ($sth->fetchColumn() > 0) {
42 42
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
43
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
44
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
43
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
44
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
45 45
 			} elseif ($arrival_airport_time == '') {
46
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
47
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
46
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
47
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
48 48
 			} elseif ($departure_airport_time == '') {
49
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
50
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
49
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
50
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
51 51
 			} else {
52
-			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
53
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
54
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
52
+				//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
53
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
54
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
55 55
 			}
56 56
 			try {
57 57
 				$sth = $this->db->prepare($query);
@@ -62,17 +62,17 @@  discard block
 block discarded – undo
62 62
 			if ($sth->fetchColumn() == 0) {
63 63
 				//$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident';
64 64
 				if ($departure_airport_time == '' && $arrival_airport_time == '') {
65
-                            	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
66
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
65
+									$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
66
+					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
67 67
 				} elseif ($arrival_airport_time == '') {
68
-                            	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
69
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
68
+									$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
69
+					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
70 70
 				} elseif ($departure_airport_time == '') {
71
-                            	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
72
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
71
+									$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
72
+					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
73 73
 				} else {
74
-                            	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
75
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
74
+									$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
75
+					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
76 76
 				}
77 77
 				 try {
78 78
 					$sth = $this->db->prepare($query);
@@ -105,15 +105,15 @@  discard block
 block discarded – undo
105 105
 	}
106 106
 
107 107
 	public function getSchedule($ident) {
108
-	        $Translation = new Translation($this->db);
109
-	        $operator = $Translation->checkTranslation($ident,false);
110
-	        if ($ident != $operator) {
111
-	    		$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1";
112
-	    		$query_values = array(':ident' => $ident,'operator' => $operator);
113
-	    	} else {
114
-		        $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1";
115
-	    		$query_values = array(':ident' => $ident);
116
-	    	}
108
+			$Translation = new Translation($this->db);
109
+			$operator = $Translation->checkTranslation($ident,false);
110
+			if ($ident != $operator) {
111
+				$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1";
112
+				$query_values = array(':ident' => $ident,'operator' => $operator);
113
+			} else {
114
+				$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1";
115
+				$query_values = array(':ident' => $ident);
116
+			}
117 117
 		 try {
118 118
 			$sth = $this->db->prepare($query);
119 119
 			$sth->execute($query_values);
@@ -129,15 +129,15 @@  discard block
 block discarded – undo
129 129
 
130 130
 	public function checkSchedule($ident) {
131 131
 		global $globalDBdriver;
132
-	        //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
133
-	        if ($globalDBdriver == 'mysql') {
132
+			//$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
133
+			if ($globalDBdriver == 'mysql') {
134 134
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident AND ((date_added BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND DATE(NOW()) and date_modified IS NULL) OR (date_modified BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 15 DAY)) AND DATE(NOW()))) LIMIT 1";
135 135
 		} else {
136 136
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident 
137 137
 			AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL)
138 138
 			     OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) LIMIT 1";
139 139
 		}
140
-	        $query_values = array(':ident' => $ident);
140
+			$query_values = array(':ident' => $ident);
141 141
 		 try {
142 142
 			$sth = $this->db->prepare($query);
143 143
 			$sth->execute($query_values);
@@ -150,12 +150,12 @@  discard block
 block discarded – undo
150 150
 	}
151 151
 
152 152
 	/**
153
-	* Get flight info from Air France
154
-	* @param String $callsign The callsign
155
-	* @param String $date date we want flight number info
156
-	* @param String $carrier IATA code
157
-	* @return Flight departure and arrival airports and time
158
-	*/
153
+	 * Get flight info from Air France
154
+	 * @param String $callsign The callsign
155
+	 * @param String $date date we want flight number info
156
+	 * @param String $carrier IATA code
157
+	 * @return Flight departure and arrival airports and time
158
+	 */
159 159
 	private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
160 160
 		$Common = new Common();
161 161
 		$check_date = new Datetime($date);
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
 	}
192 192
 
193 193
 	/**
194
-	* Get flight info from EasyJet
195
-	* @param String $callsign The callsign
196
-	* @param String $date date we want flight number info
197
-	* @return Flight departure and arrival airports and time
198
-	*/
194
+	 * Get flight info from EasyJet
195
+	 * @param String $callsign The callsign
196
+	 * @param String $date date we want flight number info
197
+	 * @return Flight departure and arrival airports and time
198
+	 */
199 199
 	private function getEasyJet($callsign, $date = 'NOW') {
200 200
 		global $globalTimezone;
201 201
 		$Common = new Common();
@@ -219,10 +219,10 @@  discard block
 block discarded – undo
219 219
 	}
220 220
 
221 221
 	/**
222
-	* Get flight info from Ryanair
223
-	* @param String $callsign The callsign
224
-	* @return Flight departure and arrival airports and time
225
-	*/
222
+	 * Get flight info from Ryanair
223
+	 * @param String $callsign The callsign
224
+	 * @return Flight departure and arrival airports and time
225
+	 */
226 226
 	private function getRyanair($callsign) {
227 227
 		$Common = new Common();
228 228
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -245,10 +245,10 @@  discard block
 block discarded – undo
245 245
 	}
246 246
 
247 247
 	/**
248
-	* Get flight info from Swiss
249
-	* @param String $callsign The callsign
250
-	* @return Flight departure and arrival airports and time
251
-	*/
248
+	 * Get flight info from Swiss
249
+	 * @param String $callsign The callsign
250
+	 * @return Flight departure and arrival airports and time
251
+	 */
252 252
 	private function getSwiss($callsign) {
253 253
 		$Common = new Common();
254 254
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
 	}
278 278
 	
279 279
 	/**
280
-	* Get flight info from British Airways API
281
-	* @param String $callsign The callsign
282
-	* @param String $date date we want flight number info
283
-	* @return Flight departure and arrival airports and time
284
-	*/
280
+	 * Get flight info from British Airways API
281
+	 * @param String $callsign The callsign
282
+	 * @param String $date date we want flight number info
283
+	 * @return Flight departure and arrival airports and time
284
+	 */
285 285
 	public function getBritishAirways($callsign, $date = 'NOW') {
286 286
 		global $globalBritishAirwaysKey;
287 287
 		$Common = new Common();
@@ -305,11 +305,11 @@  discard block
 block discarded – undo
305 305
 	}
306 306
 
307 307
 	/**
308
-	* Get flight info from Lutfhansa API
309
-	* @param String $callsign The callsign
310
-	* @param String $date date we want flight number info
311
-	* @return Flight departure and arrival airports and time
312
-	*/
308
+	 * Get flight info from Lutfhansa API
309
+	 * @param String $callsign The callsign
310
+	 * @param String $date date we want flight number info
311
+	 * @return Flight departure and arrival airports and time
312
+	 */
313 313
 	public function getLufthansa($callsign, $date = 'NOW') {
314 314
 		global $globalLufthansaKey;
315 315
 		$Common = new Common();
@@ -339,11 +339,11 @@  discard block
 block discarded – undo
339 339
 	}
340 340
 
341 341
 	/**
342
-	* Get flight info from Transavia API
343
-	* @param String $callsign The callsign
344
-	* @param String $date date we want flight number info
345
-	* @return Flight departure and arrival airports and time
346
-	*/
342
+	 * Get flight info from Transavia API
343
+	 * @param String $callsign The callsign
344
+	 * @param String $date date we want flight number info
345
+	 * @return Flight departure and arrival airports and time
346
+	 */
347 347
 	public function getTransavia($callsign, $date = 'NOW') {
348 348
 		global $globalTransaviaKey;
349 349
 		$Common = new Common();
@@ -369,10 +369,10 @@  discard block
 block discarded – undo
369 369
 	}
370 370
 
371 371
 	/**
372
-	* Get flight info from Tunisair
373
-	* @param String $callsign The callsign
374
-	* @return Flight departure and arrival airports and time
375
-	*/
372
+	 * Get flight info from Tunisair
373
+	 * @param String $callsign The callsign
374
+	 * @return Flight departure and arrival airports and time
375
+	 */
376 376
 	public function getTunisair($callsign) {
377 377
 		$Common = new Common();
378 378
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -389,10 +389,10 @@  discard block
 block discarded – undo
389 389
 	}
390 390
 
391 391
 	/**
392
-	* Get flight info from Vueling
393
-	* @param String $callsign The callsign
394
-	* @return Flight departure and arrival airports and time
395
-	*/
392
+	 * Get flight info from Vueling
393
+	 * @param String $callsign The callsign
394
+	 * @return Flight departure and arrival airports and time
395
+	 */
396 396
 	public function getVueling($callsign,$date = 'NOW') {
397 397
 		$Common = new Common();
398 398
 		$check_date = new Datetime($date);
@@ -414,11 +414,11 @@  discard block
 block discarded – undo
414 414
 	}
415 415
 
416 416
 	/**
417
-	* Get flight info from Iberia
418
-	* @param String $callsign The callsign
419
-	* @param String $date date we want flight number info
420
-	* @return Flight departure and arrival airports and time
421
-	*/
417
+	 * Get flight info from Iberia
418
+	 * @param String $callsign The callsign
419
+	 * @param String $date date we want flight number info
420
+	 * @return Flight departure and arrival airports and time
421
+	 */
422 422
 	public function getIberia($callsign, $date = 'NOW') {
423 423
 		$Common = new Common();
424 424
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -448,11 +448,11 @@  discard block
 block discarded – undo
448 448
 	}
449 449
 
450 450
 	/**
451
-	* Get flight info from Star Alliance
452
-	* @param String $callsign The callsign
453
-	* @param String $date date we want flight number info
454
-	* @return Flight departure and arrival airports and time
455
-	*/
451
+	 * Get flight info from Star Alliance
452
+	 * @param String $callsign The callsign
453
+	 * @param String $date date we want flight number info
454
+	 * @return Flight departure and arrival airports and time
455
+	 */
456 456
 
457 457
 	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
458 458
 		$Common = new Common();
@@ -484,11 +484,11 @@  discard block
 block discarded – undo
484 484
 
485 485
 
486 486
 	/**
487
-	* Get flight info from Alitalia
488
-	* @param String $callsign The callsign
489
-	* @param String $date date we want flight number info
490
-	* @return Flight departure and arrival airports and time
491
-	*/
487
+	 * Get flight info from Alitalia
488
+	 * @param String $callsign The callsign
489
+	 * @param String $date date we want flight number info
490
+	 * @return Flight departure and arrival airports and time
491
+	 */
492 492
 	private function getAlitalia($callsign, $date = 'NOW') {
493 493
 		$Common = new Common();
494 494
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -507,11 +507,11 @@  discard block
 block discarded – undo
507 507
 	}
508 508
 
509 509
 	/**
510
-	* Get flight info from Brussels airlines
511
-	* @param String $callsign The callsign
512
-	* @param String $date date we want flight number info
513
-	* @return Flight departure and arrival airports and time
514
-	*/
510
+	 * Get flight info from Brussels airlines
511
+	 * @param String $callsign The callsign
512
+	 * @param String $date date we want flight number info
513
+	 * @return Flight departure and arrival airports and time
514
+	 */
515 515
 	private function getBrussels($callsign, $date = 'NOW') {
516 516
 		$Common = new Common();
517 517
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -521,24 +521,24 @@  discard block
 block discarded – undo
521 521
 		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
522 522
 		$data = $Common->getData($url);
523 523
 		if ($data != '') {
524
-		    //echo $data;
525
-		    $parsed_json = json_decode($data,true);
526
-		    if (isset($parsed_json[0]['FromAirportCode'])) {
524
+			//echo $data;
525
+			$parsed_json = json_decode($data,true);
526
+			if (isset($parsed_json[0]['FromAirportCode'])) {
527 527
 			$DepartureAirportIata = $parsed_json[0]['FromAirportCode'];
528 528
 			$ArrivalAirportIata = $parsed_json[0]['ToAirportCode'];
529 529
 			$departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate']));
530 530
 			$arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate']));
531 531
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
532
-		    }
532
+			}
533 533
 		}
534 534
 	}
535 535
 
536 536
 	/**
537
-	* Get flight info from FlightRadar24
538
-	* @param String $callsign The callsign
539
-	* @param String $date date we want flight number info
540
-	* @return Flight departure and arrival airports and time
541
-	*/
537
+	 * Get flight info from FlightRadar24
538
+	 * @param String $callsign The callsign
539
+	 * @param String $date date we want flight number info
540
+	 * @return Flight departure and arrival airports and time
541
+	 */
542 542
 /*
543 543
 	public function getFlightRadar24($callsign, $date = 'NOW') {
544 544
 		$Common = new Common();
@@ -567,11 +567,11 @@  discard block
 block discarded – undo
567 567
 	}
568 568
   */
569 569
 	/**
570
-	* Get flight info from Lufthansa
571
-	* @param String $callsign The callsign
572
-	* @param String $date date we want flight number info
573
-	* @return Flight departure and arrival airports and time
574
-	*/
570
+	 * Get flight info from Lufthansa
571
+	 * @param String $callsign The callsign
572
+	 * @param String $date date we want flight number info
573
+	 * @return Flight departure and arrival airports and time
574
+	 */
575 575
 
576 576
 /*	private function getLufthansa($callsign, $date = 'NOW') {
577 577
 		$Common = new Common();
@@ -599,10 +599,10 @@  discard block
 block discarded – undo
599 599
 	}
600 600
   */
601 601
 	/**
602
-	* Get flight info from flytap
603
-	* @param String $callsign The callsign
604
-	* @return Flight departure and arrival airports and time
605
-	*/
602
+	 * Get flight info from flytap
603
+	 * @param String $callsign The callsign
604
+	 * @return Flight departure and arrival airports and time
605
+	 */
606 606
 	private function getFlyTap($callsign) {
607 607
 		$Common = new Common();
608 608
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -625,10 +625,10 @@  discard block
 block discarded – undo
625 625
 	}
626 626
 
627 627
 	/**
628
-	* Get flight info from flightmapper
629
-	* @param String $callsign The callsign
630
-	* @return Flight departure and arrival airports and time
631
-	*/
628
+	 * Get flight info from flightmapper
629
+	 * @param String $callsign The callsign
630
+	 * @return Flight departure and arrival airports and time
631
+	 */
632 632
 	public function getFlightMapper($callsign) {
633 633
 		$Common = new Common();
634 634
 		$airline_icao = '';
@@ -656,11 +656,11 @@  discard block
 block discarded – undo
656 656
 				$aarr = '';
657 657
 				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
658 658
 				if ($n == 7) {
659
-				    $departureTime = $dhour;
660
-				    $arrivalTime = $ahour;
661
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
662
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
663
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
659
+					$departureTime = $dhour;
660
+					$arrivalTime = $ahour;
661
+					$DepartureAirportIata = str_replace(array('(',')'),'',$darr);
662
+					$ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
663
+					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
664 664
 				}
665 665
 			}
666 666
 		}
@@ -668,10 +668,10 @@  discard block
 block discarded – undo
668 668
 	}
669 669
 
670 670
 	/**
671
-	* Get flight info from flightaware
672
-	* @param String $callsign The callsign
673
-	* @return Flight departure and arrival airports and time
674
-	*/
671
+	 * Get flight info from flightaware
672
+	 * @param String $callsign The callsign
673
+	 * @return Flight departure and arrival airports and time
674
+	 */
675 675
 	public function getFlightAware($callsign) {
676 676
 		$Common = new Common();
677 677
 		/*
@@ -704,10 +704,10 @@  discard block
 block discarded – undo
704 704
 	}
705 705
 
706 706
 	/**
707
-	* Get flight info from CostToTravel
708
-	* @param String $callsign The callsign
709
-	* @return Flight departure and arrival airports and time
710
-	*/
707
+	 * Get flight info from CostToTravel
708
+	 * @param String $callsign The callsign
709
+	 * @return Flight departure and arrival airports and time
710
+	 */
711 711
 	public function getCostToTravel($callsign) {
712 712
 		$Common = new Common();
713 713
 		$url= "http://www.costtotravel.com/flight-number/".$callsign;
@@ -729,11 +729,11 @@  discard block
 block discarded – undo
729 729
 	}
730 730
 
731 731
 	/**
732
-	* Get flight info from Air Canada
733
-	* @param String $callsign The callsign
734
-	* @param String $date date we want flight number info
735
-	* @return Flight departure and arrival airports and time
736
-	*/
732
+	 * Get flight info from Air Canada
733
+	 * @param String $callsign The callsign
734
+	 * @param String $date date we want flight number info
735
+	 * @return Flight departure and arrival airports and time
736
+	 */
737 737
 	private function getAirCanada($callsign,$date = 'NOW') {
738 738
 		$Common = new Common();
739 739
 		if (class_exists("DomDocument") === FALSE) return array();
@@ -758,11 +758,11 @@  discard block
 block discarded – undo
758 758
 	}
759 759
 
760 760
 	/**
761
-	* Get flight info from Vietnam Airlines
762
-	* @param String $callsign The callsign
763
-	* @param String $date date we want flight number info
764
-	* @return Flight departure and arrival airports and time
765
-	*/
761
+	 * Get flight info from Vietnam Airlines
762
+	 * @param String $callsign The callsign
763
+	 * @param String $date date we want flight number info
764
+	 * @return Flight departure and arrival airports and time
765
+	 */
766 766
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
767 767
 		$Common = new Common();
768 768
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -784,12 +784,12 @@  discard block
 block discarded – undo
784 784
 	}
785 785
 
786 786
 	/**
787
-	* Get flight info from Air Berlin
788
-	* @param String $callsign The callsign
789
-	* @param String $date date we want flight number info
790
-	* @param String $carrier airline code
791
-	* @return Flight departure and arrival airports and time
792
-	*/
787
+	 * Get flight info from Air Berlin
788
+	 * @param String $callsign The callsign
789
+	 * @param String $date date we want flight number info
790
+	 * @param String $carrier airline code
791
+	 * @return Flight departure and arrival airports and time
792
+	 */
793 793
 	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
794 794
 		$Common = new Common();
795 795
 		date_default_timezone_set('UTC');
@@ -818,11 +818,11 @@  discard block
 block discarded – undo
818 818
 			$table = $Common->table2array($data);
819 819
 			$flight = $table;
820 820
 			if (isset($flight[5][4])) {
821
-			    $arrivalTime = $flight[5][4];
822
-			    $arrivalAirport = $flight[5][3];
821
+				$arrivalTime = $flight[5][4];
822
+				$arrivalAirport = $flight[5][3];
823 823
 			} else {
824
-			    $arrivalTime = '';
825
-			    $arrivalAirport = '';
824
+				$arrivalTime = '';
825
+				$arrivalAirport = '';
826 826
 			}
827 827
 		} else return array();
828 828
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 					}
1091 1091
 			}
1092 1092
 		}
1093
-	        return array();
1093
+			return array();
1094 1094
 	}
1095 1095
 }
1096 1096
 
Please login to merge, or discard this patch.
Spacing   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
 	/ @param String $source source of data
26 26
 	*/
27 27
 	
28
-	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
28
+	public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') {
29 29
 		date_default_timezone_set('UTC');
30
-		$date = date("Y-m-d H:i:s",time());
30
+		$date = date("Y-m-d H:i:s", time());
31 31
 	        //if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
32 32
 	        //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
33 33
 	        $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
@@ -35,69 +35,69 @@  discard block
 block discarded – undo
35 35
 		 try {
36 36
 			$sth = $this->db->prepare($query);
37 37
 			$sth->execute($query_values);
38
-		} catch(PDOException $e) {
38
+		} catch (PDOException $e) {
39 39
 			return "error : ".$e->getMessage();
40 40
 		}
41 41
 		if ($sth->fetchColumn() > 0) {
42 42
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
43 43
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
44
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
44
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao);
45 45
 			} elseif ($arrival_airport_time == '') {
46 46
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
47
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
47
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao);
48 48
 			} elseif ($departure_airport_time == '') {
49 49
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
50
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
50
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
51 51
 			} else {
52 52
 			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
53 53
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
54
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
54
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
55 55
 			}
56 56
 			try {
57 57
 				$sth = $this->db->prepare($query);
58 58
 				$sth->execute($query_values);
59
-			} catch(PDOException $e) {
59
+			} catch (PDOException $e) {
60 60
 				return "error : ".$e->getMessage();
61 61
 			}
62 62
 			if ($sth->fetchColumn() == 0) {
63 63
 				//$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident';
64 64
 				if ($departure_airport_time == '' && $arrival_airport_time == '') {
65 65
                             	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
66
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
66
+				    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
67 67
 				} elseif ($arrival_airport_time == '') {
68 68
                             	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
69
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
69
+				    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
70 70
 				} elseif ($departure_airport_time == '') {
71 71
                             	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
72
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
72
+				    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
73 73
 				} else {
74 74
                             	    $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
75
-				    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
75
+				    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
76 76
 				}
77 77
 				 try {
78 78
 					$sth = $this->db->prepare($query);
79 79
 					$sth->execute($query_values);
80
-				} catch(PDOException $e) {
80
+				} catch (PDOException $e) {
81 81
 					return "error : ".$e->getMessage();
82 82
 				}
83 83
 			} else {
84 84
 				//$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident';
85 85
 				$query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident';
86
-				$query_values = array(':ident' => $ident,':date' => $date);
86
+				$query_values = array(':ident' => $ident, ':date' => $date);
87 87
 				 try {
88 88
 					$sth = $this->db->prepare($query);
89 89
 					$sth->execute($query_values);
90
-				} catch(PDOException $e) {
90
+				} catch (PDOException $e) {
91 91
 					return "error : ".$e->getMessage();
92 92
 				}
93 93
 			}
94 94
 		} else {
95 95
 			$query = 'INSERT INTO  routes (CallSign,FromAirport_ICAO, FromAirport_Time, ToAirport_ICAO, ToAirport_Time,date_added,source)  VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)';
96
-			$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
96
+			$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
97 97
 			 try {
98 98
 				$sth = $this->db->prepare($query);
99 99
 				$sth->execute($query_values);
100
-			} catch(PDOException $e) {
100
+			} catch (PDOException $e) {
101 101
 				return "error : ".$e->getMessage();
102 102
 			}
103 103
 		}
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
 
107 107
 	public function getSchedule($ident) {
108 108
 	        $Translation = new Translation($this->db);
109
-	        $operator = $Translation->checkTranslation($ident,false);
109
+	        $operator = $Translation->checkTranslation($ident, false);
110 110
 	        if ($ident != $operator) {
111 111
 	    		$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1";
112
-	    		$query_values = array(':ident' => $ident,'operator' => $operator);
112
+	    		$query_values = array(':ident' => $ident, 'operator' => $operator);
113 113
 	    	} else {
114 114
 		        $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1";
115 115
 	    		$query_values = array(':ident' => $ident);
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		 try {
118 118
 			$sth = $this->db->prepare($query);
119 119
 			$sth->execute($query_values);
120
-		} catch(PDOException $e) {
120
+		} catch (PDOException $e) {
121 121
 			return "error : ".$e->getMessage();
122 122
 		}
123 123
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		 try {
142 142
 			$sth = $this->db->prepare($query);
143 143
 			$sth->execute($query_values);
144
-		} catch(PDOException $e) {
144
+		} catch (PDOException $e) {
145 145
 			return "error : ".$e->getMessage();
146 146
 		}
147 147
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -156,16 +156,16 @@  discard block
 block discarded – undo
156 156
 	* @param String $carrier IATA code
157 157
 	* @return Flight departure and arrival airports and time
158 158
 	*/
159
-	private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
159
+	private function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') {
160 160
 		$Common = new Common();
161 161
 		$check_date = new Datetime($date);
162
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
163
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
162
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
163
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
164 164
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
165 165
 		$json = $Common->getData($url);
166 166
 	
167 167
 		$parsed_json = json_decode($json);
168
-		if (property_exists($parsed_json,'errors') === false) {
168
+		if (property_exists($parsed_json, 'errors') === false) {
169 169
 			//$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'};
170 170
 			$originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'};
171 171
 			//$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'};
@@ -175,9 +175,9 @@  discard block
 block discarded – undo
175 175
 			//$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'};
176 176
 			$arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'};
177 177
 
178
-			preg_match('/\((.*?)\)/',$originShort,$originiata);
178
+			preg_match('/\((.*?)\)/', $originShort, $originiata);
179 179
 			$DepartureAirportIata = $originiata[1];
180
-			preg_match('/\((.*?)\)/',$destinationShort,$destinationiata);
180
+			preg_match('/\((.*?)\)/', $destinationShort, $destinationiata);
181 181
 			$ArrivalAirportIata = $destinationiata[1];
182 182
 
183 183
 			/*
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 			$arrivalTime = gmdate('H:i',strtotime($arrivalTime));
187 187
 			*/
188 188
 		
189
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
189
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance');
190 190
 		} else return array();
191 191
 	}
192 192
 
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
 		$Common = new Common();
202 202
 		date_default_timezone_set($globalTimezone);
203 203
 		$check_date = new Datetime($date);
204
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
205
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
204
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
205
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
206 206
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
207 207
 		$json = $Common->getData($url);
208 208
 		$parsed_json = json_decode($json);
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 			$departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'};
215 215
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
216 216
 
217
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
217
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet');
218 218
 		} else return array();
219 219
 	}
220 220
 
@@ -225,12 +225,12 @@  discard block
 block discarded – undo
225 225
 	*/
226 226
 	private function getRyanair($callsign) {
227 227
 		$Common = new Common();
228
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
229
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
228
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
229
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
230 230
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
231 231
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
232
-		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
233
-		$json = $Common->getData($url,'post',$post,$headers);
232
+		$headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post));
233
+		$json = $Common->getData($url, 'post', $post, $headers);
234 234
 		$parsed_json = json_decode($json);
235 235
 		if (isset($parsed_json->{'flightInfo'})) {
236 236
 			$flights = $parsed_json->{'flightInfo'};
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 				$ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name
240 240
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
241 241
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
242
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
242
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
243 243
 			} else return array();
244 244
 		} else return array();
245 245
 	}
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
 	*/
252 252
 	private function getSwiss($callsign) {
253 253
 		$Common = new Common();
254
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
255
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
254
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
255
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
256 256
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
257 257
 		$json = $Common->getData($url);
258 258
 		$parsed_json = json_decode($json);
@@ -266,12 +266,12 @@  discard block
 block discarded – undo
266 266
 				if ($flight->{'no'} == "Vol LX ".$numvol) {
267 267
 					$DepartureAirportIata = $flight->{'from'}->{'code'}; //city
268 268
 					$ArrivalAirportIata = $flight->{'to'}->{'code'}; //city
269
-					$departureTime = substr($flight->{'from'}->{'hour'},0,5);
270
-					$arrivalTime = substr($flight->{'to'}->{'hour'},0,5);
269
+					$departureTime = substr($flight->{'from'}->{'hour'},0, 5);
270
+					$arrivalTime = substr($flight->{'to'}->{'hour'},0, 5);
271 271
 				}
272 272
 			}
273 273
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
274
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
274
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss');
275 275
 			} else return array();
276 276
 		} else return array();
277 277
 	}
@@ -286,21 +286,21 @@  discard block
 block discarded – undo
286 286
 		global $globalBritishAirwaysKey;
287 287
 		$Common = new Common();
288 288
 		$check_date = new Datetime($date);
289
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
290
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
289
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
290
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
291 291
 		if ($globalBritishAirwaysKey == '') return array();
292 292
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
293 293
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
294
-		$json = $Common->getData($url,'get','',$headers);
294
+		$json = $Common->getData($url, 'get', '', $headers);
295 295
 		if ($json == '') return array();
296 296
 		$parsed_json = json_decode($json);
297 297
 		$flights = $parsed_json->{'FlightsResponse'};
298 298
 		if (count($flights) > 0) {
299 299
 			$DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'};
300 300
 			$ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'};
301
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
302
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
303
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
301
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
302
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
303
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways');
304 304
 		} else return array();
305 305
 	}
306 306
 
@@ -314,27 +314,27 @@  discard block
 block discarded – undo
314 314
 		global $globalLufthansaKey;
315 315
 		$Common = new Common();
316 316
 		$check_date = new Datetime($date);
317
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
318
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
317
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
318
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
319 319
 		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
320 320
 		$url = "https://api.lufthansa.com/v1/oauth/token";
321
-		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
322
-		$data = $Common->getData($url,'post',$post);
321
+		$post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials');
322
+		$data = $Common->getData($url, 'post', $post);
323 323
 		$parsed_data = json_decode($data);
324 324
 		if (!isset($parsed_data->{'access_token'})) return array();
325 325
 		$token = $parsed_data->{'access_token'};
326 326
 		
327 327
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
328
-		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
329
-		$json = $Common->getData($url,'get','',$headers);
328
+		$headers = array('Authorization: Bearer '.$token, 'Accept: application/json');
329
+		$json = $Common->getData($url, 'get', '', $headers);
330 330
 		if ($json == '') return array();
331 331
 		$parsed_json = json_decode($json);
332 332
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
333 333
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
334
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
334
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
335 335
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
336
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
337
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
336
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
337
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa');
338 338
 		} else return array();
339 339
 	}
340 340
 
@@ -348,23 +348,23 @@  discard block
 block discarded – undo
348 348
 		global $globalTransaviaKey;
349 349
 		$Common = new Common();
350 350
 		$check_date = new Datetime($date);
351
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
352
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
351
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
352
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
353 353
 		if ($globalTransaviaKey == '') return array();
354 354
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
355 355
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
356 356
 		$headers = array('apikey: '.$globalTransaviaKey);
357
-		$json = $Common->getData($url,'get','',$headers);
357
+		$json = $Common->getData($url, 'get', '', $headers);
358 358
 		//echo 'result : '.$json;
359 359
 		if ($json == '') return array();
360 360
 		$parsed_json = json_decode($json);
361 361
 		
362 362
 		if (isset($parsed_json->{'data'}[0])) {
363 363
 			$DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'};
364
-			$departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
364
+			$departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
365 365
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
366
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
367
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
366
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
367
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia');
368 368
 		} else return array();
369 369
 	}
370 370
 
@@ -375,14 +375,14 @@  discard block
 block discarded – undo
375 375
 	*/
376 376
 	public function getTunisair($callsign) {
377 377
 		$Common = new Common();
378
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
379
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
378
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
379
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
380 380
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
381 381
 		$data = $Common->getData($url);
382 382
 		$table = $Common->table2array($data);
383 383
 		foreach ($table as $flight) {
384
-			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) {
385
-				return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair');
384
+			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) {
385
+				return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair');
386 386
 			}
387 387
 		}
388 388
 		return array();
@@ -393,21 +393,21 @@  discard block
 block discarded – undo
393 393
 	* @param String $callsign The callsign
394 394
 	* @return Flight departure and arrival airports and time
395 395
 	*/
396
-	public function getVueling($callsign,$date = 'NOW') {
396
+	public function getVueling($callsign, $date = 'NOW') {
397 397
 		$Common = new Common();
398 398
 		$check_date = new Datetime($date);
399
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
400
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
401
-		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
399
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
400
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
401
+		$final_date = str_replace('/', '%2F', $check_date->format('d/m/Y'));
402 402
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
403 403
 		$data = $Common->getData($url);
404
-		$data=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$data));
404
+		$data = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $data));
405 405
 		if ($data != '') {
406
-			preg_match('/flightOri=[A-Z]{3}/',$data,$result);
407
-			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
408
-			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
409
-			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
410
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
406
+			preg_match('/flightOri=[A-Z]{3}/', $data, $result);
407
+			$DepartureAirportIata = str_replace('flightOri=', '', $result[0]);
408
+			preg_match('/flightDest=[A-Z]{3}/', $data, $result);
409
+			$ArrivalAirportIata = str_replace('flightDest=', '', $result[0]);
410
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'Source' => 'website_vueling');
411 411
 			else return array();
412 412
 		}
413 413
 		return array();
@@ -421,27 +421,27 @@  discard block
 block discarded – undo
421 421
 	*/
422 422
 	public function getIberia($callsign, $date = 'NOW') {
423 423
 		$Common = new Common();
424
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
424
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
425 425
 		$check_date = new Datetime($date);
426
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
426
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
427 427
 		$url = "https://www.iberia.com/web/flightDetail.do";
428
-		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
429
-		$data = $Common->getData($url,'post',$post);
428
+		$post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB');
429
+		$data = $Common->getData($url, 'post', $post);
430 430
 		if ($data != '') {
431 431
 			$table = $Common->table2array($data);
432 432
 			//print_r($table);
433 433
 			if (count($table) > 0) {
434 434
 				$flight = $table;
435
-				preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
436
-				preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch);
435
+				preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
436
+				preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch);
437 437
 				$DepartureAirportIata = $DepartureAirportIataMatch[0];
438 438
 				$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
439
-				$departureTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[3][2]))),0,5);
440
-				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
439
+				$departureTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[3][2]))), 0, 5);
440
+				$arrivalTime = trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][1])));
441 441
 				if ($arrivalTime == 'Hora estimada de llegada') {
442
-					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
443
-				} else $arrivalTime = substr($arrivalTime,0,5);
444
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
442
+					$arrivalTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][2]))), 0, 5);
443
+				} else $arrivalTime = substr($arrivalTime, 0, 5);
444
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia');
445 445
 			}
446 446
 		}
447 447
 		return array();
@@ -454,11 +454,11 @@  discard block
 block discarded – undo
454 454
 	* @return Flight departure and arrival airports and time
455 455
 	*/
456 456
 
457
-	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
457
+	private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') {
458 458
 		$Common = new Common();
459
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
459
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
460 460
 		$check_date = new Datetime($date);
461
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
461
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
462 462
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
463 463
 		$data = $Common->getData($url);
464 464
 		if ($data != '') {
@@ -467,13 +467,13 @@  discard block
 block discarded – undo
467 467
 				$flight = $table;
468 468
 				//print_r($table);
469 469
 				if (isset($flight[25]) && isset($flight[29])) {
470
-					preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch);
471
-					preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch);
470
+					preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch);
471
+					preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch);
472 472
 					$DepartureAirportIata = $DepartureAirportIataMatch[0];
473 473
 					$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
474
-					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
475
-					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
476
-					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
474
+					$departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5);
475
+					$arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5);
476
+					return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance');
477 477
 				} else return array();
478 478
 			}
479 479
 			
@@ -491,10 +491,10 @@  discard block
 block discarded – undo
491 491
 	*/
492 492
 	private function getAlitalia($callsign, $date = 'NOW') {
493 493
 		$Common = new Common();
494
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
494
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
495 495
 		$check_date = new Datetime($date);
496
-		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
497
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
496
+		$url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
497
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
498 498
 		$data = $Common->getData($url);
499 499
 		if ($data != '') {
500 500
 			$table = $Common->text2array($data);
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 			$ArrivalAirportIata = '';
503 503
 			$departureTime = $table[4];
504 504
 			$arrivalTime = $table[5];
505
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia');
505
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia');
506 506
 		}
507 507
 	}
508 508
 
@@ -514,21 +514,21 @@  discard block
 block discarded – undo
514 514
 	*/
515 515
 	private function getBrussels($callsign, $date = 'NOW') {
516 516
 		$Common = new Common();
517
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
517
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
518 518
 		$check_date = new Datetime($date);
519
-		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
519
+		$url = "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
520 520
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
521
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
521
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
522 522
 		$data = $Common->getData($url);
523 523
 		if ($data != '') {
524 524
 		    //echo $data;
525
-		    $parsed_json = json_decode($data,true);
525
+		    $parsed_json = json_decode($data, true);
526 526
 		    if (isset($parsed_json[0]['FromAirportCode'])) {
527 527
 			$DepartureAirportIata = $parsed_json[0]['FromAirportCode'];
528 528
 			$ArrivalAirportIata = $parsed_json[0]['ToAirportCode'];
529
-			$departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate']));
530
-			$arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate']));
531
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
529
+			$departureTime = date('H:i', strtotime($parsed_json[0]['ScheduledDepatureDate']));
530
+			$arrivalTime = date('H:i', strtotime($parsed_json[0]['ScheduledArrivalDate']));
531
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels');
532 532
 		    }
533 533
 		}
534 534
 	}
@@ -605,21 +605,21 @@  discard block
 block discarded – undo
605 605
 	*/
606 606
 	private function getFlyTap($callsign) {
607 607
 		$Common = new Common();
608
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
609
-		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
608
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
609
+		$url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
610 610
 		//$check_date = new Datetime($date);
611
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
612
-		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
613
-		$data = $Common->getData($url,'post',$post);
611
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
612
+		$post = array('arrivalsdepartures_content' => 'number', 'arrivalsdepartures_tp' => $numvol, 'arrivalsdepartures_trk' => 'ARR', 'arrivalsdepartures_date_trk' => '1', 'aptCode' => '', 'arrivalsdepartures' => 'DEP', 'arrivalsdepartures_date' => '1', 'aptCodeFrom' => '', 'aptCodeTo' => '', 'arrivalsdepartures2' => 'DEP', 'arrivalsdepartures_date2' => '1');
613
+		$data = $Common->getData($url, 'post', $post);
614 614
 		if ($data != '') {
615 615
 			$table = $Common->table2array($data);
616
-			$departureTime = trim(substr($table[15][0],0,5));
617
-			$arrivalTime = trim(substr($table[35][0],0,5));
618
-			preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch);
619
-			preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch);
616
+			$departureTime = trim(substr($table[15][0], 0, 5));
617
+			$arrivalTime = trim(substr($table[35][0], 0, 5));
618
+			preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch);
619
+			preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch);
620 620
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
621 621
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
622
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap');
622
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap');
623 623
 		}
624 624
 		return array();
625 625
 	}
@@ -641,10 +641,10 @@  discard block
 block discarded – undo
641 641
 			} 
642 642
 		}
643 643
 		if ($airline_icao == '') return array();
644
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
645
-		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
644
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
645
+		$url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
646 646
 		//$check_date = new Datetime($date);
647
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
647
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
648 648
 		$data = $Common->getData($url);
649 649
 		if ($data != '') {
650 650
 			$table = $Common->table2array($data);
@@ -654,13 +654,13 @@  discard block
 block discarded – undo
654 654
 				$darr = '';
655 655
 				$ahour = '';
656 656
 				$aarr = '';
657
-				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
657
+				$n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr);
658 658
 				if ($n == 7) {
659 659
 				    $departureTime = $dhour;
660 660
 				    $arrivalTime = $ahour;
661
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
662
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
663
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
661
+				    $DepartureAirportIata = str_replace(array('(', ')'), '', $darr);
662
+				    $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr);
663
+				    return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper');
664 664
 				}
665 665
 			}
666 666
 		}
@@ -684,20 +684,20 @@  discard block
 block discarded – undo
684 684
 			} 
685 685
 		}
686 686
 		*/
687
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
688
-		$url= "http://fr.flightaware.com/live/flight/".$callsign;
687
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
688
+		$url = "http://fr.flightaware.com/live/flight/".$callsign;
689 689
 		//$check_date = new Datetime($date);
690
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
690
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
691 691
 		$data = $Common->getData($url);
692 692
 		if ($data != '') {
693 693
 			$table = $Common->table2array($data);
694 694
 			if (isset($table[11][0])) {
695
-				$departureTime = str_replace('h',':',substr($table[5][0],0,5));
696
-				$arrivalTime = str_replace('h',':',substr($table[5][1],0,5));
695
+				$departureTime = str_replace('h', ':', substr($table[5][0], 0, 5));
696
+				$arrivalTime = str_replace('h', ':', substr($table[5][1], 0, 5));
697 697
 				echo $table[3][0];
698
-				sscanf($table[3][0],'%*[^(] (%3[A-Z] / %*4[A-Z])',$DepartureAirportIata);
699
-				sscanf($table[3][1],'%*[^(] (%3[A-Z] / %*4[A-Z])',$ArrivalAirportIata);
700
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightaware');
698
+				sscanf($table[3][0], '%*[^(] (%3[A-Z] / %*4[A-Z])', $DepartureAirportIata);
699
+				sscanf($table[3][1], '%*[^(] (%3[A-Z] / %*4[A-Z])', $ArrivalAirportIata);
700
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightaware');
701 701
 			}
702 702
 		}
703 703
 		return array();
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 	*/
711 711
 	public function getCostToTravel($callsign) {
712 712
 		$Common = new Common();
713
-		$url= "http://www.costtotravel.com/flight-number/".$callsign;
713
+		$url = "http://www.costtotravel.com/flight-number/".$callsign;
714 714
 		//$check_date = new Datetime($date);
715 715
 		//if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
716 716
 		$data = $Common->getData($url);
@@ -718,11 +718,11 @@  discard block
 block discarded – undo
718 718
 			$table = $Common->table2array($data);
719 719
 			//print_r($table);
720 720
 			if (isset($table[11][1])) {
721
-				$departureTime = substr($table[11][1],0,5);
722
-				$arrivalTime = substr($table[17][1],0,5);
723
-				$DepartureAirportIata = substr($table[13][1],0,3);
724
-				$ArrivalAirportIata = substr($table[15][1],0,3);
725
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
721
+				$departureTime = substr($table[11][1], 0, 5);
722
+				$arrivalTime = substr($table[17][1], 0, 5);
723
+				$DepartureAirportIata = substr($table[13][1], 0, 3);
724
+				$ArrivalAirportIata = substr($table[15][1], 0, 3);
725
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel');
726 726
 			}
727 727
 		}
728 728
 		return array();
@@ -734,14 +734,14 @@  discard block
 block discarded – undo
734 734
 	* @param String $date date we want flight number info
735 735
 	* @return Flight departure and arrival airports and time
736 736
 	*/
737
-	private function getAirCanada($callsign,$date = 'NOW') {
737
+	private function getAirCanada($callsign, $date = 'NOW') {
738 738
 		$Common = new Common();
739 739
 		if (class_exists("DomDocument") === FALSE) return array();
740 740
 		date_default_timezone_set('UTC');
741 741
 		$check_date = new Datetime($date);
742
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
743
-		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
744
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
742
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
743
+		$url = "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
744
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
745 745
 		$data = $Common->getData($url);
746 746
 		$dom = new DomDocument();
747 747
 		$dom->loadXML($data);
@@ -749,11 +749,11 @@  discard block
 block discarded – undo
749 749
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
750 750
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
751 751
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
752
-			$departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
752
+			$departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
753 753
 			$arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0);
754 754
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
755
-			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
756
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
755
+			$arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
756
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada');
757 757
 		} else return array();
758 758
 	}
759 759
 
@@ -765,21 +765,21 @@  discard block
 block discarded – undo
765 765
 	*/
766 766
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
767 767
 		$Common = new Common();
768
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
768
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
769 769
 		$check_date = new Datetime($date);
770
-		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
771
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
770
+		$url = "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
771
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
772 772
 		$data = $Common->getData($url);
773 773
 		if ($data != '') {
774 774
 			$table = $Common->table2array($data);
775 775
 			$flight = $table;
776
-			preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
777
-			preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch);
776
+			preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
777
+			preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch);
778 778
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
779 779
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
780 780
 			$departureTime = $flight[5][1];
781 781
 			$arrivalTime = $flight[23][1];
782
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines');
782
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines');
783 783
 		}
784 784
 	}
785 785
 
@@ -790,16 +790,16 @@  discard block
 block discarded – undo
790 790
 	* @param String $carrier airline code
791 791
 	* @return Flight departure and arrival airports and time
792 792
 	*/
793
-	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
793
+	private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') {
794 794
 		$Common = new Common();
795 795
 		date_default_timezone_set('UTC');
796 796
 		//AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair 
797
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
797
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
798 798
 		$check_date = new Datetime($date);
799
-		$url= "http://www.airberlin.com/en-US/site/aims.php";
800
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
801
-		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
802
-		$data = $Common->getData($url,'post',$post);
799
+		$url = "http://www.airberlin.com/en-US/site/aims.php";
800
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
801
+		$post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => $carrier);
802
+		$data = $Common->getData($url, 'post', $post);
803 803
 		//echo $data;
804 804
 		$DepartureAirportIata = '';
805 805
 		$ArrivalAirportIata = '';
@@ -812,8 +812,8 @@  discard block
 block discarded – undo
812 812
 			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
813 813
 			else $departureAirport = '';
814 814
 		} else return array();
815
-		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
816
-		$data = $Common->getData($url,'post',$post);
815
+		$post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB');
816
+		$data = $Common->getData($url, 'post', $post);
817 817
 		if ($data != '') {
818 818
 			$table = $Common->table2array($data);
819 819
 			$flight = $table;
@@ -841,13 +841,13 @@  discard block
 block discarded – undo
841 841
 			}
842 842
 		}
843 843
 		if (isset($DepartureAirportIata)) {
844
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
844
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin');
845 845
 		} else return array();
846 846
 	}
847 847
 
848 848
 
849 849
 	
850
-	public function fetchSchedule($ident,$date = 'NOW') {
850
+	public function fetchSchedule($ident, $date = 'NOW') {
851 851
 		global $globalSchedulesSources, $globalSchedulesFetch;
852 852
 		//$Common = new Common();
853 853
 		if (!$globalSchedulesFetch) return array();
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
 				// Brussels Airlines
918 918
 				case "BEL":
919 919
 				case "SN":
920
-					return $this->getBrussels($ident,$date);
920
+					return $this->getBrussels($ident, $date);
921 921
 /*
922 922
 				// Copa Airlines
923 923
 				case "CMP":
@@ -1002,17 +1002,17 @@  discard block
 block discarded – undo
1002 1002
 				// Air France
1003 1003
 				case "AF":
1004 1004
 				case "AFR":
1005
-					return $this->getAirFrance($ident,$date,'AF');
1005
+					return $this->getAirFrance($ident, $date, 'AF');
1006 1006
 				// HOP
1007 1007
 				case "A5":
1008 1008
 				case "HOP":
1009
-					return $this->getAirFrance($ident,$date,'A5');
1009
+					return $this->getAirFrance($ident, $date, 'A5');
1010 1010
 				// EasyJet
1011 1011
 				case "U2":
1012 1012
 				case "DS":
1013 1013
 				case "EZY":
1014 1014
 				case "EZS":
1015
-					return $this->getEasyJet($ident,$date);
1015
+					return $this->getEasyJet($ident, $date);
1016 1016
 				// Ryanair
1017 1017
 				case "FR":
1018 1018
 				case "RYR":
@@ -1062,25 +1062,25 @@  discard block
 block discarded – undo
1062 1062
 					return $this->getIberia($ident);
1063 1063
 				// Vietnam Airlines
1064 1064
 				case "HVN":
1065
-					return $this->getVietnamAirlines($ident,$date);
1065
+					return $this->getVietnamAirlines($ident, $date);
1066 1066
 				// Air Berlin
1067 1067
 				case "AB":
1068 1068
 				case "BER":
1069
-					return $this->getAirBerlin($ident,$date,'AB');
1069
+					return $this->getAirBerlin($ident, $date, 'AB');
1070 1070
 				// NIKI
1071 1071
 				case "HG":
1072 1072
 				case "NLY":
1073
-					return $this->getAirBerlin($ident,$date,'HG');
1073
+					return $this->getAirBerlin($ident, $date, 'HG');
1074 1074
 				// BelAir
1075 1075
 				case "4T":
1076 1076
 				case "BHP":
1077
-					return $this->getAirBerlin($ident,$date,'4T');
1077
+					return $this->getAirBerlin($ident, $date, '4T');
1078 1078
 				default:
1079 1079
 					// Randomly use a generic function to get hours
1080 1080
 					if (strlen($airline_icao) == 2) {
1081
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1081
+						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1082 1082
 						if (count($globalSchedulesSources) > 0) {
1083
-							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1083
+							$rand = mt_rand(0, count($globalSchedulesSources) - 1);
1084 1084
 							$source = $globalSchedulesSources[$rand];
1085 1085
 							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1086 1086
 							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
Please login to merge, or discard this patch.
Braces   +170 added lines, -58 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 	public function __construct($dbc = null) {
13 13
 		$Connection = new Connection($dbc);
14 14
 		$this->db = $Connection->db();
15
-		if ($this->db === null) die('Error: No DB connection.');
15
+		if ($this->db === null) {
16
+			die('Error: No DB connection.');
17
+		}
16 18
 	}
17 19
 	
18 20
 	/**
@@ -124,7 +126,9 @@  discard block
 block discarded – undo
124 126
 		$sth->closeCursor();
125 127
 		if (count($row) > 0) {
126 128
 			return $row;
127
-		} else return array();
129
+		} else {
130
+			return array();
131
+		}
128 132
 	}
129 133
 
130 134
 	public function checkSchedule($ident) {
@@ -160,7 +164,9 @@  discard block
 block discarded – undo
160 164
 		$Common = new Common();
161 165
 		$check_date = new Datetime($date);
162 166
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
163
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
167
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
168
+			return array();
169
+		}
164 170
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
165 171
 		$json = $Common->getData($url);
166 172
 	
@@ -187,7 +193,9 @@  discard block
 block discarded – undo
187 193
 			*/
188 194
 		
189 195
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
190
-		} else return array();
196
+		} else {
197
+			return array();
198
+		}
191 199
 	}
192 200
 
193 201
 	/**
@@ -202,7 +210,9 @@  discard block
 block discarded – undo
202 210
 		date_default_timezone_set($globalTimezone);
203 211
 		$check_date = new Datetime($date);
204 212
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
205
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
213
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
214
+			return array();
215
+		}
206 216
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
207 217
 		$json = $Common->getData($url);
208 218
 		$parsed_json = json_decode($json);
@@ -215,7 +225,9 @@  discard block
 block discarded – undo
215 225
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
216 226
 
217 227
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
218
-		} else return array();
228
+		} else {
229
+			return array();
230
+		}
219 231
 	}
220 232
 
221 233
 	/**
@@ -226,7 +238,9 @@  discard block
 block discarded – undo
226 238
 	private function getRyanair($callsign) {
227 239
 		$Common = new Common();
228 240
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
229
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
241
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
242
+			return array();
243
+		}
230 244
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
231 245
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
232 246
 		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
@@ -240,8 +254,12 @@  discard block
 block discarded – undo
240 254
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
241 255
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
242 256
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
243
-			} else return array();
244
-		} else return array();
257
+			} else {
258
+				return array();
259
+			}
260
+		} else {
261
+			return array();
262
+		}
245 263
 	}
246 264
 
247 265
 	/**
@@ -252,7 +270,9 @@  discard block
 block discarded – undo
252 270
 	private function getSwiss($callsign) {
253 271
 		$Common = new Common();
254 272
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
255
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
273
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
274
+			return array();
275
+		}
256 276
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
257 277
 		$json = $Common->getData($url);
258 278
 		$parsed_json = json_decode($json);
@@ -272,8 +292,12 @@  discard block
 block discarded – undo
272 292
 			}
273 293
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
274 294
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
275
-			} else return array();
276
-		} else return array();
295
+			} else {
296
+				return array();
297
+			}
298
+		} else {
299
+			return array();
300
+		}
277 301
 	}
278 302
 	
279 303
 	/**
@@ -287,12 +311,18 @@  discard block
 block discarded – undo
287 311
 		$Common = new Common();
288 312
 		$check_date = new Datetime($date);
289 313
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
290
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
291
-		if ($globalBritishAirwaysKey == '') return array();
314
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
315
+			return array();
316
+		}
317
+		if ($globalBritishAirwaysKey == '') {
318
+			return array();
319
+		}
292 320
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
293 321
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
294 322
 		$json = $Common->getData($url,'get','',$headers);
295
-		if ($json == '') return array();
323
+		if ($json == '') {
324
+			return array();
325
+		}
296 326
 		$parsed_json = json_decode($json);
297 327
 		$flights = $parsed_json->{'FlightsResponse'};
298 328
 		if (count($flights) > 0) {
@@ -301,7 +331,9 @@  discard block
 block discarded – undo
301 331
 			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
302 332
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
303 333
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
304
-		} else return array();
334
+		} else {
335
+			return array();
336
+		}
305 337
 	}
306 338
 
307 339
 	/**
@@ -315,19 +347,27 @@  discard block
 block discarded – undo
315 347
 		$Common = new Common();
316 348
 		$check_date = new Datetime($date);
317 349
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
318
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
319
-		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
350
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
351
+			return array();
352
+		}
353
+		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') {
354
+			return array();
355
+		}
320 356
 		$url = "https://api.lufthansa.com/v1/oauth/token";
321 357
 		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
322 358
 		$data = $Common->getData($url,'post',$post);
323 359
 		$parsed_data = json_decode($data);
324
-		if (!isset($parsed_data->{'access_token'})) return array();
360
+		if (!isset($parsed_data->{'access_token'})) {
361
+			return array();
362
+		}
325 363
 		$token = $parsed_data->{'access_token'};
326 364
 		
327 365
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
328 366
 		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
329 367
 		$json = $Common->getData($url,'get','',$headers);
330
-		if ($json == '') return array();
368
+		if ($json == '') {
369
+			return array();
370
+		}
331 371
 		$parsed_json = json_decode($json);
332 372
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
333 373
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
@@ -335,7 +375,9 @@  discard block
 block discarded – undo
335 375
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
336 376
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
337 377
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
338
-		} else return array();
378
+		} else {
379
+			return array();
380
+		}
339 381
 	}
340 382
 
341 383
 	/**
@@ -349,14 +391,20 @@  discard block
 block discarded – undo
349 391
 		$Common = new Common();
350 392
 		$check_date = new Datetime($date);
351 393
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
352
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
353
-		if ($globalTransaviaKey == '') return array();
394
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
395
+			return array();
396
+		}
397
+		if ($globalTransaviaKey == '') {
398
+			return array();
399
+		}
354 400
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
355 401
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
356 402
 		$headers = array('apikey: '.$globalTransaviaKey);
357 403
 		$json = $Common->getData($url,'get','',$headers);
358 404
 		//echo 'result : '.$json;
359
-		if ($json == '') return array();
405
+		if ($json == '') {
406
+			return array();
407
+		}
360 408
 		$parsed_json = json_decode($json);
361 409
 		
362 410
 		if (isset($parsed_json->{'data'}[0])) {
@@ -365,7 +413,9 @@  discard block
 block discarded – undo
365 413
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
366 414
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
367 415
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
368
-		} else return array();
416
+		} else {
417
+			return array();
418
+		}
369 419
 	}
370 420
 
371 421
 	/**
@@ -376,7 +426,9 @@  discard block
 block discarded – undo
376 426
 	public function getTunisair($callsign) {
377 427
 		$Common = new Common();
378 428
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
379
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
429
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
430
+			return array();
431
+		}
380 432
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
381 433
 		$data = $Common->getData($url);
382 434
 		$table = $Common->table2array($data);
@@ -397,7 +449,9 @@  discard block
 block discarded – undo
397 449
 		$Common = new Common();
398 450
 		$check_date = new Datetime($date);
399 451
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
400
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
452
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
453
+			return array();
454
+		}
401 455
 		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
402 456
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
403 457
 		$data = $Common->getData($url);
@@ -407,8 +461,11 @@  discard block
 block discarded – undo
407 461
 			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
408 462
 			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
409 463
 			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
410
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
411
-			else return array();
464
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') {
465
+				return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
466
+			} else {
467
+				return array();
468
+			}
412 469
 		}
413 470
 		return array();
414 471
 	}
@@ -423,7 +480,9 @@  discard block
 block discarded – undo
423 480
 		$Common = new Common();
424 481
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
425 482
 		$check_date = new Datetime($date);
426
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
483
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
484
+			return array();
485
+		}
427 486
 		$url = "https://www.iberia.com/web/flightDetail.do";
428 487
 		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
429 488
 		$data = $Common->getData($url,'post',$post);
@@ -440,7 +499,9 @@  discard block
 block discarded – undo
440 499
 				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
441 500
 				if ($arrivalTime == 'Hora estimada de llegada') {
442 501
 					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
443
-				} else $arrivalTime = substr($arrivalTime,0,5);
502
+				} else {
503
+					$arrivalTime = substr($arrivalTime,0,5);
504
+				}
444 505
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
445 506
 			}
446 507
 		}
@@ -458,7 +519,9 @@  discard block
 block discarded – undo
458 519
 		$Common = new Common();
459 520
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
460 521
 		$check_date = new Datetime($date);
461
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
522
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
523
+			return array();
524
+		}
462 525
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
463 526
 		$data = $Common->getData($url);
464 527
 		if ($data != '') {
@@ -474,7 +537,9 @@  discard block
 block discarded – undo
474 537
 					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
475 538
 					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
476 539
 					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
477
-				} else return array();
540
+				} else {
541
+					return array();
542
+				}
478 543
 			}
479 544
 			
480 545
 
@@ -494,7 +559,9 @@  discard block
 block discarded – undo
494 559
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
495 560
 		$check_date = new Datetime($date);
496 561
 		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
497
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
562
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
563
+			return array();
564
+		}
498 565
 		$data = $Common->getData($url);
499 566
 		if ($data != '') {
500 567
 			$table = $Common->text2array($data);
@@ -518,7 +585,9 @@  discard block
 block discarded – undo
518 585
 		$check_date = new Datetime($date);
519 586
 		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
520 587
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
521
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
588
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
589
+			return array();
590
+		}
522 591
 		$data = $Common->getData($url);
523 592
 		if ($data != '') {
524 593
 		    //echo $data;
@@ -608,7 +677,9 @@  discard block
 block discarded – undo
608 677
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
609 678
 		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
610 679
 		//$check_date = new Datetime($date);
611
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
680
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
681
+			return array();
682
+		}
612 683
 		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
613 684
 		$data = $Common->getData($url,'post',$post);
614 685
 		if ($data != '') {
@@ -640,11 +711,15 @@  discard block
 block discarded – undo
640 711
 				$airline_icao = substr($callsign, 0, 3);
641 712
 			} 
642 713
 		}
643
-		if ($airline_icao == '') return array();
714
+		if ($airline_icao == '') {
715
+			return array();
716
+		}
644 717
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
645 718
 		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
646 719
 		//$check_date = new Datetime($date);
647
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
720
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
721
+			return array();
722
+		}
648 723
 		$data = $Common->getData($url);
649 724
 		if ($data != '') {
650 725
 			$table = $Common->table2array($data);
@@ -687,7 +762,9 @@  discard block
 block discarded – undo
687 762
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
688 763
 		$url= "http://fr.flightaware.com/live/flight/".$callsign;
689 764
 		//$check_date = new Datetime($date);
690
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
765
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
766
+			return array();
767
+		}
691 768
 		$data = $Common->getData($url);
692 769
 		if ($data != '') {
693 770
 			$table = $Common->table2array($data);
@@ -736,16 +813,22 @@  discard block
 block discarded – undo
736 813
 	*/
737 814
 	private function getAirCanada($callsign,$date = 'NOW') {
738 815
 		$Common = new Common();
739
-		if (class_exists("DomDocument") === FALSE) return array();
816
+		if (class_exists("DomDocument") === FALSE) {
817
+			return array();
818
+		}
740 819
 		date_default_timezone_set('UTC');
741 820
 		$check_date = new Datetime($date);
742 821
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
743 822
 		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
744
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
823
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
824
+			return array();
825
+		}
745 826
 		$data = $Common->getData($url);
746 827
 		$dom = new DomDocument();
747 828
 		$dom->loadXML($data);
748
-		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array();
829
+		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) {
830
+			return array();
831
+		}
749 832
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
750 833
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
751 834
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
@@ -754,7 +837,9 @@  discard block
 block discarded – undo
754 837
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
755 838
 			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
756 839
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
757
-		} else return array();
840
+		} else {
841
+			return array();
842
+		}
758 843
 	}
759 844
 
760 845
 	/**
@@ -768,7 +853,9 @@  discard block
 block discarded – undo
768 853
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
769 854
 		$check_date = new Datetime($date);
770 855
 		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
771
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
856
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
857
+			return array();
858
+		}
772 859
 		$data = $Common->getData($url);
773 860
 		if ($data != '') {
774 861
 			$table = $Common->table2array($data);
@@ -797,7 +884,9 @@  discard block
 block discarded – undo
797 884
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
798 885
 		$check_date = new Datetime($date);
799 886
 		$url= "http://www.airberlin.com/en-US/site/aims.php";
800
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
887
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
888
+			return array();
889
+		}
801 890
 		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
802 891
 		$data = $Common->getData($url,'post',$post);
803 892
 		//echo $data;
@@ -807,11 +896,19 @@  discard block
 block discarded – undo
807 896
 		if ($data != '') {
808 897
 			$table = $Common->table2array($data);
809 898
 			$flight = $table;
810
-			if (isset($flight[5][4])) $departureTime = $flight[5][4];
811
-			else $departureTime = '';
812
-			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
813
-			else $departureAirport = '';
814
-		} else return array();
899
+			if (isset($flight[5][4])) {
900
+				$departureTime = $flight[5][4];
901
+			} else {
902
+				$departureTime = '';
903
+			}
904
+			if (isset($flight[5][2])) {
905
+				$departureAirport = $flight[5][2];
906
+			} else {
907
+				$departureAirport = '';
908
+			}
909
+		} else {
910
+			return array();
911
+		}
815 912
 		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
816 913
 		$data = $Common->getData($url,'post',$post);
817 914
 		if ($data != '') {
@@ -824,10 +921,14 @@  discard block
 block discarded – undo
824 921
 			    $arrivalTime = '';
825 922
 			    $arrivalAirport = '';
826 923
 			}
827
-		} else return array();
924
+		} else {
925
+			return array();
926
+		}
828 927
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
829 928
 		$json = $Common->getData($url);
830
-		if ($json == '') return array();
929
+		if ($json == '') {
930
+			return array();
931
+		}
831 932
 		$parsed_json = json_decode($json);
832 933
 		$airports = $parsed_json->{'suggestList'};
833 934
 		if (count($airports) > 0) {
@@ -842,7 +943,9 @@  discard block
 block discarded – undo
842 943
 		}
843 944
 		if (isset($DepartureAirportIata)) {
844 945
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
845
-		} else return array();
946
+		} else {
947
+			return array();
948
+		}
846 949
 	}
847 950
 
848 951
 
@@ -850,7 +953,9 @@  discard block
 block discarded – undo
850 953
 	public function fetchSchedule($ident,$date = 'NOW') {
851 954
 		global $globalSchedulesSources, $globalSchedulesFetch;
852 955
 		//$Common = new Common();
853
-		if (!$globalSchedulesFetch) return array();
956
+		if (!$globalSchedulesFetch) {
957
+			return array();
958
+		}
854 959
 		$airline_icao = '';
855 960
 		if (!is_numeric(substr($ident, 0, 3)))
856 961
 		{
@@ -1078,14 +1183,21 @@  discard block
 block discarded – undo
1078 1183
 				default:
1079 1184
 					// Randomly use a generic function to get hours
1080 1185
 					if (strlen($airline_icao) == 2) {
1081
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1186
+						if (!isset($globalSchedulesSources)) {
1187
+							$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1188
+						}
1082 1189
 						if (count($globalSchedulesSources) > 0) {
1083 1190
 							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1084 1191
 							$source = $globalSchedulesSources[$rand];
1085
-							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1086
-							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
1192
+							if ($source == 'flightmapper') {
1193
+								return $this->getFlightMapper($ident);
1194
+							} elseif ($source == 'costtotravel') {
1195
+								return $this->getCostToTravel($ident);
1196
+							}
1087 1197
 							//elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date);
1088
-							elseif ($source == 'flightaware') return $this->getFlightAware($ident);
1198
+							elseif ($source == 'flightaware') {
1199
+								return $this->getFlightAware($ident);
1200
+							}
1089 1201
 						}
1090 1202
 					}
1091 1203
 			}
Please login to merge, or discard this patch.