Completed
Push — master ( e02292...8795ac )
by Yannick
09:22 queued 02:55
created
upcoming.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
 require_once('header.php');
8 8
 
9 9
 //calculuation for the pagination
10
-if(!isset($_GET['limit']))
10
+if (!isset($_GET['limit']))
11 11
 {
12 12
 	$limit_start = 0;
13 13
 	$limit_end = 25;
14 14
 	$absolute_difference = 25;
15
-}  else {
15
+} else {
16 16
 	$limit_explode = explode(",", $_GET['limit']);
17 17
 	$limit_start = $limit_explode[0];
18 18
 	$limit_end = $limit_explode[1];
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 print '<div class="table column">';	
36 36
 print '<p>'._("This page shows all upcoming flights within the next 3 hours calculated using historical data, based on the number of same flights on the current day of the week &amp; current time. This does not take into account real-time delays and other factors.").'</p>';
37 37
 
38
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
38
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
39 39
 if ($sort != '') {
40 40
 	$spotter_array = $Spotter->getUpcomingFlights($limit_start.",".$absolute_difference, $sort);
41 41
 } else {
Please login to merge, or discard this patch.
aircraft-detailed.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,16 +5,16 @@  discard block
 block discarded – undo
5 5
 require_once('require/class.Language.php');
6 6
 $Spotter = new Spotter();
7 7
 
8
-if (!isset($_GET['aircraft_type'])){
8
+if (!isset($_GET['aircraft_type'])) {
9 9
 	header('Location: '.$globalURL.'/aircraft');
10 10
 } else {
11 11
 	//calculuation for the pagination
12
-	if(!isset($_GET['limit']) || count(explode(",", $_GET['limit'])) < 2)
12
+	if (!isset($_GET['limit']) || count(explode(",", $_GET['limit'])) < 2)
13 13
 	{
14 14
 		$limit_start = 0;
15 15
 		$limit_end = 25;
16 16
 		$absolute_difference = 25;
17
-	}  else {
17
+	} else {
18 18
 		$limit_explode = explode(",", $_GET['limit']);
19 19
 		$limit_start = $limit_explode[0];
20 20
 		$limit_end = $limit_explode[1];
@@ -28,15 +28,15 @@  discard block
 block discarded – undo
28 28
 	$limit_previous_1 = $limit_start - $absolute_difference;
29 29
 	$limit_previous_2 = $limit_end - $absolute_difference;
30 30
 	
31
-	$aircraft_type = filter_input(INPUT_GET,'aircraft_type',FILTER_SANITIZE_STRING);
31
+	$aircraft_type = filter_input(INPUT_GET, 'aircraft_type', FILTER_SANITIZE_STRING);
32 32
 	$page_url = $globalURL.'/aircraft/'.$aircraft_type;
33 33
 	
34
-	$sort = htmlspecialchars(filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING));
35
-	$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type,$limit_start.",".$absolute_difference, $sort);
34
+	$sort = htmlspecialchars(filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING));
35
+	$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type, $limit_start.",".$absolute_difference, $sort);
36 36
 	
37 37
 	if (!empty($spotter_array))
38 38
 	{
39
-		$title = sprintf(_("Detailed View for %s (%s)"),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']);
39
+		$title = sprintf(_("Detailed View for %s (%s)"), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']);
40 40
 		require_once('header.php');
41 41
 	    
42 42
 		print '<div class="select-item">';
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
     		$Stats = new Stats();
47 47
 		$aircraft_types = $Stats->getAllAircraftTypes();
48 48
 		if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes();
49
-		foreach($aircraft_types as $aircrafttype)
49
+		foreach ($aircraft_types as $aircrafttype)
50 50
 		{
51
-			if($aircraft_type == $aircrafttype['aircraft_icao'])
51
+			if ($aircraft_type == $aircrafttype['aircraft_icao'])
52 52
 			{
53 53
 				print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_manufacturer'].' '.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>';
54 54
 			} else {
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 		include('aircraft-sub-menu.php');
76 76
 	        
77 77
 		print '<div class="table column">';
78
-		print '<p>'.sprintf(_("The table below shows the detailed information of all flights from <strong>%s (%s)</strong>."),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']).'</p>';
78
+		print '<p>'.sprintf(_("The table below shows the detailed information of all flights from <strong>%s (%s)</strong>."), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']).'</p>';
79 79
 		  
80 80
 		include('table-output.php');
81 81
 		  
Please login to merge, or discard this patch.
country-detailed.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,17 +3,17 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 
6
-if (!isset($_GET['country'])){
6
+if (!isset($_GET['country'])) {
7 7
 	header('Location: '.$globalURL.'');
8 8
 } else {
9 9
 	$Spotter = new Spotter();
10 10
 	//calculuation for the pagination
11
-	if(!isset($_GET['limit']))
11
+	if (!isset($_GET['limit']))
12 12
 	{
13 13
 	  $limit_start = 0;
14 14
 	  $limit_end = 25;
15 15
 	  $absolute_difference = 25;
16
-	}  else {
16
+	} else {
17 17
 		$limit_explode = explode(",", $_GET['limit']);
18 18
 		$limit_start = $limit_explode[0];
19 19
 		$limit_end = $limit_explode[1];
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	$country = ucwords(str_replace("-", " ", $_GET['country']));
31 31
 	
32 32
 	$page_url = $globalURL.'/country/'.$_GET['country'];
33
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
33
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
34 34
 	if ($sort != '') {
35 35
 		$spotter_array = $Spotter->getSpotterDataByCountry($country, $limit_start.",".$absolute_difference, $sort);
36 36
 	} else {
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
 	if (!empty($spotter_array))
41 41
 	{
42
-		$title = sprintf(_("Detailed View for Airports &amp; Airlines from %s"),$country);
42
+		$title = sprintf(_("Detailed View for Airports &amp; Airlines from %s"), $country);
43 43
 
44 44
 		require_once('header.php');
45 45
 		print '<div class="select-item">';
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
 		print '<select name="country" class="selectpicker" data-live-search="true">';
48 48
 		print '<option></option>';
49 49
 		$all_countries = $Spotter->getAllCountries();
50
-		foreach($all_countries as $all_country)
50
+		foreach ($all_countries as $all_country)
51 51
 		{
52
-			if($country == $all_country['country'])
52
+			if ($country == $all_country['country'])
53 53
 			{
54 54
 				print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'" selected="selected">'.$all_country['country'].'</option>';
55 55
 			} else {
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 		if ($_GET['country'] != "NA")
65 65
 		{
66 66
 			print '<div class="info column">';
67
-			print '<h1>'.sprintf(_("Airports &amp; Airlines from %s"),$country).'</h1>';
67
+			print '<h1>'.sprintf(_("Airports &amp; Airlines from %s"), $country).'</h1>';
68 68
 			print '</div>';
69 69
 		} else {
70 70
 			print '<div class="alert alert-warning">'._("This special country profile shows all flights that do <u>not</u> have a country of a airline or departure/arrival airport associated with them.").'</div>';
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 		include('country-sub-menu.php');
74 74
 		print '<div class="table column">';
75
-		print '<p>'.sprintf(_("The table below shows the detailed information of all flights of airports (both departure &amp; arrival) OR airlines from <strong>%s</strong>."),$country).'</p>';
75
+		print '<p>'.sprintf(_("The table below shows the detailed information of all flights of airports (both departure &amp; arrival) OR airlines from <strong>%s</strong>."), $country).'</p>';
76 76
 
77 77
 		include('table-output.php');
78 78
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
require/class.ATC.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -15,22 +15,22 @@  discard block
 block discarded – undo
15 15
     * @param Array $filter the filter
16 16
     * @return Array the SQL part
17 17
     */
18
-    public function getFilter($filter = array(),$where = false,$and = false) {
18
+    public function getFilter($filter = array(), $where = false, $and = false) {
19 19
 	global $globalFilter, $globalStatsFilters, $globalFilterName;
20 20
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 21
 	    if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22
-		foreach($globalStatsFilters[$globalFilterName] as $source) {
22
+		foreach ($globalStatsFilters[$globalFilterName] as $source) {
23 23
 			if (isset($source['source'])) $filter['source'][] = $source['source'];
24 24
 		}
25 25
 	    } else {
26 26
 		$filter = $globalStatsFilters[$globalFilterName];
27 27
 	    }
28 28
 	}
29
-	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+	if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
30 30
 	$filter_query_join = '';
31 31
 	$filter_query_where = '';
32 32
 	if (isset($filter['source']) && !empty($filter['source'])) {
33
-	    $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
33
+	    $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')";
34 34
 	}
35 35
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
36 36
 	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
@@ -45,25 +45,25 @@  discard block
 block discarded – undo
45 45
                  try {
46 46
                         $sth = $this->db->prepare($query);
47 47
                         $sth->execute($query_values);
48
-                } catch(PDOException $e) {
48
+                } catch (PDOException $e) {
49 49
                         return "error : ".$e->getMessage();
50 50
                 }
51 51
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
52 52
                 return $all;
53 53
         }
54 54
 
55
-       public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') {
56
-    		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
57
-    		$info = str_replace('^','<br />',$info);
58
-    		$info = str_replace('&amp;sect;','',$info);
59
-    		$info = str_replace('"','',$info);
55
+       public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') {
56
+    		$info = preg_replace('/[^(\x20-\x7F)]*/', '', $info);
57
+    		$info = str_replace('^', '<br />', $info);
58
+    		$info = str_replace('&amp;sect;', '', $info);
59
+    		$info = str_replace('"', '', $info);
60 60
     		if ($type == '') $type = NULL;
61 61
                 $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)";
62
-                $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
62
+                $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name);
63 63
                  try {
64 64
                         $sth = $this->db->prepare($query);
65 65
                         $sth->execute($query_values);
66
-                } catch(PDOException $e) {
66
+                } catch (PDOException $e) {
67 67
                         return "error : ".$e->getMessage();
68 68
                 }
69 69
         }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
                  try {
75 75
                         $sth = $this->db->prepare($query);
76 76
                         $sth->execute($query_values);
77
-                } catch(PDOException $e) {
77
+                } catch (PDOException $e) {
78 78
                         return "error : ".$e->getMessage();
79 79
                 }
80 80
         }
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
                  try {
86 86
                         $sth = $this->db->prepare($query);
87 87
                         $sth->execute($query_values);
88
-                } catch(PDOException $e) {
88
+                } catch (PDOException $e) {
89 89
                         return "error : ".$e->getMessage();
90 90
                 }
91 91
         }
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
                 try {
101 101
                         $sth = $this->db->prepare($query);
102 102
                         $sth->execute();
103
-                } catch(PDOException $e) {
103
+                } catch (PDOException $e) {
104 104
                         return "error";
105 105
                 }
106 106
                 return "success";
Please login to merge, or discard this patch.
install/index.php 1 patch
Spacing   +201 added lines, -201 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.create_db.php');
10 10
 require_once(dirname(__FILE__).'/class.update_schema.php');
11 11
 require_once(dirname(__FILE__).'/class.settings.php');
12
-$title="Install";
12
+$title = "Install";
13 13
 require(dirname(__FILE__).'/../require/settings.php');
14 14
 require(dirname(__FILE__).'/header.php');
15 15
 
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 if (!extension_loaded('curl')) {
67 67
 	$error[] = "Curl is not loaded.";
68 68
 }
69
-if(function_exists('apache_get_modules') ){
70
-	if(!in_array('mod_rewrite',apache_get_modules())) {
69
+if (function_exists('apache_get_modules')) {
70
+	if (!in_array('mod_rewrite', apache_get_modules())) {
71 71
 		$error[] = "mod_rewrite is not available.";
72 72
 	}
73 73
 /*
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 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>';
84 84
 if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) {
85 85
 	if (function_exists('get_headers')) {
86
-		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/','search',str_replace('index.php',$_SERVER["REQUEST_URI"])));
87
-		if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
86
+		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/', 'search', str_replace('index.php', $_SERVER["REQUEST_URI"])));
87
+		if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
88 88
 			print '<div class="info column"><p><strong>Check your configuration, rewrite don\'t seems to work.</strong></p></div>';
89 89
 		}
90 90
 	}
@@ -424,13 +424,13 @@  discard block
 block discarded – undo
424 424
 ?>
425 425
 							<tr>
426 426
 								<?php
427
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
427
+								    if (filter_var($source['host'], FILTER_VALIDATE_URL)) {
428 428
 								?>
429 429
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
430 430
 								<td><input type="number" name="port[]" id="port" value="<?php print $source['port']; ?>" /></td>
431 431
 								<?php
432 432
 								    } else {
433
-									$hostport = explode(':',$source['host']);
433
+									$hostport = explode(':', $source['host']);
434 434
 									if (isset($hostport[1])) {
435 435
 										$host = $hostport[0];
436 436
 										$port = $hostport[1];
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 			<br />
765 765
 			<p>
766 766
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
767
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
767
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" />
768 768
 			</p>
769 769
 			<br />
770 770
 			<p>
@@ -810,14 +810,14 @@  discard block
 block discarded – undo
810 810
 $error = '';
811 811
 
812 812
 if (isset($_POST['dbtype'])) {
813
-	$dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING);
814
-	$dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING);
815
-	$dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING);
816
-	$dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING);
817
-	$dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING);
818
-	$dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING);
819
-	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
820
-	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
813
+	$dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING);
814
+	$dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING);
815
+	$dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING);
816
+	$dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING);
817
+	$dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING);
818
+	$dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING);
819
+	$dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING);
820
+	$dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING);
821 821
 
822 822
 	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
823 823
 	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
@@ -837,48 +837,48 @@  discard block
 block discarded – undo
837 837
 	} else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
838 838
 	*/
839 839
 	
840
-	$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
840
+	$settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname));
841 841
 
842
-	$sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING);
843
-	$siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING);
844
-	$timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING);
845
-	$language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING);
846
-	$settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language));
842
+	$sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING);
843
+	$siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING);
844
+	$timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING);
845
+	$language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
846
+	$settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language));
847 847
 
848
-	$mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING);
849
-	$mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING);
850
-	$mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING);
851
-	$googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING);
852
-	$bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING);
853
-	$mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING);
854
-	$hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING);
855
-	$hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING);
856
-	$settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey));
848
+	$mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING);
849
+	$mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING);
850
+	$mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING);
851
+	$googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING);
852
+	$bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING);
853
+	$mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING);
854
+	$hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING);
855
+	$hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING);
856
+	$settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey));
857 857
 	
858
-	$latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING);
859
-	$latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING);
860
-	$longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING);
861
-	$longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING);
862
-	$livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT);
863
-	$settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom));
858
+	$latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING);
859
+	$latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING);
860
+	$longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING);
861
+	$longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING);
862
+	$livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT);
863
+	$settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom));
864 864
 
865
-	$squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING);
866
-	$settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country));
865
+	$squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING);
866
+	$settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country));
867 867
 
868
-	$latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING);
869
-	$longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING);
870
-	$settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter));
868
+	$latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING);
869
+	$longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING);
870
+	$settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter));
871 871
 
872
-	$acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING);
872
+	$acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING);
873 873
 	if ($acars == 'acars') {
874
-		$settings = array_merge($settings,array('globalACARS' => 'TRUE'));
874
+		$settings = array_merge($settings, array('globalACARS' => 'TRUE'));
875 875
 	} else {
876
-		$settings = array_merge($settings,array('globalACARS' => 'FALSE'));
876
+		$settings = array_merge($settings, array('globalACARS' => 'FALSE'));
877 877
 	}
878 878
 
879
-	$flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING);
880
-	$flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING);
881
-	$settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword));
879
+	$flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING);
880
+	$flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING);
881
+	$settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword));
882 882
 	
883 883
 	$source_name = $_POST['source_name'];
884 884
 	$source_latitude = $_POST['source_latitude'];
@@ -892,8 +892,8 @@  discard block
 block discarded – undo
892 892
 	
893 893
 	$sources = array();
894 894
 	foreach ($source_name as $keys => $name) {
895
-	    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]);
896
-	    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]);
895
+	    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]);
896
+	    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]);
897 897
 	}
898 898
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
899 899
 
@@ -906,13 +906,13 @@  discard block
 block discarded – undo
906 906
 	$sbsurl = $_POST['sbsurl'];
907 907
 	*/
908 908
 
909
-	$globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING);
910
-	$globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING);
911
-	$globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING);
912
-	$globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING);
913
-	$globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING);
914
-	$globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING);
915
-	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
909
+	$globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING);
910
+	$globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING);
911
+	$globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING);
912
+	$globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING);
913
+	$globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING);
914
+	$globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING);
915
+	$datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING);
916 916
 
917 917
 /*	
918 918
 	$globalSBS1Hosts = array();
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 	}
929 929
 	$settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts));
930 930
 */
931
-	$settings_comment = array_merge($settings_comment,array('globalSBS1Hosts'));
931
+	$settings_comment = array_merge($settings_comment, array('globalSBS1Hosts'));
932 932
 	$host = $_POST['host'];
933 933
 	$port = $_POST['port'];
934 934
 	$name = $_POST['name'];
@@ -939,96 +939,96 @@  discard block
 block discarded – undo
939 939
 	foreach ($host as $key => $h) {
940 940
 		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
941 941
 		else $cov = 'FALSE';
942
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
942
+		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov);
943 943
 	}
944
-	$settings = array_merge($settings,array('globalSources' => $gSources));
944
+	$settings = array_merge($settings, array('globalSources' => $gSources));
945 945
 
946 946
 /*
947 947
 	$sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT);
948 948
 	$settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout));
949 949
 */
950
-	$acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING);
951
-	$acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT);
952
-	$settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport));
950
+	$acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING);
951
+	$acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT);
952
+	$settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport));
953 953
 
954
-	$bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING);
955
-	$settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly));
954
+	$bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING);
955
+	$settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly));
956 956
 
957
-	$notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING);
958
-	$settings = array_merge($settings,array('globalNOTAMSource' => $notamsource));
959
-	$metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING);
960
-	$settings = array_merge($settings,array('globalMETARurl' => $metarsource));
957
+	$notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING);
958
+	$settings = array_merge($settings, array('globalNOTAMSource' => $notamsource));
959
+	$metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING);
960
+	$settings = array_merge($settings, array('globalMETARurl' => $metarsource));
961 961
 
962
-	$zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING);
963
-	$zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING);
964
-	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
962
+	$zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING);
963
+	$zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING);
964
+	$zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT);
965 965
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
966
-		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
967
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
966
+		$settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance)));
967
+	} else $settings = array_merge($settings, array('globalDistanceIgnore' => array()));
968 968
 
969
-	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
970
-	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
971
-	$maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT);
972
-	$settings = array_merge($settings,array('globalMapRefresh' => $maprefresh));
973
-	$mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT);
974
-	$settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle));
975
-	$closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT);
976
-	$settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist));
969
+	$refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT);
970
+	$settings = array_merge($settings, array('globalLiveInterval' => $refresh));
971
+	$maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT);
972
+	$settings = array_merge($settings, array('globalMapRefresh' => $maprefresh));
973
+	$mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT);
974
+	$settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle));
975
+	$closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT);
976
+	$settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist));
977 977
 
978
-	$aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT);
979
-	$settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize));
978
+	$aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT);
979
+	$settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize));
980 980
 
981
-	$archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT);
982
-	$settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths));
981
+	$archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT);
982
+	$settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths));
983 983
 	
984
-	$archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING);
984
+	$archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING);
985 985
 	if ($archiveyear == "archiveyear") {
986
-		$settings = array_merge($settings,array('globalArchiveYear' => 'TRUE'));
986
+		$settings = array_merge($settings, array('globalArchiveYear' => 'TRUE'));
987 987
 	} else {
988
-		$settings = array_merge($settings,array('globalArchiveYear' => 'FALSE'));
988
+		$settings = array_merge($settings, array('globalArchiveYear' => 'FALSE'));
989 989
 	}
990
-	$archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT);
991
-	$settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths));
992
-	$archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT);
993
-	$settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
990
+	$archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT);
991
+	$settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths));
992
+	$archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT);
993
+	$settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
994 994
 
995
-	$britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING);
996
-	$settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways));
997
-	$transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING);
998
-	$settings = array_merge($settings,array('globalTransaviaKey' => $transavia));
995
+	$britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING);
996
+	$settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways));
997
+	$transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING);
998
+	$settings = array_merge($settings, array('globalTransaviaKey' => $transavia));
999 999
 
1000
-	$lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING);
1001
-	$lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING);
1002
-	$settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret)));
1000
+	$lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING);
1001
+	$lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING);
1002
+	$settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret)));
1003 1003
 
1004 1004
 	// Create in settings.php keys not yet configurable if not already here
1005 1005
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1006
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1006
+	if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE'));
1007 1007
 
1008
-	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1008
+	$resetyearstats = filter_input(INPUT_POST, 'resetyearstats', FILTER_SANITIZE_STRING);
1009 1009
 	if ($resetyearstats == 'resetyearstats') {
1010
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'TRUE'));
1010
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'TRUE'));
1011 1011
 	} else {
1012
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'FALSE'));
1012
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'FALSE'));
1013 1013
 	}
1014 1014
 
1015
-	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
1015
+	$archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING);
1016 1016
 	if ($archive == 'archive') {
1017
-		$settings = array_merge($settings,array('globalArchive' => 'TRUE'));
1017
+		$settings = array_merge($settings, array('globalArchive' => 'TRUE'));
1018 1018
 	} else {
1019
-		$settings = array_merge($settings,array('globalArchive' => 'FALSE'));
1019
+		$settings = array_merge($settings, array('globalArchive' => 'FALSE'));
1020 1020
 	}
1021
-	$daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING);
1021
+	$daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING);
1022 1022
 	if ($daemon == 'daemon') {
1023
-		$settings = array_merge($settings,array('globalDaemon' => 'TRUE'));
1023
+		$settings = array_merge($settings, array('globalDaemon' => 'TRUE'));
1024 1024
 	} else {
1025
-		$settings = array_merge($settings,array('globalDaemon' => 'FALSE'));
1025
+		$settings = array_merge($settings, array('globalDaemon' => 'FALSE'));
1026 1026
 	}
1027
-	$schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING);
1027
+	$schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING);
1028 1028
 	if ($schedules == 'schedules') {
1029
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE'));
1029
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE'));
1030 1030
 	} else {
1031
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE'));
1031
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE'));
1032 1032
 	}
1033 1033
 
1034 1034
 /*
@@ -1039,177 +1039,177 @@  discard block
 block discarded – undo
1039 1039
 		$settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE'));
1040 1040
 	}
1041 1041
 */
1042
-	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1043
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1044
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1045
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1046
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1042
+	$settings = array_merge($settings, array('globalFlightAware' => 'FALSE'));
1043
+	if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE'));
1044
+	else $settings = array_merge($settings, array('globalSBS1' => 'FALSE'));
1045
+	if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE'));
1046
+	else $settings = array_merge($settings, array('globalAPRS' => 'FALSE'));
1047 1047
 	if ($globalivao == 'ivao') {
1048 1048
 		//$settings = array_merge($settings,array('globalIVAO' => 'TRUE','globalVATSIM' => 'FALSE'));
1049
-		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1050
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1049
+		$settings = array_merge($settings, array('globalIVAO' => 'TRUE'));
1050
+	} else $settings = array_merge($settings, array('globalIVAO' => 'FALSE'));
1051 1051
 	if ($globalvatsim == 'vatsim') {
1052 1052
 		//$settings = array_merge($settings,array('globalVATSIM' => 'TRUE','globalIVAO' => 'FALSE'));
1053
-		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1054
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1053
+		$settings = array_merge($settings, array('globalVATSIM' => 'TRUE'));
1054
+	} else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE'));
1055 1055
 	if ($globalphpvms == 'phpvms') {
1056
-		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1057
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1056
+		$settings = array_merge($settings, array('globalphpVMS' => 'TRUE'));
1057
+	} else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE'));
1058 1058
 	if ($globalvam == 'vam') {
1059
-		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1060
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1059
+		$settings = array_merge($settings, array('globalVAM' => 'TRUE'));
1060
+	} else $settings = array_merge($settings, array('globalVAM' => 'FALSE'));
1061 1061
 	if ($globalvatsim == 'vatsim' || $globalivao == 'ivao' || $globalphpvms == 'phpvms') {
1062
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1063
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1062
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE'));
1063
+	} else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE'));
1064 1064
 	
1065 1065
 
1066 1066
 
1067
-	$notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING);
1067
+	$notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING);
1068 1068
 	if ($notam == 'notam') {
1069
-		$settings = array_merge($settings,array('globalNOTAM' => 'TRUE'));
1069
+		$settings = array_merge($settings, array('globalNOTAM' => 'TRUE'));
1070 1070
 	} else {
1071
-		$settings = array_merge($settings,array('globalNOTAM' => 'FALSE'));
1071
+		$settings = array_merge($settings, array('globalNOTAM' => 'FALSE'));
1072 1072
 	}
1073
-	$owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING);
1073
+	$owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING);
1074 1074
 	if ($owner == 'owner') {
1075
-		$settings = array_merge($settings,array('globalOwner' => 'TRUE'));
1075
+		$settings = array_merge($settings, array('globalOwner' => 'TRUE'));
1076 1076
 	} else {
1077
-		$settings = array_merge($settings,array('globalOwner' => 'FALSE'));
1077
+		$settings = array_merge($settings, array('globalOwner' => 'FALSE'));
1078 1078
 	}
1079
-	$map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING);
1079
+	$map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING);
1080 1080
 	if ($map3d == 'map3d') {
1081
-		$settings = array_merge($settings,array('globalMap3D' => 'TRUE'));
1081
+		$settings = array_merge($settings, array('globalMap3D' => 'TRUE'));
1082 1082
 	} else {
1083
-		$settings = array_merge($settings,array('globalMap3D' => 'FALSE'));
1083
+		$settings = array_merge($settings, array('globalMap3D' => 'FALSE'));
1084 1084
 	}
1085
-	$crash = filter_input(INPUT_POST,'crash',FILTER_SANITIZE_STRING);
1085
+	$crash = filter_input(INPUT_POST, 'crash', FILTER_SANITIZE_STRING);
1086 1086
 	if ($crash == 'crash') {
1087
-		$settings = array_merge($settings,array('globalAccidents' => 'TRUE'));
1087
+		$settings = array_merge($settings, array('globalAccidents' => 'TRUE'));
1088 1088
 	} else {
1089
-		$settings = array_merge($settings,array('globalAccidents' => 'FALSE'));
1089
+		$settings = array_merge($settings, array('globalAccidents' => 'FALSE'));
1090 1090
 	}
1091
-	$mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING);
1091
+	$mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING);
1092 1092
 	if ($mapsatellites == 'mapsatellites') {
1093
-		$settings = array_merge($settings,array('globalMapSatellites' => 'TRUE'));
1093
+		$settings = array_merge($settings, array('globalMapSatellites' => 'TRUE'));
1094 1094
 	} else {
1095
-		$settings = array_merge($settings,array('globalMapSatellites' => 'FALSE'));
1095
+		$settings = array_merge($settings, array('globalMapSatellites' => 'FALSE'));
1096 1096
 	}
1097
-	$map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING);
1097
+	$map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING);
1098 1098
 	if ($map3ddefault == 'map3ddefault') {
1099
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE'));
1099
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE'));
1100 1100
 	} else {
1101
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE'));
1101
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE'));
1102 1102
 	}
1103
-	$translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING);
1103
+	$translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING);
1104 1104
 	if ($translate == 'translate') {
1105
-		$settings = array_merge($settings,array('globalTranslate' => 'TRUE'));
1105
+		$settings = array_merge($settings, array('globalTranslate' => 'TRUE'));
1106 1106
 	} else {
1107
-		$settings = array_merge($settings,array('globalTranslate' => 'FALSE'));
1107
+		$settings = array_merge($settings, array('globalTranslate' => 'FALSE'));
1108 1108
 	}
1109
-	$realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING);
1109
+	$realairlines = filter_input(INPUT_POST, 'realairlines', FILTER_SANITIZE_STRING);
1110 1110
 	if ($realairlines == 'realairlines') {
1111
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE'));
1111
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'TRUE'));
1112 1112
 	} else {
1113
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE'));
1113
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'FALSE'));
1114 1114
 	}
1115
-	$estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING);
1115
+	$estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING);
1116 1116
 	if ($estimation == 'estimation') {
1117
-		$settings = array_merge($settings,array('globalMapEstimation' => 'TRUE'));
1117
+		$settings = array_merge($settings, array('globalMapEstimation' => 'TRUE'));
1118 1118
 	} else {
1119
-		$settings = array_merge($settings,array('globalMapEstimation' => 'FALSE'));
1119
+		$settings = array_merge($settings, array('globalMapEstimation' => 'FALSE'));
1120 1120
 	}
1121
-	$metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING);
1121
+	$metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING);
1122 1122
 	if ($metar == 'metar') {
1123
-		$settings = array_merge($settings,array('globalMETAR' => 'TRUE'));
1123
+		$settings = array_merge($settings, array('globalMETAR' => 'TRUE'));
1124 1124
 	} else {
1125
-		$settings = array_merge($settings,array('globalMETAR' => 'FALSE'));
1125
+		$settings = array_merge($settings, array('globalMETAR' => 'FALSE'));
1126 1126
 	}
1127
-	$metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING);
1127
+	$metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING);
1128 1128
 	if ($metarcycle == 'metarcycle') {
1129
-		$settings = array_merge($settings,array('globalMETARcycle' => 'TRUE'));
1129
+		$settings = array_merge($settings, array('globalMETARcycle' => 'TRUE'));
1130 1130
 	} else {
1131
-		$settings = array_merge($settings,array('globalMETARcycle' => 'FALSE'));
1131
+		$settings = array_merge($settings, array('globalMETARcycle' => 'FALSE'));
1132 1132
 	}
1133
-	$fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING);
1133
+	$fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING);
1134 1134
 	if ($fork == 'fork') {
1135
-		$settings = array_merge($settings,array('globalFork' => 'TRUE'));
1135
+		$settings = array_merge($settings, array('globalFork' => 'TRUE'));
1136 1136
 	} else {
1137
-		$settings = array_merge($settings,array('globalFork' => 'FALSE'));
1137
+		$settings = array_merge($settings, array('globalFork' => 'FALSE'));
1138 1138
 	}
1139 1139
 
1140
-	$colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING);
1140
+	$colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING);
1141 1141
 	if ($colormap == 'colormap') {
1142
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE'));
1142
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE'));
1143 1143
 	} else {
1144
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE'));
1144
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE'));
1145 1145
 	}
1146 1146
 	
1147 1147
 	if (isset($_POST['aircrafticoncolor'])) {
1148
-		$aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING);
1149
-		$settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1)));
1148
+		$aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING);
1149
+		$settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1)));
1150 1150
 	}
1151 1151
 
1152
-	$airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT);
1153
-	$settings = array_merge($settings,array('globalAirportZoom' => $airportzoom));
1152
+	$airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT);
1153
+	$settings = array_merge($settings, array('globalAirportZoom' => $airportzoom));
1154 1154
 
1155
-	$unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING);
1156
-	$settings = array_merge($settings,array('globalUnitDistance' => $unitdistance));
1157
-	$unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING);
1158
-	$settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude));
1159
-	$unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING);
1160
-	$settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed));
1155
+	$unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING);
1156
+	$settings = array_merge($settings, array('globalUnitDistance' => $unitdistance));
1157
+	$unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING);
1158
+	$settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude));
1159
+	$unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING);
1160
+	$settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed));
1161 1161
 
1162
-	$mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING);
1162
+	$mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING);
1163 1163
 	if ($mappopup == 'mappopup') {
1164
-		$settings = array_merge($settings,array('globalMapPopup' => 'TRUE'));
1164
+		$settings = array_merge($settings, array('globalMapPopup' => 'TRUE'));
1165 1165
 	} else {
1166
-		$settings = array_merge($settings,array('globalMapPopup' => 'FALSE'));
1166
+		$settings = array_merge($settings, array('globalMapPopup' => 'FALSE'));
1167 1167
 	}
1168
-	$airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING);
1168
+	$airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING);
1169 1169
 	if ($airportpopup == 'airportpopup') {
1170
-		$settings = array_merge($settings,array('globalAirportPopup' => 'TRUE'));
1170
+		$settings = array_merge($settings, array('globalAirportPopup' => 'TRUE'));
1171 1171
 	} else {
1172
-		$settings = array_merge($settings,array('globalAirportPopup' => 'FALSE'));
1172
+		$settings = array_merge($settings, array('globalAirportPopup' => 'FALSE'));
1173 1173
 	}
1174
-	$maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING);
1174
+	$maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING);
1175 1175
 	if ($maphistory == 'maphistory') {
1176
-		$settings = array_merge($settings,array('globalMapHistory' => 'TRUE'));
1176
+		$settings = array_merge($settings, array('globalMapHistory' => 'TRUE'));
1177 1177
 	} else {
1178
-		$settings = array_merge($settings,array('globalMapHistory' => 'FALSE'));
1178
+		$settings = array_merge($settings, array('globalMapHistory' => 'FALSE'));
1179 1179
 	}
1180
-	$flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING);
1180
+	$flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING);
1181 1181
 	if ($flightroute == 'flightroute') {
1182
-		$settings = array_merge($settings,array('globalMapRoute' => 'TRUE'));
1182
+		$settings = array_merge($settings, array('globalMapRoute' => 'TRUE'));
1183 1183
 	} else {
1184
-		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1184
+		$settings = array_merge($settings, array('globalMapRoute' => 'FALSE'));
1185 1185
 	}
1186
-	$allflights = filter_input(INPUT_POST,'allflights',FILTER_SANITIZE_STRING);
1186
+	$allflights = filter_input(INPUT_POST, 'allflights', FILTER_SANITIZE_STRING);
1187 1187
 	if ($allflights == 'allflights') {
1188
-		$settings = array_merge($settings,array('globalAllFlights' => 'TRUE'));
1188
+		$settings = array_merge($settings, array('globalAllFlights' => 'TRUE'));
1189 1189
 	} else {
1190
-		$settings = array_merge($settings,array('globalAllFlights' => 'FALSE'));
1190
+		$settings = array_merge($settings, array('globalAllFlights' => 'FALSE'));
1191 1191
 	}
1192
-	$waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING);
1192
+	$waypoints = filter_input(INPUT_POST, 'waypoints', FILTER_SANITIZE_STRING);
1193 1193
 	if ($waypoints == 'waypoints') {
1194
-		$settings = array_merge($settings,array('globalWaypoints' => 'TRUE'));
1194
+		$settings = array_merge($settings, array('globalWaypoints' => 'TRUE'));
1195 1195
 	} else {
1196
-		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1196
+		$settings = array_merge($settings, array('globalWaypoints' => 'FALSE'));
1197 1197
 	}
1198 1198
 
1199
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1199
+	if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE'));
1200 1200
 
1201 1201
 	// Set some defaults values...
1202 1202
 	if (!isset($globalAircraftImageSources)) {
1203
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1204
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1203
+	    $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
1204
+	    $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources));
1205 1205
 	}
1206 1206
 
1207 1207
 	if (!isset($globalSchedulesSources)) {
1208
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1209
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1208
+	    $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1209
+    	    $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources));
1210 1210
     	}
1211 1211
 
1212
-	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1212
+	$settings = array_merge($settings, array('globalInstalled' => 'TRUE'));
1213 1213
 
1214 1214
 	if ($error == '') settings::modify_settings($settings);
1215 1215
 	if ($error == '') settings::comment_settings($settings_comment);
Please login to merge, or discard this patch.
require/class.METAR.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                         $Connection = new Connection();
55 55
                         $sth = $Connection->db->prepare($query);
56 56
                         $sth->execute();
57
-                } catch(PDOException $e) {
57
+                } catch (PDOException $e) {
58 58
                         return "error : ".$e->getMessage();
59 59
                 }
60 60
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                         $Connection = new Connection();
71 71
                         $sth = $Connection->db->prepare($query);
72 72
                         $sth->execute();
73
-                } catch(PDOException $e) {
73
+                } catch (PDOException $e) {
74 74
                         return "error : ".$e->getMessage();
75 75
                 }
76 76
         }
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
         public function parse($data) {
81 81
     		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82 82
     		$codes = implode('|', array_keys($this->texts));
83
-    		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
83
+    		$regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#';
84 84
     		//$pieces = explode(' ',$data);
85
-    		$pieces = preg_split('/\s/',$data);
85
+    		$pieces = preg_split('/\s/', $data);
86 86
     		$pos = 0;
87 87
     		if ($pieces[0] == 'METAR') $pos++;
88 88
     		elseif ($pieces[0] == 'SPECI') $pos++;
@@ -90,25 +90,25 @@  discard block
 block discarded – undo
90 90
     		$result = array();
91 91
     		$result['location'] = $pieces[$pos];
92 92
     		$pos++;
93
-    		$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
-    		$result['time'] = substr($pieces[$pos],2,4);
93
+    		$result['dayofmonth'] = substr($pieces[$pos], 0, 2);
94
+    		$result['time'] = substr($pieces[$pos], 2, 4);
95 95
     		$c = count($pieces);
96
-    		for($pos++; $pos < $c; $pos++) {
96
+    		for ($pos++; $pos < $c; $pos++) {
97 97
     			$piece = $pieces[$pos];
98 98
     			if ($piece == 'RMK') break;
99 99
     			if ($piece == 'AUTO') $result['auto'] = true;
100 100
     			if ($piece == 'COR') $result['correction'] = true;
101 101
     			// Wind Speed
102 102
     			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
-    				$result['wind']['direction'] = (float)$matches[1];
103
+    				$result['wind']['direction'] = (float) $matches[1];
104 104
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
108
-				$result['wind']['gust'] = (float)$matches[3];
105
+    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2);
106
+    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2);
107
+    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2);
108
+				$result['wind']['gust'] = (float) $matches[3];
109 109
 				$result['wind']['unit'] = $matches[4];
110
-				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
111
-				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
110
+				$result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0;
111
+				$result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0;
112 112
     			}
113 113
 
114 114
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
     			*/
129 129
     			// Temperature
130 130
     			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
-    				$temp = (float)$matches[1];
131
+    				$temp = (float) $matches[1];
132 132
 				if ($matches[1]{0} == 'M') {
133
-					$temp = ((float)substr($matches[1], 1)) * -1;
133
+					$temp = ((float) substr($matches[1], 1))*-1;
134 134
 				}
135 135
     				$result['temperature'] = $temp;
136
-    				$dew = (float)$matches[2];
136
+    				$dew = (float) $matches[2];
137 137
 				if ($matches[2]{0} == 'M') {
138
-					$dew = ((float)substr($matches[2], 1)) * -1;
138
+					$dew = ((float) substr($matches[2], 1))*-1;
139 139
 				}
140 140
 				$result['dew'] = $dew;
141 141
     			}
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     					$result['QNH'] = $matches[2];
148 148
     				} else {
149 149
     					// inHg
150
-    					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
150
+    					$result['QNH'] = round(($matches[2]/100)*33.86389, 2);
151 151
 				}
152 152
     				/*
153 153
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
     			// Visibility
169 169
     			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170 170
     				if (isset($matches[3]) && strlen($matches[3]) > 0) {
171
-					$result['visibility'] = (float)$matches[3] * 1609.34;
171
+					$result['visibility'] = (float) $matches[3]*1609.34;
172 172
 				} else {
173 173
 					if ($matches[1] == '9999') {
174 174
 						$result['visibility'] = '> 10000';
175 175
 					} else {
176
-						$result['visibility'] = (float)$matches[1];
176
+						$result['visibility'] = (float) $matches[1];
177 177
 					}
178 178
 				}
179 179
 				if (preg_match('#^CAVOK$#', $piece, $matches)) {
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196 196
     				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197 197
     				$cloud['type_code'] = $type;
198
-    				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
198
+    				$cloud['level'] = round(((float) $matches[2])*100*0.3048);
199 199
     				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200 200
     				$result['cloud'][] = $cloud;
201 201
     			}
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 				$rvr['runway'] = $matches[1];
206 206
 				$rvr['assessment'] = $matches[2];
207 207
 				$rvr['rvr'] = $matches[3];
208
-				$rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0;
209
-				$rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : '';
208
+				$rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0;
209
+				$rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : '';
210 210
 				$result['RVR'] = $rvr;
211 211
 			}
212 212
     			
@@ -223,12 +223,12 @@  discard block
 block discarded – undo
223 223
     			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224 224
     				//echo $piece;
225 225
     				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
226
+    				if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
+    				else $range = array('exact' => (float) $matches[2], 'unit' => 'M');
228 228
 				if (isset($matches[3])) {
229 229
 					$range = Array(
230
-					    'from' => (float)$matches[2],
231
-					    'to'   => (float)$matches[4],
230
+					    'from' => (float) $matches[2],
231
+					    'to'   => (float) $matches[4],
232 232
 					    'unit' => $matches[5] ? 'FT' : 'M'
233 233
 					);
234 234
 				}
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                  try {
278 278
                         $sth = $this->db->prepare($query);
279 279
                         $sth->execute($query_values);
280
-                } catch(PDOException $e) {
280
+                } catch (PDOException $e) {
281 281
                         return "error : ".$e->getMessage();
282 282
                 }
283 283
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -287,19 +287,19 @@  discard block
 block discarded – undo
287 287
                 return $all;
288 288
         }
289 289
 
290
-       public function addMETAR($location,$metar,$date) {
290
+       public function addMETAR($location, $metar, $date) {
291 291
 		global $globalDBdriver;
292
-		$date = date('Y-m-d H:i:s',strtotime($date));
292
+		$date = date('Y-m-d H:i:s', strtotime($date));
293 293
 		if ($globalDBdriver == 'mysql') {
294 294
 			$query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar";
295 295
 		} else {
296 296
 			$query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);";
297 297
 		}
298
-                $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
298
+                $query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar));
299 299
                  try {
300 300
                         $sth = $this->db->prepare($query);
301 301
                         $sth->execute($query_values);
302
-                } catch(PDOException $e) {
302
+                } catch (PDOException $e) {
303 303
                         return "error : ".$e->getMessage();
304 304
                 }
305 305
         }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
                  try {
311 311
                         $sth = $this->db->prepare($query);
312 312
                         $sth->execute($query_values);
313
-                } catch(PDOException $e) {
313
+                } catch (PDOException $e) {
314 314
                         return "error : ".$e->getMessage();
315 315
                 }
316 316
         }
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
                  try {
320 320
                         $sth = $this->db->prepare($query);
321 321
                         $sth->execute();
322
-                } catch(PDOException $e) {
322
+                } catch (PDOException $e) {
323 323
                         return "error : ".$e->getMessage();
324 324
                 }
325 325
         }
@@ -331,29 +331,29 @@  discard block
 block discarded – undo
331 331
     		$Common = new Common();
332 332
     		if (isset($globalIVAO) && $globalIVAO) {
333 333
         		//$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
334
-			$Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt');
335
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
334
+			$Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt');
335
+    			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r");
336 336
     		} else {
337 337
 			//$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT');
338
-			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
339
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
338
+			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
339
+    			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r");
340 340
     		}
341 341
     		if ($handle) {
342 342
 			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
343 343
 			$date = '';
344 344
     			//foreach(explode("\n",$cycle) as $line) {
345
-	    		while(($line = fgets($handle,4096)) !== false) {
346
-				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
345
+	    		while (($line = fgets($handle, 4096)) !== false) {
346
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
347 347
 					$date = $line;
348 348
     				} elseif ($line != '') {
349 349
     				    //$this->parse($line);
350 350
     				    if ($date == '') $date = date('Y/m/d H:m');
351 351
         			    $pos = 0;
352
-        			    $pieces = preg_split('/\s/',$line);
352
+        			    $pieces = preg_split('/\s/', $line);
353 353
         			    if ($pieces[0] == 'METAR') $pos++;
354 354
         			    if (strlen($pieces[$pos]) != 4) $pos++;
355 355
 		        	    $location = $pieces[$pos];
356
-        	        	    echo $this->addMETAR($location,$line,$date);
356
+        	        	    echo $this->addMETAR($location, $line, $date);
357 357
     				}
358 358
     			}
359 359
     			fclose($handle);
@@ -366,11 +366,11 @@  discard block
 block discarded – undo
366 366
     		if ($globalMETARurl == '') return array();
367 367
     		date_default_timezone_set("UTC");
368 368
     		$Common = new Common();
369
-    		$url = str_replace('{icao}',$icao,$globalMETARurl);
369
+    		$url = str_replace('{icao}', $icao, $globalMETARurl);
370 370
     		$cycle = $Common->getData($url);
371 371
     		$date = '';
372
-    		foreach(explode("\n",$cycle) as $line) {
373
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
372
+    		foreach (explode("\n", $cycle) as $line) {
373
+    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) {
374 374
     				//echo "date : ".$line."\n";
375 375
     				$date = $line;
376 376
     			} 
@@ -379,12 +379,12 @@  discard block
 block discarded – undo
379 379
     			    //echo $line;
380 380
     			    if ($date == '') $date = date('Y/m/d H:m');
381 381
     			    $pos = 0;
382
-    			    $pieces = preg_split('/\s/',$line);
382
+    			    $pieces = preg_split('/\s/', $line);
383 383
     			    if ($pieces[0] == 'METAR') $pos++;
384 384
     			    if (strlen($pieces[$pos]) != 4) $pos++;
385 385
 	        	    $location = $pieces[$pos];
386 386
 	        	    if (strlen($location == 4)) {
387
-	        		$this->addMETAR($location,$line,$date);
387
+	        		$this->addMETAR($location, $line, $date);
388 388
 	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
389 389
 	        	    } else return array();
390 390
     			}
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Spacing   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
 	$currentdate = date('Y-m-d');
30 30
 	$sourcestat = $Stats->getStatsSource($currentdate);
31 31
 	if (!empty($sourcestat)) {
32
-	    foreach($sourcestat as $srcst) {
32
+	    foreach ($sourcestat as $srcst) {
33 33
 	    	$type = $srcst['stats_type'];
34 34
 		if ($type == 'polar' || $type == 'hist') {
35 35
 		    $source = $srcst['source_name'];
36 36
 		    $data = $srcst['source_data'];
37
-		    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
37
+		    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
38 38
 	        }
39 39
 	    }
40 40
 	}
41 41
     }
42 42
 
43
-    public function get_Schedule($id,$ident) {
43
+    public function get_Schedule($id, $ident) {
44 44
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
45 45
 	// Get schedule here, so it's done only one time
46 46
 	
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 		$schedule = $Schedule->fetchSchedule($operator);
66 66
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
67 67
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
68
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
69
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
68
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
69
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
70 70
 		    // Should also check if route schedule = route from DB
71 71
 		    if ($schedule['DepartureAirportIATA'] != '') {
72 72
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			    }
87 87
 			}
88 88
 		    }
89
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
89
+		    $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']);
90 90
 		}
91 91
 	    } else $scheduleexist = true;
92 92
 	} else $scheduleexist = true;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
        if ($scheduleexist) {
95 95
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
96 96
     		$sch = $Schedule->getSchedule($operator);
97
-		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
97
+		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time']));
98 98
        }
99 99
 	$Spotter->db = null;
100 100
 	$Schedule->db = null;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
121 121
     		$Spotter = new Spotter($this->db);
122 122
         	$real_arrival = $this->arrival($key);
123
-        	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
123
+        	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
124 124
             }
125 125
 	}
126 126
     }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         $airport_time = '';
134 134
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
135 135
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
136
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
136
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
137 137
     	    if (isset($closestAirports[0])) {
138 138
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
139 139
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         		    break;
149 149
         		}
150 150
         	    }
151
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
151
+        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) {
152 152
         		$airport_icao = $closestAirports[0]['icao'];
153 153
         		$airport_time = $this->all_flights[$key]['datetime'];
154 154
         	} else {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
         } else {
162 162
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
163 163
         }
164
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
164
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
165 165
     }
166 166
 
167 167
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
173 173
 	foreach ($this->all_flights as $key => $flight) {
174 174
     	    if (isset($flight['lastupdate'])) {
175
-        	if ($flight['lastupdate'] < (time()-3000)) {
175
+        	if ($flight['lastupdate'] < (time() - 3000)) {
176 176
             	    if (isset($this->all_flights[$key]['id'])) {
177 177
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
178 178
 			/*
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
             		$real_arrival = $this->arrival($key);
184 184
             		$Spotter = new Spotter($this->db);
185 185
             		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
186
-				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
186
+				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
187 187
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
188 188
 			}
189 189
 			// Put in archive
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	$send = false;
220 220
 	
221 221
 	// SBS format is CSV format
222
-	if(is_array($line) && isset($line['hex'])) {
222
+	if (is_array($line) && isset($line['hex'])) {
223 223
 	    //print_r($line);
224 224
   	    if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
225 225
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 		//print_r($this->all_flights);
254 254
 		if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) {
255 255
 		    $this->all_flights[$id] = array('hex' => $hex);
256
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
256
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
257 257
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
258 258
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
259 259
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 			$Spotter = new Spotter($this->db);
264 264
 			$aircraft_icao = $Spotter->getAllAircraftType($hex);
265 265
 			$Spotter->db = null;
266
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
266
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
267 267
 
268 268
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
269 269
 			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
@@ -271,32 +271,32 @@  discard block
 block discarded – undo
271 271
 			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
272 272
 			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
273 273
 			}
274
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
274
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
275 275
 		    } else if (isset($line['aircraft_name'])) {
276 276
 			// Get aircraft ICAO from aircraft name
277 277
 			$Spotter = new Spotter($this->db);
278 278
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
279 279
 			$Spotter->db = null;
280
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
281
-			else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
282
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
283
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true));
284
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
280
+			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
281
+			else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
282
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $line['aircraft_icao']));
283
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true));
284
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
285 285
 		    if (!isset($line['id'])) {
286 286
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
287 287
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
288 288
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
289
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
289
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
290 290
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
291
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
291
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
292 292
 
293 293
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
294 294
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
295 295
 		}
296 296
 		
297
-		if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
297
+		if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/', $line['datetime'])) {
298 298
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
299
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
299
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
300 300
 		    } else {
301 301
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
302 302
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
@@ -307,23 +307,23 @@  discard block
 block discarded – undo
307 307
 				*/
308 308
 				return '';
309 309
 		    }
310
-		} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
310
+		} else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
311 311
 
312 312
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
313
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
313
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
314 314
 		}
315 315
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
316
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
316
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
317 317
 		}
318 318
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
319
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
319
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id']));
320 320
 		}
321 321
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
322
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
322
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name']));
323 323
 		}
324 324
  
325 325
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
326
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
326
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
327 327
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
328 328
 			$timeelapsed = microtime(true);
329 329
             		$Spotter = new Spotter($this->db);
@@ -333,10 +333,10 @@  discard block
 block discarded – undo
333 333
 			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
334 334
 			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
335 335
 			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
336
-            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
336
+            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource);
337 337
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
338 338
 			$Spotter->db = null;
339
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
339
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
340 340
 		    }
341 341
 
342 342
 /*
@@ -347,24 +347,24 @@  discard block
 block discarded – undo
347 347
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
348 348
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
349 349
   */
350
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
350
+		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
351 351
 
352 352
 		    //$putinarchive = true;
353 353
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
354
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
354
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
355 355
 		    }
356 356
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
357
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
357
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
358 358
 		    }
359 359
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
360
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
360
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
361 361
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
362 362
 				$timeelapsed = microtime(true);
363 363
 				$Spotter = new Spotter($this->db);
364 364
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
365 365
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
366
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
367
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
366
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
367
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
368 368
 
369 369
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
370 370
 			$timeelapsed = microtime(true);
@@ -377,34 +377,34 @@  discard block
 block discarded – undo
377 377
 				$Translation->db = null;
378 378
 			}
379 379
 			$Spotter->db = null;
380
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
380
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
381 381
 
382 382
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
383 383
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
384 384
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
385 385
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
386
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
386
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop']));
387 387
 		    	    }
388 388
 			}
389 389
 			if (!isset($globalFork)) $globalFork = TRUE;
390 390
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
391
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
391
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
392 392
 			}
393 393
 		    }
394 394
 		}
395 395
 
396 396
 		if (isset($line['speed']) && $line['speed'] != '') {
397 397
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
398
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
399
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
398
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
399
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
400 400
 		    //$dataFound = true;
401 401
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
402
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
402
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
403 403
 		    if ($distance > 1000 && $distance < 10000) {
404 404
 		    // use datetime
405 405
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
406 406
 			$speed = $speed*3.6;
407
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
407
+			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
408 408
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
409 409
 		    }
410 410
 		}
@@ -412,11 +412,11 @@  discard block
 block discarded – undo
412 412
 
413 413
 
414 414
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
415
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
415
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
416 416
 	    	    else unset($timediff);
417
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
417
+	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')))) {
418 418
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
419
-			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
419
+			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
420 420
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
421 421
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
422 422
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
425 425
 				$timeelapsed = microtime(true);
426 426
 				$Spotter = new Spotter($this->db);
427
-				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
427
+				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
428 428
 				if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
429 429
 				$Spotter->db = null;
430
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
430
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
431 431
 				$this->tmd = 0;
432 432
 				if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
433 433
 			    }
@@ -436,13 +436,13 @@  discard block
 block discarded – undo
436 436
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
437 437
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
438 438
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
439
-				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
439
+				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
440 440
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
441 441
 				    $dataFound = true;
442 442
 				    $this->all_flights[$id]['time_last_coord'] = time();
443 443
 				}
444 444
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
445
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
445
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
446 446
 				/*
447 447
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
448 448
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -460,13 +460,13 @@  discard block
 block discarded – undo
460 460
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
461 461
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
462 462
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
463
-				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
463
+				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
464 464
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
465 465
 				    $dataFound = true;
466 466
 				    $this->all_flights[$id]['time_last_coord'] = time();
467 467
 				}
468 468
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
469
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
469
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
470 470
 				/*
471 471
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
472 472
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -484,45 +484,45 @@  discard block
 block discarded – undo
484 484
 		    } else if ($globalDebug && $timediff > 20) {
485 485
 			$this->tmd = $this->tmd + 1;
486 486
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
487
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
488
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
487
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
488
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
489 489
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
490 490
 		    }
491 491
 		}
492 492
 		if (isset($line['last_update']) && $line['last_update'] != '') {
493 493
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
494
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
494
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
495 495
 		}
496 496
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
497
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
497
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
498 498
 		    //$dataFound = true;
499 499
 		}
500 500
 		if (isset($line['format_source']) && $line['format_source'] != '') {
501
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
501
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
502 502
 		}
503 503
 		if (isset($line['source_name']) && $line['source_name'] != '') {
504
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
504
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
505 505
 		}
506 506
 		if (isset($line['emergency']) && $line['emergency'] != '') {
507
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
507
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
508 508
 		    //$dataFound = true;
509 509
 		}
510 510
 		if (isset($line['ground']) && $line['ground'] != '') {
511 511
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
512 512
 			// Here we force archive of flight because after ground it's a new one (or should be)
513
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
514
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
515
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
516
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
517
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
513
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
514
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
515
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
516
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
517
+			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
518 518
 		    }
519 519
 		    if ($line['ground'] != 1) $line['ground'] = 0;
520
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
520
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
521 521
 		    //$dataFound = true;
522 522
 		}
523 523
 		if (isset($line['squawk']) && $line['squawk'] != '') {
524 524
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
525
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
525
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
526 526
 			    $highlight = '';
527 527
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
528 528
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -530,48 +530,48 @@  discard block
 block discarded – undo
530 530
 			    if ($highlight != '') {
531 531
 				$timeelapsed = microtime(true);
532 532
 				$Spotter = new Spotter($this->db);
533
-				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
533
+				$Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
534 534
 				$Spotter->db = null;
535
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
535
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
536 536
 
537 537
 				$this->all_flights[$id]['putinarchive'] = true;
538 538
 				//$putinarchive = true;
539 539
 				//$highlight = '';
540 540
 			    }
541 541
 			    
542
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
542
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
543 543
 		    //$dataFound = true;
544 544
 		}
545 545
 
546 546
 		if (isset($line['altitude']) && $line['altitude'] != '') {
547 547
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
548
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
549
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
550
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
548
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
549
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
550
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
551 551
 			//$dataFound = true;
552 552
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
553 553
   		}
554 554
 
555 555
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
556
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
556
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
557 557
 		}
558 558
 		
559 559
 		if (isset($line['heading']) && $line['heading'] != '') {
560
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
561
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
562
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
560
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
561
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
562
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
563 563
 		    //$dataFound = true;
564 564
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
565
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
566
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
567
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
565
+  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
566
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
567
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
568 568
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
569 569
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
570 570
   		    // If not enough messages and ACARS set heading to 0
571
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
571
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
572 572
   		}
573
-		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
574
-		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
573
+		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
574
+		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
575 575
 
576 576
 //		print_r($this->all_flights[$id]);
577 577
 		//gets the callsign from the last hour
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 		if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
582 582
 		    $this->all_flights[$id]['lastupdate'] = time();
583 583
 		    if ($this->all_flights[$id]['addedSpotter'] == 0) {
584
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
584
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
585 585
 			    //print_r($this->all_flights);
586 586
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
587 587
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -591,61 +591,61 @@  discard block
 block discarded – undo
591 591
 				$SpotterLive = new SpotterLive($this->db);
592 592
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
593 593
 				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
594
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
594
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
595 595
 				} elseif (isset($line['id'])) {
596 596
 				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
597
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
597
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
598 598
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
599 599
 				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
600
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
600
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
601 601
 				} else $recent_ident = '';
602
-				$SpotterLive->db=null;
602
+				$SpotterLive->db = null;
603 603
 
604 604
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
605 605
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
606 606
 			    } else {
607 607
 				$recent_ident = '';
608
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
608
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
609 609
 			    }
610 610
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
611
-			    if($recent_ident == "")
611
+			    if ($recent_ident == "")
612 612
 			    {
613 613
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
614 614
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
615 615
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
616 616
 				//adds the spotter data for the archive
617 617
 				$ignoreImport = false;
618
-				foreach($globalAirportIgnore as $airportIgnore) {
618
+				foreach ($globalAirportIgnore as $airportIgnore) {
619 619
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
620 620
 					$ignoreImport = true;
621 621
 				    }
622 622
 				}
623 623
 				if (count($globalAirportAccept) > 0) {
624 624
 				    $ignoreImport = true;
625
-				    foreach($globalAirportIgnore as $airportIgnore) {
625
+				    foreach ($globalAirportIgnore as $airportIgnore) {
626 626
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
627 627
 					    $ignoreImport = false;
628 628
 					}
629 629
 				    }
630 630
 				}
631 631
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
632
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
633
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
632
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
633
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
634 634
 					    $ignoreImport = true;
635 635
 					}
636 636
 				    }
637 637
 				}
638 638
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
639 639
 				    $ignoreImport = true;
640
-				    foreach($globalAirlineAccept as $airlineAccept) {
641
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
640
+				    foreach ($globalAirlineAccept as $airlineAccept) {
641
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
642 642
 					    $ignoreImport = false;
643 643
 					}
644 644
 				    }
645 645
 				}
646 646
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
647 647
 				    $ignoreImport = true;
648
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
648
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
649 649
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
650 650
 					    $ignoreImport = false;
651 651
 					}
@@ -657,27 +657,27 @@  discard block
 block discarded – undo
657 657
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
658 658
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
659 659
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
660
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
660
+				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
661 661
 				    $timeelapsed = microtime(true);
662 662
 				    $Spotter = new Spotter($this->db);
663
-				    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']);
663
+				    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name']);
664 664
 				    $Spotter->db = null;
665 665
 				    if ($globalDebug && isset($result)) echo $result."\n";
666
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
666
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
667 667
 				    
668 668
 				    // Add source stat in DB
669 669
 				    $Stats = new Stats($this->db);
670 670
 				    if (!empty($this->stats)) {
671 671
 					if ($globalDebug) echo 'Add source stats : ';
672
-				        foreach($this->stats as $date => $data) {
673
-					    foreach($data as $source => $sourced) {
672
+				        foreach ($this->stats as $date => $data) {
673
+					    foreach ($data as $source => $sourced) {
674 674
 					        //print_r($sourced);
675
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
676
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
675
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
676
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
677 677
 				    		if (isset($sourced['msg'])) {
678 678
 				    		    if (time() - $sourced['msg']['date'] > 10) {
679 679
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
680
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
680
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
681 681
 			    			        unset($this->stats[$date][$source]['msg']);
682 682
 			    			    }
683 683
 			    			}
@@ -713,18 +713,18 @@  discard block
 block discarded – undo
713 713
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
714 714
 				    $SpotterLive = new SpotterLive($this->db);
715 715
 				    $SpotterLive->deleteLiveSpotterData();
716
-				    $SpotterLive->db=null;
716
+				    $SpotterLive->db = null;
717 717
 				    if ($globalDebug) echo " Done\n";
718 718
 				    $this->last_delete = time();
719 719
 				}
720 720
 			    } else {
721
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
721
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
722 722
 				    $this->all_flights[$id]['id'] = $recent_ident;
723 723
 				    $this->all_flights[$id]['addedSpotter'] = 1;
724 724
 				}
725 725
 				if (isset($globalDaemon) && !$globalDaemon) {
726 726
 					$Spotter = new Spotter($this->db);
727
-					$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
727
+					$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']);
728 728
 					$Spotter->db = null;
729 729
 				}
730 730
 				
@@ -748,37 +748,37 @@  discard block
 block discarded – undo
748 748
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
749 749
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
750 750
 
751
-		    foreach($globalAirportIgnore as $airportIgnore) {
751
+		    foreach ($globalAirportIgnore as $airportIgnore) {
752 752
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
753 753
 			    $ignoreImport = true;
754 754
 			}
755 755
 		    }
756 756
 		    if (count($globalAirportAccept) > 0) {
757 757
 		        $ignoreImport = true;
758
-		        foreach($globalAirportIgnore as $airportIgnore) {
758
+		        foreach ($globalAirportIgnore as $airportIgnore) {
759 759
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
760 760
 				$ignoreImport = false;
761 761
 			    }
762 762
 			}
763 763
 		    }
764 764
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
765
-			foreach($globalAirlineIgnore as $airlineIgnore) {
766
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
765
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
766
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
767 767
 				$ignoreImport = true;
768 768
 			    }
769 769
 			}
770 770
 		    }
771 771
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
772 772
 			$ignoreImport = true;
773
-			foreach($globalAirlineAccept as $airlineAccept) {
774
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
773
+			foreach ($globalAirlineAccept as $airlineAccept) {
774
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
775 775
 				$ignoreImport = false;
776 776
 			    }
777 777
 			}
778 778
 		    }
779 779
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
780 780
 			$ignoreImport = true;
781
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
781
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
782 782
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
783 783
 			        $ignoreImport = false;
784 784
 			    }
@@ -786,13 +786,13 @@  discard block
 block discarded – undo
786 786
 		    }
787 787
 
788 788
 		    if (!$ignoreImport) {
789
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
789
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
790 790
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
791 791
 				$timeelapsed = microtime(true);
792 792
 				$SpotterLive = new SpotterLive($this->db);
793
-				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
793
+				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
794 794
 				$SpotterLive->db = null;
795
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
795
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
796 796
 
797 797
 				// Put statistics in $this->stats variable
798 798
 				//if ($line['format_source'] != 'aprs') {
@@ -810,19 +810,19 @@  discard block
 block discarded – undo
810 810
 							$latitude = $globalCenterLatitude;
811 811
 							$longitude = $globalCenterLongitude;
812 812
 						}
813
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
813
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
814 814
 					} else {
815 815
 						$latitude = $this->source_location[$source]['latitude'];
816 816
 						$longitude = $this->source_location[$source]['longitude'];
817 817
 					}
818
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
818
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
819 819
 					//$stats_heading = $stats_heading%22.5;
820 820
 					$stats_heading = round($stats_heading/22.5);
821
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
821
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
822 822
 					$current_date = date('Y-m-d');
823 823
 					if ($stats_heading == 16) $stats_heading = 0;
824 824
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
825
-						for ($i=0;$i<=15;$i++) {
825
+						for ($i = 0; $i <= 15; $i++) {
826 826
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
827 827
 						}
828 828
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -837,9 +837,9 @@  discard block
 block discarded – undo
837 837
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
838 838
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
839 839
 						    end($this->stats[$current_date][$source]['hist']);
840
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
840
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
841 841
 						} else $mini = 0;
842
-						for ($i=$mini;$i<=$distance;$i+=10) {
842
+						for ($i = $mini; $i <= $distance; $i += 10) {
843 843
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
844 844
 						}
845 845
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
853 853
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
854 854
 				if ($globalDebug) echo $result."\n";
855
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
855
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
856 856
 			//$this->del();
857 857
 			
858 858
 			
Please login to merge, or discard this patch.
incident-latest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 $page_url = $globalURL.'/accident-latest';
10 10
 
11
-if(!isset($_GET['limit']))
11
+if (!isset($_GET['limit']))
12 12
 {
13 13
 	$limit_start = 0;
14 14
 	$limit_end = 25;
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
 print '<div class="table column">';
36 36
 print '<p>'._("The table below shows the latest Incidents.").'</p>';
37
-$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference,'incident');
37
+$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference, 'incident');
38 38
 //print_r($spotter_array);
39 39
 if (!empty($spotter_array) && $spotter_array[0]['query_number_rows'] != 0) {
40 40
 	include('table-output.php');
Please login to merge, or discard this patch.
accident.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
2
+$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING);
3 3
 if ($date == '') $date = date('Y-m-d');
4 4
 header('Location: '.$globalURL.'/accident/'.$date);
5 5
 ?>
6 6
\ No newline at end of file
Please login to merge, or discard this patch.