Completed
Push — master ( 64cd98...c5e9bd )
by Yannick
04:45
created
waypoints-geojson.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 		date_default_timezone_set('UTC');
27 27
 		//waypoint plotting
28 28
 		$output .= '{"type": "Feature",';
29
-		    $output .= '"properties": {';
29
+			$output .= '"properties": {';
30 30
 			$output .= '"segment_name": "'.$spotter_item['segment_name'].'",';
31 31
 			$output .= '"base": "'.$spotter_item['base'].'",';
32 32
 			$output .= '"top": "'.$spotter_item['top'].'",';
@@ -49,15 +49,15 @@  discard block
 block discarded – undo
49 49
 				$output .= '"stroke": "#f0f0f0",';
50 50
 				$output .= '"stroke-width": 2';
51 51
 //			}
52
-		    $output .= '},';
53
-		    $output .= '"geometry": {';
52
+			$output .= '},';
53
+			$output .= '"geometry": {';
54 54
 			$output .= '"type": "LineString",';
55 55
 			$output .= '"coordinates": [';
56
-			    //$output .= '['.$spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].'], ['.$spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].'], ['.$spotter_item['longitude_end_seg2'].', '.$spotter_item['latitude_end_seg2'].']';
57
-			    $output .= '['.$spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].','.round($spotter_item['base']*100*0.3048).'], ['.$spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].','.round($spotter_item['base']*100*0.3048).']';
56
+				//$output .= '['.$spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].'], ['.$spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].'], ['.$spotter_item['longitude_end_seg2'].', '.$spotter_item['latitude_end_seg2'].']';
57
+				$output .= '['.$spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].','.round($spotter_item['base']*100*0.3048).'], ['.$spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].','.round($spotter_item['base']*100*0.3048).']';
58 58
 			//    $output .= '['.$spotter_item['latitude_begin'].', '.$spotter_item['longitude_begin'].'], ['.$spotter_item['latitude_end'].', '.$spotter_item['longitude_end'].']';
59 59
 			$output .= ']';
60
-		    $output .= '}';
60
+			$output .= '}';
61 61
 /*		    $output .= '"geometry": {';
62 62
 			$output .= '"type": "Point",';
63 63
 			$output .= '"coordinates": [';
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		$output .= '},';
69 69
 		//waypoint plotting
70 70
 		$output .= '{"type": "Feature",';
71
-		    $output .= '"properties": {';
71
+			$output .= '"properties": {';
72 72
 			$output .= '"ident": "'.$spotter_item['name_begin'].'",';
73 73
 			$output .= '"high": "'.$spotter_item['high'].'",';
74 74
 			$output .= '"alt": "'.$spotter_item['base'].'",';
@@ -98,17 +98,17 @@  discard block
 block discarded – undo
98 98
 				$output .= '"marker-size": "small",';
99 99
 				$output .= '"marker-color": "#0000ff"';
100 100
 			}
101
-		    $output .= '},';
102
-		    $output .= '"geometry": {';
101
+			$output .= '},';
102
+			$output .= '"geometry": {';
103 103
 			$output .= '"type": "Point",';
104 104
 			$output .= '"coordinates": [';
105
-			    $output .= $spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].', '.round($spotter_item['base']*100*0.3048);;
105
+				$output .= $spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].', '.round($spotter_item['base']*100*0.3048);;
106 106
 			$output .= ']';
107
-		    $output .= '}';
107
+			$output .= '}';
108 108
 
109 109
 		$output .= '},';
110 110
 		$output .= '{"type": "Feature",';
111
-		    $output .= '"properties": {';
111
+			$output .= '"properties": {';
112 112
 			$output .= '"ident": "'.$spotter_item['name_end'].'",';
113 113
 			$output .= '"high": "'.$spotter_item['high'].'",';
114 114
 			$output .= '"alt": "'.$spotter_item['top'].'",';
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
 				$output .= '"marker-size": "small",';
146 146
 				$output .= '"marker-color": "#0000ff"';
147 147
 			}
148
-		    $output .= '},';
149
-		    $output .= '"geometry": {';
148
+			$output .= '},';
149
+			$output .= '"geometry": {';
150 150
 			$output .= '"type": "Point",';
151 151
 			$output .= '"coordinates": [';
152
-			    $output .= $spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].', '.round($spotter_item['base']*100*0.3048);
152
+				$output .= $spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].', '.round($spotter_item['base']*100*0.3048);
153 153
 			$output .= ']';
154
-		    $output .= '}';
154
+			$output .= '}';
155 155
 
156 156
 		$output .= '},';
157 157
 	}
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
 if (isset($_GET['coord'])) 
12 12
 {
13
-	$coords = explode(',',$_GET['coord']);
13
+	$coords = explode(',', $_GET['coord']);
14 14
 	$spotter_array = $Spotter->getAllWaypointsInfobyCoord($coords);
15 15
 } else {
16 16
 	die;
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 if (!empty($spotter_array))
22 22
 {	  
23 23
 //	print_r($spotter_array);
24
-	foreach($spotter_array as $spotter_item)
24
+	foreach ($spotter_array as $spotter_item)
25 25
 	{
26 26
 		date_default_timezone_set('UTC');
27 27
 		//waypoint plotting
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 		    $output .= '"geometry": {';
103 103
 			$output .= '"type": "Point",';
104 104
 			$output .= '"coordinates": [';
105
-			    $output .= $spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].', '.round($spotter_item['base']*100*0.3048);;
105
+			    $output .= $spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].', '.round($spotter_item['base']*100*0.3048); ;
106 106
 			$output .= ']';
107 107
 		    $output .= '}';
108 108
 
Please login to merge, or discard this patch.
airspace-data.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 <button type="button" class="close">&times;</button>
8 8
 <?php
9 9
 
10
-$airspaceid = filter_input(INPUT_GET,'airspace',FILTER_SANITIZE_NUMBER_INT);
10
+$airspaceid = filter_input(INPUT_GET, 'airspace', FILTER_SANITIZE_NUMBER_INT);
11 11
 //$notamref = urldecode($notamref);
12 12
 if ($globalDBdriver == 'mysql') {
13 13
 	$query = "SELECT * FROM airspace WHERE ogr_fid = :id";
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 try {
19 19
 	$sth = $Connection->db->prepare($query);
20 20
 	$sth->execute(array(':id' => $airspaceid));
21
-} catch(PDOException $e) {
21
+} catch (PDOException $e) {
22 22
 	echo "error";
23 23
 }
24
-$result=$sth->fetchAll(PDO::FETCH_ASSOC);
24
+$result = $sth->fetchAll(PDO::FETCH_ASSOC);
25 25
 $airspace = $result[0];
26 26
 date_default_timezone_set('UTC');
27 27
 print '<div class="top">';
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,7 +25,9 @@  discard block
 block discarded – undo
25 25
 $airspace = $result[0];
26 26
 date_default_timezone_set('UTC');
27 27
 print '<div class="top">';
28
-if (isset($airspace['name'])) $airspace['title'] = $airspace['name']; 
28
+if (isset($airspace['name'])) {
29
+	$airspace['title'] = $airspace['name'];
30
+}
29 31
 print '<div class="right"><div class="callsign-details"><div class="callsign">'.$airspace['title'].'</a></div>';
30 32
 print '</div>';
31 33
 print '<div class="details">';
@@ -44,13 +46,17 @@  discard block
 block discarded – undo
44 46
 	print '</div>';
45 47
 }
46 48
 
47
-if (isset($airspace['ceiling'])) $airspace['tops'] = $airspace['ceiling'];
49
+if (isset($airspace['ceiling'])) {
50
+	$airspace['tops'] = $airspace['ceiling'];
51
+}
48 52
 print '<div>';
49 53
 print '<span>'._("Tops").'</span>';
50 54
 print $airspace['tops'];
51 55
 print '</div>';
52 56
 
53
-if (isset($airspace['floor'])) $airspace['base'] = $airspace['floor'];
57
+if (isset($airspace['floor'])) {
58
+	$airspace['base'] = $airspace['floor'];
59
+}
54 60
 print '<div>';
55 61
 print '<span>'._("Base").'</span>';
56 62
 print $airspace['base'];
Please login to merge, or discard this patch.
scripts/update_db.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
10 10
 	exec("ps ux", $output, $result);
11 11
 	$j = 0;
12
-	foreach ($output as $line) if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++;
12
+	foreach ($output as $line) if (strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++;
13 13
 	if ($j > 1) {
14 14
 		echo "Script is already runnning...";
15 15
 		die();
Please login to merge, or discard this patch.
Braces   +20 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,7 +9,9 @@  discard block
 block discarded – undo
9 9
 if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
10 10
 	exec("ps ux", $output, $result);
11 11
 	$j = 0;
12
-	foreach ($output as $line) if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++;
12
+	foreach ($output as $line) {
13
+		if(strpos($line, "update_db.php") && !strpos($line, "sh ")) $j++;
14
+	}
13 15
 	if ($j > 1) {
14 16
 		echo "Script is already runnning...";
15 17
 		die();
@@ -28,8 +30,10 @@  discard block
 block discarded – undo
28 30
 			$update_db->update_notam();
29 31
 		}
30 32
 		$update_db->insert_last_notam_update();
31
-	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n";
32
-}
33
+	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) {
34
+		echo "NOTAM are only updated once a day.\n";
35
+	}
36
+	}
33 37
 
34 38
 if ($update_db->check_last_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
35 39
 	$update_db->update_all();
@@ -37,7 +41,9 @@  discard block
 block discarded – undo
37 41
 //	$Spotter = new Spotter();
38 42
 //	$Spotter->updateFieldsFromOtherTables();
39 43
 	$update_db->insert_last_update();
40
-} elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
44
+} elseif (isset($globalDebug) && $globalDebug && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) {
45
+	echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
46
+}
41 47
 
42 48
 
43 49
 if (isset($globalMETAR) && isset($globalMETARcycle) && $globalMETAR && $globalMETARcycle) {
@@ -47,22 +53,28 @@  discard block
 block discarded – undo
47 53
 	if ($METAR->check_last_update()) {
48 54
 		$METAR->addMETARCycle();
49 55
 		$METAR->insert_last_update();
50
-	} else echo "METAR are only updated every 30 minutes.\n";
51
-}
56
+	} else {
57
+		echo "METAR are only updated every 30 minutes.\n";
58
+	}
59
+	}
52 60
 
53 61
 
54 62
 if (isset($globalOwner) && $globalOwner && $update_db->check_last_owner_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
55 63
 	echo "Updating private aircraft's owners...";
56 64
 	$update_db->update_owner();
57 65
 	$update_db->insert_last_owner_update();
58
-} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n";
66
+} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
67
+	echo "Owner are only updated every 15 days.\n";
68
+}
59 69
 
60 70
 if (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
61 71
 	echo "Updating schedules...";
62 72
 	$update_db->update_oneworld();
63 73
 	$update_db->update_skyteam();
64 74
 	$update_db->insert_last_schedules_update();
65
-} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n";
75
+} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
76
+	echo "Schedules are only updated every 15 days.\n";
77
+}
66 78
 
67 79
 if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) {
68 80
 	echo "Updating statistics and archive old data...";
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	    die;
38 38
 	}
39 39
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
40
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
40
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
41 41
     }
42 42
 }
43 43
 
44
-$options = getopt('s::',array('source::','server','idsource::'));
44
+$options = getopt('s::', array('source::', 'server', 'idsource::'));
45 45
 //if (isset($options['s'])) $hosts = array($options['s']);
46 46
 //elseif (isset($options['source'])) $hosts = array($options['source']);
47 47
 if (isset($options['s'])) {
@@ -56,17 +56,17 @@  discard block
 block discarded – undo
56 56
 else $id_source = 1;
57 57
 if (isset($globalServer) && $globalServer) {
58 58
     if ($globalDebug) echo "Using Server Mode\n";
59
-    $SI=new SpotterServer();
60
-} else $SI=new SpotterImport($Connection->db);
59
+    $SI = new SpotterServer();
60
+} else $SI = new SpotterImport($Connection->db);
61 61
 //$APRS=new APRS($Connection->db);
62
-$SBS=new SBS();
63
-$ACARS=new ACARS($Connection->db);
64
-$Common=new Common();
62
+$SBS = new SBS();
63
+$ACARS = new ACARS($Connection->db);
64
+$Common = new Common();
65 65
 date_default_timezone_set('UTC');
66 66
 //$servertz = system('date +%Z');
67 67
 // signal handler - playing nice with sockets and dump1090
68 68
 if (function_exists('pcntl_fork')) {
69
-    pcntl_signal(SIGINT,  function() {
69
+    pcntl_signal(SIGINT, function() {
70 70
         global $sockets;
71 71
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
72 72
         die("Bye!\n");
@@ -109,34 +109,34 @@  discard block
 block discarded – undo
109 109
 
110 110
 function connect_all($hosts) {
111 111
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
112
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
112
+    global $sockets, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs;
113 113
     if ($globalDebug) echo 'Connect to all...'."\n";
114 114
     foreach ($hosts as $id => $value) {
115 115
 	$host = $value['host'];
116 116
 	$globalSources[$id]['last_exec'] = 0;
117 117
 	// Here we check type of source(s)
118
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
119
-            if (preg_match('/deltadb.txt$/i',$host)) {
118
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
119
+            if (preg_match('/deltadb.txt$/i', $host)) {
120 120
         	//$formats[$id] = 'deltadbtxt';
121 121
         	$globalSources[$id]['format'] = 'deltadbtxt';
122 122
         	//$last_exec['deltadbtxt'] = 0;
123 123
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
124
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
124
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
125 125
         	//$formats[$id] = 'vatsimtxt';
126 126
         	$globalSources[$id]['format'] = 'vatsimtxt';
127 127
         	//$last_exec['vatsimtxt'] = 0;
128 128
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
129
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
129
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
130 130
         	//$formats[$id] = 'aircraftlistjson';
131 131
         	$globalSources[$id]['format'] = 'aircraftlistjson';
132 132
         	//$last_exec['aircraftlistjson'] = 0;
133 133
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
134
-    	    } else if (preg_match('/opensky/i',$host)) {
134
+    	    } else if (preg_match('/opensky/i', $host)) {
135 135
         	//$formats[$id] = 'aircraftlistjson';
136 136
         	$globalSources[$id]['format'] = 'opensky';
137 137
         	//$last_exec['aircraftlistjson'] = 0;
138 138
         	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
139
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
139
+    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) {
140 140
         	//$formats[$id] = 'radarvirtueljson';
141 141
         	$globalSources[$id]['format'] = 'radarvirtueljson';
142 142
         	//$last_exec['radarvirtueljson'] = 0;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
146 146
         	    exit(0);
147 147
         	}
148
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
148
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
149 149
         	//$formats[$id] = 'planeupdatefaa';
150 150
         	$globalSources[$id]['format'] = 'planeupdatefaa';
151 151
         	//$last_exec['planeupdatefaa'] = 0;
@@ -154,26 +154,26 @@  discard block
 block discarded – undo
154 154
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
155 155
         	    exit(0);
156 156
         	}
157
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
157
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
158 158
         	//$formats[$id] = 'phpvmacars';
159 159
         	$globalSources[$id]['format'] = 'phpvmacars';
160 160
         	//$last_exec['phpvmacars'] = 0;
161 161
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
162
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
162
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
163 163
         	//$formats[$id] = 'phpvmacars';
164 164
         	$globalSources[$id]['format'] = 'vam';
165 165
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
166
-            } else if (preg_match('/whazzup/i',$host)) {
166
+            } else if (preg_match('/whazzup/i', $host)) {
167 167
         	//$formats[$id] = 'whazzup';
168 168
         	$globalSources[$id]['format'] = 'whazzup';
169 169
         	//$last_exec['whazzup'] = 0;
170 170
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
171
-            } else if (preg_match('/recentpireps/i',$host)) {
171
+            } else if (preg_match('/recentpireps/i', $host)) {
172 172
         	//$formats[$id] = 'pirepsjson';
173 173
         	$globalSources[$id]['format'] = 'pirepsjson';
174 174
         	//$last_exec['pirepsjson'] = 0;
175 175
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
176
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
176
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
177 177
         	//$formats[$id] = 'fr24json';
178 178
         	$globalSources[$id]['format'] = 'fr24json';
179 179
         	//$last_exec['fr24json'] = 0;
@@ -183,15 +183,15 @@  discard block
 block discarded – undo
183 183
         	    exit(0);
184 184
         	}
185 185
             //} else if (preg_match('/10001/',$host)) {
186
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
186
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
187 187
         	//$formats[$id] = 'tsv';
188 188
         	$globalSources[$id]['format'] = 'tsv';
189 189
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
190 190
             }
191
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
191
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
192 192
         	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
193
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
194
-	    $hostport = explode(':',$host);
193
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
194
+	    $hostport = explode(':', $host);
195 195
 	    if (isset($hostport[1])) {
196 196
 		$port = $hostport[1];
197 197
 		$hostn = $hostport[0];
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
 		$hostn = $globalSources[$id]['host'];
201 201
 	    }
202 202
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
203
-        	$s = create_socket($hostn,$port, $errno, $errstr);
203
+        	$s = create_socket($hostn, $port, $errno, $errstr);
204 204
     	    } else {
205
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
205
+        	$s = create_socket_udp($hostn, $port, $errno, $errstr);
206 206
 	    }
207 207
 	    if ($s) {
208 208
     	        $sockets[$id] = $s;
209 209
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
210
-		    if (preg_match('/aprs/',$hostn)) {
210
+		    if (preg_match('/aprs/', $hostn)) {
211 211
 			//$formats[$id] = 'aprs';
212 212
 			$globalSources[$id]['format'] = 'aprs';
213 213
 			//$aprs_connect = 0;
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
249 249
 else $timeout = 20;
250 250
 $errno = '';
251
-$errstr='';
251
+$errstr = '';
252 252
 
253 253
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
254 254
 /* Initiate connections to all the hosts simultaneously */
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 
278 278
 if ($use_aprs) {
279 279
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
280
-	$APRS=new APRS();
280
+	$APRS = new APRS();
281 281
 	$aprs_connect = 0;
282 282
 	$aprs_keep = 120;
283 283
 	$aprs_last_tx = time();
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	else $aprs_ssid = 'FAM';
289 289
 	//else $aprs_ssid = 'PerlEx';
290 290
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
291
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
291
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
292 292
 	if ($aprs_full) $aprs_filter = '';
293 293
 	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n";
294 294
 	else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n";
@@ -299,12 +299,12 @@  discard block
 block discarded – undo
299 299
 sleep(1);
300 300
 if ($globalDebug) echo "SCAN MODE \n\n";
301 301
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
302
-$endtime = time()+$globalCronEnd;
302
+$endtime = time() + $globalCronEnd;
303 303
 $i = 1;
304 304
 $tt = array();
305 305
 // Delete all ATC
306 306
 if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
307
-	$ATC=new ATC($Connection->db);
307
+	$ATC = new ATC($Connection->db);
308 308
 }
309 309
 if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
310 310
 	$ATC->deleteAll();
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 
313 313
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
314 314
 while ($i > 0) {
315
-    if (!$globalDaemon) $i = $endtime-time();
315
+    if (!$globalDaemon) $i = $endtime - time();
316 316
     // Delete old ATC
317 317
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
318 318
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	}
327 327
 	if ($max != $globalMinFetch) {
328 328
 	    if ($globalDebug) echo 'Sleeping...'."\n";
329
-	    sleep($globalMinFetch-$max+2);
329
+	    sleep($globalMinFetch - $max + 2);
330 330
 	}
331 331
     }
332 332
 
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
338 338
 	    //$buffer = $Common->getData($hosts[$id]);
339 339
 	    $buffer = $Common->getData($value['host']);
340
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
341
-	    $buffer = explode('\n',$buffer);
340
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
341
+	    $buffer = explode('\n', $buffer);
342 342
 	    foreach ($buffer as $line) {
343 343
     		if ($line != '') {
344 344
     		    $line = explode(',', $line);
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $value[' last_exec'] > $globalMinFetch))) {
368 368
 	    //$buffer = $Common->getData($hosts[$id]);
369 369
 	    $buffer = $Common->getData($value['host']);
370
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
371
-	    $buffer = explode('\n',$buffer);
370
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
371
+	    $buffer = explode('\n', $buffer);
372 372
 	    foreach ($buffer as $line) {
373 373
     		if ($line != '') {
374 374
     		    $line = explode(':', $line);
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 			$data['id'] = $line[1].'-'.$line[0];
378 378
 			$data['pilot_id'] = $line[1];
379 379
 			$data['pilot_name'] = $line[2];
380
-			$data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT);
380
+			$data['hex'] = str_pad(dechex($line[1]), 6, '000000', STR_PAD_LEFT);
381 381
 			$data['ident'] = $line[0]; // ident
382 382
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
383 383
 			$data['speed'] = $line[8]; // speed
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
394 394
 			if (isset($line[37])) $data['last_update'] = $line[37];
395 395
 		        $data['departure_airport_icao'] = $line[11];
396
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
396
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
397 397
 		        $data['arrival_airport_icao'] = $line[13];
398 398
 			$data['frequency'] = $line[4];
399 399
 			$data['type'] = $line[18];
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
     			$data['id_source'] = $id_source;
403 403
 	    		//$data['arrival_airport_time'] = ;
404 404
 	    		if ($line[9] != '') {
405
-	    		    $aircraft_data = explode('/',$line[9]);
405
+	    		    $aircraft_data = explode('/', $line[9]);
406 406
 	    		    if (isset($aircraft_data[1])) {
407 407
 	    			$data['aircraft_icao'] = $aircraft_data[1];
408 408
 	    		    }
@@ -416,9 +416,9 @@  discard block
 block discarded – undo
416 416
     			if ($line[3] == 'PILOT') $SI->add($data);
417 417
 			elseif ($line[3] == 'ATC') {
418 418
 				//print_r($data);
419
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
420
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
421
-				$typec = substr($data['ident'],-3);
419
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
420
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
421
+				$typec = substr($data['ident'], -3);
422 422
 				if ($typec == 'APP') $data['type'] = 'Approach';
423 423
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
424 424
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
430 430
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
431 431
 				
432
-				echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']);
432
+				echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name']);
433 433
 			}
434 434
     			unset($data);
435 435
     		    }
@@ -440,9 +440,9 @@  discard block
 block discarded – undo
440 440
     	    $last_exec[$id]['last'] = time();
441 441
     	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
442 442
     	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
443
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
443
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
444 444
 	    if ($buffer != '') {
445
-	    $all_data = json_decode($buffer,true);
445
+	    $all_data = json_decode($buffer, true);
446 446
 	    if (isset($all_data['acList'])) {
447 447
 		foreach ($all_data['acList'] as $line) {
448 448
 		    $data = array();
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
497 497
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
498 498
 	    $buffer = $Common->getData($value['host']);
499
-	    $all_data = json_decode($buffer,true);
499
+	    $all_data = json_decode($buffer, true);
500 500
 	    if (isset($all_data['planes'])) {
501 501
 		foreach ($all_data['planes'] as $key => $line) {
502 502
 		    $data = array();
@@ -512,12 +512,12 @@  discard block
 block discarded – undo
512 512
 		    $data['emergency'] = ''; // emergency
513 513
 		    $data['registration'] = $line[2];
514 514
 		    $data['aircraft_icao'] = $line[0];
515
-		    $deparr = explode('-',$line[1]);
515
+		    $deparr = explode('-', $line[1]);
516 516
 		    if (count($deparr) == 2) {
517 517
 			$data['departure_airport_icao'] = $deparr[0];
518 518
 			$data['arrival_airport_icao'] = $deparr[1];
519 519
 		    }
520
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
520
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
521 521
 	    	    $data['format_source'] = 'planeupdatefaa';
522 522
     		    $data['id_source'] = $id_source;
523 523
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
     	    $last_exec[$id]['last'] = time();
530 530
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
531 531
 	    $buffer = $Common->getData($value['host']);
532
-	    $all_data = json_decode($buffer,true);
532
+	    $all_data = json_decode($buffer, true);
533 533
 	    if (isset($all_data['states'])) {
534 534
 		foreach ($all_data['states'] as $key => $line) {
535 535
 		    $data = array();
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 		    //$data['emergency'] = ''; // emergency
546 546
 		    //$data['registration'] = $line[2];
547 547
 		    //$data['aircraft_icao'] = $line[0];
548
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
548
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
549 549
 	    	    $data['format_source'] = 'opensky';
550 550
     		    $data['id_source'] = $id_source;
551 551
 		    $SI->add($data);
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
559 559
 	    //$buffer = $Common->getData($hosts[$id]);
560 560
 	    $buffer = $Common->getData($value['host']);
561
-	    $all_data = json_decode($buffer,true);
561
+	    $all_data = json_decode($buffer, true);
562 562
 	    foreach ($all_data as $key => $line) {
563 563
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
564 564
 		    $data = array();
@@ -589,11 +589,11 @@  discard block
 block discarded – undo
589 589
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
590 590
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
591 591
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
592
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
592
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
593 593
 	    //echo $buffer;
594
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
595
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
596
-	    $all_data = json_decode($buffer,true);
594
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
595
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
596
+	    $all_data = json_decode($buffer, true);
597 597
 	    if (json_last_error() != JSON_ERROR_NONE) {
598 598
 		die(json_last_error_msg());
599 599
 	    }
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 			//$data['departure_airport_iata'] = $line[11];
616 616
 			//$data['arrival_airport_iata'] = $line[12];
617 617
 	    		//$data['emergency'] = ''; // emergency
618
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
618
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
619 619
 	    		$data['format_source'] = 'radarvirtueljson';
620 620
     			$data['id_source'] = $id_source;
621 621
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -630,13 +630,13 @@  discard block
 block discarded – undo
630 630
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
631 631
 	    //$buffer = $Common->getData($hosts[$id]);
632 632
 	    $buffer = $Common->getData($value['host'].'?'.time());
633
-	    $all_data = json_decode(utf8_encode($buffer),true);
633
+	    $all_data = json_decode(utf8_encode($buffer), true);
634 634
 	    
635 635
 	    if (isset($all_data['pireps'])) {
636 636
 	        foreach ($all_data['pireps'] as $line) {
637 637
 		    $data = array();
638 638
 		    $data['id'] = $line['id'];
639
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
639
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
640 640
 		    $data['ident'] = $line['callsign']; // ident
641 641
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
642 642
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -665,9 +665,9 @@  discard block
 block discarded – undo
665 665
 			$SI->add($data);
666 666
 		    //    print_r($data);
667 667
     		    } elseif ($line['icon'] == 'ct') {
668
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
669
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
670
-			$typec = substr($data['ident'],-3);
668
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
669
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
670
+			$typec = substr($data['ident'], -3);
671 671
 			$data['type'] = '';
672 672
 			if ($typec == 'APP') $data['type'] = 'Approach';
673 673
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
679 679
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
680 680
 			else $data['type'] = 'Observer';
681
-			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']);
681
+			echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name']);
682 682
 		    }
683 683
 		    unset($data);
684 684
 		}
@@ -690,13 +690,13 @@  discard block
 block discarded – undo
690 690
 	    //$buffer = $Common->getData($hosts[$id]);
691 691
 	    if ($globalDebug) echo 'Get Data...'."\n";
692 692
 	    $buffer = $Common->getData($value['host']);
693
-	    $all_data = json_decode($buffer,true);
693
+	    $all_data = json_decode($buffer, true);
694 694
 	    if ($buffer != '' && is_array($all_data)) {
695 695
 		foreach ($all_data as $line) {
696 696
 	    	    $data = array();
697 697
 	    	    //$data['id'] = $line['id']; // id not usable
698 698
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
699
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
699
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
700 700
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
701 701
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
702 702
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -719,12 +719,12 @@  discard block
 block discarded – undo
719 719
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
720 720
 		    if (isset($line['aircraftname'])) {
721 721
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
722
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
723
-	    		$aircraft_data = explode('-',$line['aircraftname']);
722
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
723
+	    		$aircraft_data = explode('-', $line['aircraftname']);
724 724
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
725 725
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
726 726
 	    		else {
727
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
727
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
728 728
 	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
729 729
 	    		    else $data['aircraft_icao'] = $line['aircraftname'];
730 730
 	    		}
@@ -746,13 +746,13 @@  discard block
 block discarded – undo
746 746
 	    //$buffer = $Common->getData($hosts[$id]);
747 747
 	    if ($globalDebug) echo 'Get Data...'."\n";
748 748
 	    $buffer = $Common->getData($value['host']);
749
-	    $all_data = json_decode($buffer,true);
749
+	    $all_data = json_decode($buffer, true);
750 750
 	    if ($buffer != '' && is_array($all_data)) {
751 751
 		foreach ($all_data as $line) {
752 752
 	    	    $data = array();
753 753
 	    	    //$data['id'] = $line['id']; // id not usable
754 754
 	    	    $data['id'] = $line['flight_id'];
755
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
755
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
756 756
 	    	    $data['pilot_name'] = $line['pilot_name'];
757 757
 	    	    $data['pilot_id'] = $line['pilot_id'];
758 758
 	    	    $data['ident'] = $line['callsign']; // ident
@@ -802,9 +802,9 @@  discard block
 block discarded – undo
802 802
 		    //$value = $formats[$nb];
803 803
 		    $format = $globalSources[$nb]['format'];
804 804
         	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv') {
805
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
805
+        		$buffer = socket_read($r, 6000, PHP_NORMAL_READ);
806 806
         	    } else {
807
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
807
+	    	        $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
808 808
 	    	    }
809 809
         	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
810 810
         	    //echo $buffer."\n";
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
 		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
813 813
 		    $error = false;
814 814
 		    //$SI::del();
815
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
815
+		    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
816 816
 		    // SBS format is CSV format
817 817
 		    if ($buffer != '') {
818 818
 			$tt[$format] = 0;
@@ -831,10 +831,10 @@  discard block
 block discarded – undo
831 831
                         } elseif ($format == 'flightgearsp') {
832 832
                     	    //echo $buffer."\n";
833 833
                     	    if (strlen($buffer) > 5) {
834
-				$line = explode(',',$buffer);
834
+				$line = explode(',', $buffer);
835 835
 				$data = array();
836 836
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
837
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
837
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
838 838
 				$data['ident'] = $line[6];
839 839
 				$data['aircraft_name'] = $line[7];
840 840
 				$data['longitude'] = $line[1];
@@ -845,21 +845,21 @@  discard block
 block discarded – undo
845 845
 				$data['datetime'] = date('Y-m-d H:i:s');
846 846
 				$data['format_source'] = 'flightgearsp';
847 847
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
848
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
848
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
849 849
 			    }
850 850
                         } elseif ($format == 'acars') {
851 851
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
852 852
 			    $ACARS->add(trim($buffer));
853
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
853
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
854 854
 			    $ACARS->deleteLiveAcarsData();
855 855
 			} elseif ($format == 'flightgearmp') {
856
-			    if (substr($buffer,0,1) != '#') {
856
+			    if (substr($buffer, 0, 1) != '#') {
857 857
 				$data = array();
858 858
 				//echo $buffer."\n";
859
-				$line = explode(' ',$buffer);
859
+				$line = explode(' ', $buffer);
860 860
 				if (count($line) == 11) {
861
-				    $userserver = explode('@',$line[0]);
862
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
861
+				    $userserver = explode('@', $line[0]);
862
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
863 863
 				    $data['ident'] = $userserver[0];
864 864
 				    $data['registration'] = $userserver[0];
865 865
 				    $data['latitude'] = $line[4];
@@ -867,24 +867,24 @@  discard block
 block discarded – undo
867 867
 				    $data['altitude'] = $line[6];
868 868
 				    $data['datetime'] = date('Y-m-d H:i:s');
869 869
 				    $aircraft_type = $line[10];
870
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
871
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
870
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
871
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
872 872
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
873 873
 				}
874 874
 			    }
875 875
 			} elseif ($format == 'beast') {
876 876
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
877 877
 			    die;
878
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
878
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
879 879
 			    $line = explode("\t", $buffer);
880
-			    for($k = 0; $k < count($line); $k=$k+2) {
880
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
881 881
 				$key = $line[$k];
882
-			        $lined[$key] = $line[$k+1];
882
+			        $lined[$key] = $line[$k + 1];
883 883
 			    }
884 884
     			    if (count($lined) > 3) {
885 885
     				$data['hex'] = $lined['hexid'];
886 886
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
887
-    				$data['datetime'] = date('Y-m-d H:i:s');;
887
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
888 888
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
889 889
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
890 890
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -902,24 +902,24 @@  discard block
 block discarded – undo
902 902
     			    } else $error = true;
903 903
 			} elseif ($format == 'aprs' && $use_aprs) {
904 904
 			    if ($aprs_connect == 0) {
905
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
905
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
906 906
 				$aprs_connect = 1;
907 907
 			    }
908
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
908
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
909 909
 				$aprs_last_tx = time();
910 910
 				$data_aprs = "# Keep alive";
911
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
911
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
912 912
 			    }
913 913
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
914
-			    $buffer = str_replace('APRS <- ','',$buffer);
915
-			    $buffer = str_replace('APRS -> ','',$buffer);
916
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
914
+			    $buffer = str_replace('APRS <- ', '', $buffer);
915
+			    $buffer = str_replace('APRS -> ', '', $buffer);
916
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
917 917
 				$line = $APRS->parse($buffer);
918 918
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
919 919
 				    $data = array();
920 920
 				    //print_r($line);
921 921
 				    $data['hex'] = $line['address'];
922
-				    $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
922
+				    $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
923 923
 				    //$data['datetime'] = date('Y-m-d H:i:s');
924 924
 				    $data['ident'] = $line['ident'];
925 925
 				    $data['latitude'] = $line['latitude'];
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
 				    $currentdate = date('Y-m-d H:i:s');
940 940
 				    $aprsdate = strtotime($data['datetime']);
941 941
 				    // Accept data if time <= system time + 20s
942
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
942
+				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
943 943
 				    else {
944 944
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
945 945
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
 				connect_all($sourceee);
1025 1025
 				$sourceee = array();
1026 1026
 				//connect_all($globalSources);
1027
-				$tt[$format]=0;
1027
+				$tt[$format] = 0;
1028 1028
 				break;
1029 1029
 			    }
1030 1030
 			}
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
 		}
1033 1033
 	    } else {
1034 1034
 		$error = socket_strerror(socket_last_error());
1035
-		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1035
+		if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1036 1036
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY) || time() - $time >= $timeout) {
1037 1037
 			if (isset($globalDebug)) echo "Restarting...\n";
1038 1038
 			// Restart the script if possible
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 			    if ($globalDebug) echo "Shutdown all sockets...";
1041 1041
 			    
1042 1042
 			    foreach ($sockets as $sock) {
1043
-				@socket_shutdown($sock,2);
1043
+				@socket_shutdown($sock, 2);
1044 1044
 				@socket_close($sock);
1045 1045
 			    }
1046 1046
 			    
Please login to merge, or discard this patch.
Braces   +532 added lines, -182 removed lines patch added patch discarded remove patch
@@ -14,7 +14,9 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16 16
 
17
-if (!isset($globalDebug)) $globalDebug = FALSE;
17
+if (!isset($globalDebug)) {
18
+	$globalDebug = FALSE;
19
+}
18 20
 
19 21
 // Check if schema is at latest version
20 22
 $Connection = new Connection();
@@ -51,13 +53,22 @@  discard block
 block discarded – undo
51 53
     $globalSources = array();
52 54
     $globalSources[] = array('host' => $options['source']);
53 55
 }
54
-if (isset($options['server'])) $globalServer = TRUE;
55
-if (isset($options['idsource'])) $id_source = $options['idsource'];
56
-else $id_source = 1;
56
+if (isset($options['server'])) {
57
+	$globalServer = TRUE;
58
+}
59
+if (isset($options['idsource'])) {
60
+	$id_source = $options['idsource'];
61
+} else {
62
+	$id_source = 1;
63
+}
57 64
 if (isset($globalServer) && $globalServer) {
58
-    if ($globalDebug) echo "Using Server Mode\n";
65
+    if ($globalDebug) {
66
+    	echo "Using Server Mode\n";
67
+    }
59 68
     $SI=new SpotterServer();
60
-} else $SI=new SpotterImport($Connection->db);
69
+} else {
70
+	$SI=new SpotterImport($Connection->db);
71
+}
61 72
 //$APRS=new APRS($Connection->db);
62 73
 $SBS=new SBS();
63 74
 $ACARS=new ACARS($Connection->db);
@@ -75,7 +86,9 @@  discard block
 block discarded – undo
75 86
 }
76 87
 
77 88
 // let's try and connect
78
-if ($globalDebug) echo "Connecting...\n";
89
+if ($globalDebug) {
90
+	echo "Connecting...\n";
91
+}
79 92
 $use_aprs = false;
80 93
 $aprs_full = false;
81 94
 
@@ -83,7 +96,9 @@  discard block
 block discarded – undo
83 96
     $ip = gethostbyname($host);
84 97
     $s = socket_create(AF_INET, SOCK_STREAM, 0);
85 98
     $r = @socket_connect($s, $ip, $port);
86
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
99
+    if (!socket_set_nonblock($s)) {
100
+    	echo "Unable to set nonblock on socket\n";
101
+    }
87 102
     if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
88 103
         return $s;
89 104
     }
@@ -110,7 +125,9 @@  discard block
 block discarded – undo
110 125
 function connect_all($hosts) {
111 126
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
112 127
     global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
113
-    if ($globalDebug) echo 'Connect to all...'."\n";
128
+    if ($globalDebug) {
129
+    	echo 'Connect to all...'."\n";
130
+    }
114 131
     foreach ($hosts as $id => $value) {
115 132
 	$host = $value['host'];
116 133
 	$globalSources[$id]['last_exec'] = 0;
@@ -120,27 +137,37 @@  discard block
 block discarded – undo
120 137
         	//$formats[$id] = 'deltadbtxt';
121 138
         	$globalSources[$id]['format'] = 'deltadbtxt';
122 139
         	//$last_exec['deltadbtxt'] = 0;
123
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
140
+        	if ($globalDebug) {
141
+        		echo "Connect to deltadb source (".$host.")...\n";
142
+        	}
124 143
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
125 144
         	//$formats[$id] = 'vatsimtxt';
126 145
         	$globalSources[$id]['format'] = 'vatsimtxt';
127 146
         	//$last_exec['vatsimtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
147
+        	if ($globalDebug) {
148
+        		echo "Connect to vatsim source (".$host.")...\n";
149
+        	}
129 150
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
130 151
         	//$formats[$id] = 'aircraftlistjson';
131 152
         	$globalSources[$id]['format'] = 'aircraftlistjson';
132 153
         	//$last_exec['aircraftlistjson'] = 0;
133
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
154
+        	if ($globalDebug) {
155
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
156
+        	}
134 157
     	    } else if (preg_match('/opensky/i',$host)) {
135 158
         	//$formats[$id] = 'aircraftlistjson';
136 159
         	$globalSources[$id]['format'] = 'opensky';
137 160
         	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
161
+        	if ($globalDebug) {
162
+        		echo "Connect to opensky source (".$host.")...\n";
163
+        	}
139 164
     	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
140 165
         	//$formats[$id] = 'radarvirtueljson';
141 166
         	$globalSources[$id]['format'] = 'radarvirtueljson';
142 167
         	//$last_exec['radarvirtueljson'] = 0;
143
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
168
+        	if ($globalDebug) {
169
+        		echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
170
+        	}
144 171
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
145 172
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
146 173
         	    exit(0);
@@ -149,7 +176,9 @@  discard block
 block discarded – undo
149 176
         	//$formats[$id] = 'planeupdatefaa';
150 177
         	$globalSources[$id]['format'] = 'planeupdatefaa';
151 178
         	//$last_exec['planeupdatefaa'] = 0;
152
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
179
+        	if ($globalDebug) {
180
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
181
+        	}
153 182
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
154 183
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
155 184
         	    exit(0);
@@ -158,26 +187,36 @@  discard block
 block discarded – undo
158 187
         	//$formats[$id] = 'phpvmacars';
159 188
         	$globalSources[$id]['format'] = 'phpvmacars';
160 189
         	//$last_exec['phpvmacars'] = 0;
161
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
190
+        	if ($globalDebug) {
191
+        		echo "Connect to phpvmacars source (".$host.")...\n";
192
+        	}
162 193
             } else if (preg_match('/VAM-json.php$/i',$host)) {
163 194
         	//$formats[$id] = 'phpvmacars';
164 195
         	$globalSources[$id]['format'] = 'vam';
165
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
196
+        	if ($globalDebug) {
197
+        		echo "Connect to Vam source (".$host.")...\n";
198
+        	}
166 199
             } else if (preg_match('/whazzup/i',$host)) {
167 200
         	//$formats[$id] = 'whazzup';
168 201
         	$globalSources[$id]['format'] = 'whazzup';
169 202
         	//$last_exec['whazzup'] = 0;
170
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
203
+        	if ($globalDebug) {
204
+        		echo "Connect to whazzup source (".$host.")...\n";
205
+        	}
171 206
             } else if (preg_match('/recentpireps/i',$host)) {
172 207
         	//$formats[$id] = 'pirepsjson';
173 208
         	$globalSources[$id]['format'] = 'pirepsjson';
174 209
         	//$last_exec['pirepsjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
210
+        	if ($globalDebug) {
211
+        		echo "Connect to pirepsjson source (".$host.")...\n";
212
+        	}
176 213
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
177 214
         	//$formats[$id] = 'fr24json';
178 215
         	$globalSources[$id]['format'] = 'fr24json';
179 216
         	//$last_exec['fr24json'] = 0;
180
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
217
+        	if ($globalDebug) {
218
+        		echo "Connect to fr24 source (".$host.")...\n";
219
+        	}
181 220
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
182 221
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
183 222
         	    exit(0);
@@ -186,10 +225,14 @@  discard block
 block discarded – undo
186 225
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
187 226
         	//$formats[$id] = 'tsv';
188 227
         	$globalSources[$id]['format'] = 'tsv';
189
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
228
+        	if ($globalDebug) {
229
+        		echo "Connect to tsv source (".$host.")...\n";
230
+        	}
190 231
             }
191 232
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
192
-        	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
233
+        	if ($globalDebug) {
234
+        		echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
235
+        	}
193 236
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
194 237
 	    $hostport = explode(':',$host);
195 238
 	    if (isset($hostport[1])) {
@@ -226,17 +269,25 @@  discard block
 block discarded – undo
226 269
         		//$formats[$id] = 'beast';
227 270
         		$globalSources[$id]['format'] = 'beast';
228 271
 		    //} else $formats[$id] = 'sbs';
229
-		    } else $globalSources[$id]['format'] = 'sbs';
272
+		    } else {
273
+		    	$globalSources[$id]['format'] = 'sbs';
274
+		    }
230 275
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
231 276
 		}
232
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
277
+		if ($globalDebug) {
278
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
279
+		}
233 280
             } else {
234
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
281
+		if ($globalDebug) {
282
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
283
+		}
235 284
     	    }
236 285
         }
237 286
     }
238 287
 }
239
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
288
+if (!isset($globalMinFetch)) {
289
+	$globalMinFetch = 15;
290
+}
240 291
 
241 292
 // Initialize all
242 293
 $status = array();
@@ -244,13 +295,19 @@  discard block
 block discarded – undo
244 295
 $formats = array();
245 296
 $last_exec = array();
246 297
 $time = time();
247
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
248
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
249
-else $timeout = 20;
298
+if (isset($globalSourcesTimeout)) {
299
+	$timeout = $globalSourcesTimeOut;
300
+} else if (isset($globalSBS1TimeOut)) {
301
+	$timeout = $globalSBS1TimeOut;
302
+} else {
303
+	$timeout = 20;
304
+}
250 305
 $errno = '';
251 306
 $errstr='';
252 307
 
253
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
308
+if (!isset($globalDaemon)) {
309
+	$globalDaemon = TRUE;
310
+}
254 311
 /* Initiate connections to all the hosts simultaneously */
255 312
 //connect_all($hosts);
256 313
 //connect_all($globalSources);
@@ -270,7 +327,9 @@  discard block
 block discarded – undo
270 327
     if (isset($source['format']) && $source['format'] == 'aprs') {
271 328
 	$aprs_connect = 0;
272 329
 	$use_aprs = true;
273
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
330
+	if (isset($source['port']) && $source['port'] == '10152') {
331
+		$aprs_full = true;
332
+	}
274 333
 	break;
275 334
     }
276 335
 }
@@ -281,24 +340,44 @@  discard block
 block discarded – undo
281 340
 	$aprs_connect = 0;
282 341
 	$aprs_keep = 120;
283 342
 	$aprs_last_tx = time();
284
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
285
-	else $aprs_version = $globalName.' using FlightAirMap';
343
+	if (isset($globalAPRSversion)) {
344
+		$aprs_version = $globalAPRSversion;
345
+	} else {
346
+		$aprs_version = $globalName.' using FlightAirMap';
347
+	}
286 348
 	//else $aprs_version = 'Perl Example App';
287
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
288
-	else $aprs_ssid = 'FAM';
349
+	if (isset($globalAPRSssid)) {
350
+		$aprs_ssid = $globalAPRSssid;
351
+	} else {
352
+		$aprs_ssid = 'FAM';
353
+	}
289 354
 	//else $aprs_ssid = 'PerlEx';
290
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
291
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
292
-	if ($aprs_full) $aprs_filter = '';
293
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n";
294
-	else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n";
295
-}
355
+	if (isset($globalAPRSfilter)) {
356
+		$aprs_filter = $globalAPRSfilter;
357
+	} else {
358
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
359
+	}
360
+	if ($aprs_full) {
361
+		$aprs_filter = '';
362
+	}
363
+	if ($aprs_filter != '') {
364
+		$aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n";
365
+	} else {
366
+		$aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n";
367
+	}
368
+	}
296 369
 
297 370
 // connected - lets do some work
298
-if ($globalDebug) echo "Connected!\n";
371
+if ($globalDebug) {
372
+	echo "Connected!\n";
373
+}
299 374
 sleep(1);
300
-if ($globalDebug) echo "SCAN MODE \n\n";
301
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
375
+if ($globalDebug) {
376
+	echo "SCAN MODE \n\n";
377
+}
378
+if (!isset($globalCronEnd)) {
379
+	$globalCronEnd = 60;
380
+}
302 381
 $endtime = time()+$globalCronEnd;
303 382
 $i = 1;
304 383
 $tt = array();
@@ -312,20 +391,28 @@  discard block
 block discarded – undo
312 391
 
313 392
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
314 393
 while ($i > 0) {
315
-    if (!$globalDaemon) $i = $endtime-time();
394
+    if (!$globalDaemon) {
395
+    	$i = $endtime-time();
396
+    }
316 397
     // Delete old ATC
317 398
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
318
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
399
+	if ($globalDebug) {
400
+		echo 'Delete old ATC...'."\n";
401
+	}
319 402
         $ATC->deleteOldATC();
320 403
     }
321 404
     
322 405
     if (count($last_exec) > 0) {
323 406
 	$max = $globalMinFetch;
324 407
 	foreach ($last_exec as $last) {
325
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
408
+	    if ((time() - $last['last']) < $max) {
409
+	    	$max = time() - $last['last'];
410
+	    }
326 411
 	}
327 412
 	if ($max != $globalMinFetch) {
328
-	    if ($globalDebug) echo 'Sleeping...'."\n";
413
+	    if ($globalDebug) {
414
+	    	echo 'Sleeping...'."\n";
415
+	    }
329 416
 	    sleep($globalMinFetch-$max+2);
330 417
 	}
331 418
     }
@@ -333,7 +420,9 @@  discard block
 block discarded – undo
333 420
     
334 421
     //foreach ($formats as $id => $value) {
335 422
     foreach ($globalSources as $id => $value) {
336
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
423
+	if (!isset($last_exec[$id]['last'])) {
424
+		$last_exec[$id]['last'] = 0;
425
+	}
337 426
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
338 427
 	    //$buffer = $Common->getData($hosts[$id]);
339 428
 	    $buffer = $Common->getData($value['host']);
@@ -345,19 +434,38 @@  discard block
 block discarded – undo
345 434
 	            $data = array();
346 435
 	            $data['hex'] = $line[1]; // hex
347 436
 	            $data['ident'] = $line[2]; // ident
348
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
349
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
350
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
351
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
352
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
437
+	            if (isset($line[3])) {
438
+	            	$data['altitude'] = $line[3];
439
+	            }
440
+	            // altitude
441
+	            if (isset($line[4])) {
442
+	            	$data['speed'] = $line[4];
443
+	            }
444
+	            // speed
445
+	            if (isset($line[5])) {
446
+	            	$data['heading'] = $line[5];
447
+	            }
448
+	            // heading
449
+	            if (isset($line[6])) {
450
+	            	$data['latitude'] = $line[6];
451
+	            }
452
+	            // lat
453
+	            if (isset($line[7])) {
454
+	            	$data['longitude'] = $line[7];
455
+	            }
456
+	            // long
353 457
 	            $data['verticalrate'] = ''; // vertical rate
354 458
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
355 459
 	            $data['emergency'] = ''; // emergency
356 460
 		    $data['datetime'] = date('Y-m-d H:i:s');
357 461
 		    $data['format_source'] = 'deltadbtxt';
358 462
     		    $data['id_source'] = $id_source;
359
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
360
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
463
+		    if (isset($value['name']) && $value['name'] != '') {
464
+		    	$data['source_name'] = $value['name'];
465
+		    }
466
+		    if (isset($value['sourcestats'])) {
467
+		    	$data['sourcestats'] = $value['sourcestats'];
468
+		    }
361 469
     		    $SI->add($data);
362 470
 		    unset($data);
363 471
     		}
@@ -379,10 +487,19 @@  discard block
 block discarded – undo
379 487
 			$data['pilot_name'] = $line[2];
380 488
 			$data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT);
381 489
 			$data['ident'] = $line[0]; // ident
382
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
490
+			if ($line[7] != '' && $line[7] != 0) {
491
+				$data['altitude'] = $line[7];
492
+			}
493
+			// altitude
383 494
 			$data['speed'] = $line[8]; // speed
384
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
385
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
495
+			if (isset($line[45])) {
496
+				$data['heading'] = $line[45];
497
+			}
498
+			// heading
499
+			elseif (isset($line[38])) {
500
+				$data['heading'] = $line[38];
501
+			}
502
+			// heading
386 503
 			$data['latitude'] = $line[5]; // lat
387 504
 	        	$data['longitude'] = $line[6]; // long
388 505
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -391,14 +508,18 @@  discard block
 block discarded – undo
391 508
 	        	$data['waypoints'] = $line[30];
392 509
 			$data['datetime'] = date('Y-m-d H:i:s');
393 510
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
394
-			if (isset($line[37])) $data['last_update'] = $line[37];
511
+			if (isset($line[37])) {
512
+				$data['last_update'] = $line[37];
513
+			}
395 514
 		        $data['departure_airport_icao'] = $line[11];
396 515
 		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
397 516
 		        $data['arrival_airport_icao'] = $line[13];
398 517
 			$data['frequency'] = $line[4];
399 518
 			$data['type'] = $line[18];
400 519
 			$data['range'] = $line[19];
401
-			if (isset($line[35])) $data['info'] = $line[35];
520
+			if (isset($line[35])) {
521
+				$data['info'] = $line[35];
522
+			}
402 523
     			$data['id_source'] = $id_source;
403 524
 	    		//$data['arrival_airport_time'] = ;
404 525
 	    		if ($line[9] != '') {
@@ -412,22 +533,35 @@  discard block
 block discarded – undo
412 533
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
413 534
 	    		*/
414 535
 	    		$data['format_source'] = $value['format'];
415
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
416
-    			if ($line[3] == 'PILOT') $SI->add($data);
417
-			elseif ($line[3] == 'ATC') {
536
+			if (isset($value['name']) && $value['name'] != '') {
537
+				$data['source_name'] = $value['name'];
538
+			}
539
+    			if ($line[3] == 'PILOT') {
540
+    				$SI->add($data);
541
+    			} elseif ($line[3] == 'ATC') {
418 542
 				//print_r($data);
419 543
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
420 544
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
421 545
 				$typec = substr($data['ident'],-3);
422
-				if ($typec == 'APP') $data['type'] = 'Approach';
423
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
424
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
425
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
426
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
427
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
428
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
429
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
430
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
546
+				if ($typec == 'APP') {
547
+					$data['type'] = 'Approach';
548
+				} elseif ($typec == 'TWR') {
549
+					$data['type'] = 'Tower';
550
+				} elseif ($typec == 'OBS') {
551
+					$data['type'] = 'Observer';
552
+				} elseif ($typec == 'GND') {
553
+					$data['type'] = 'Ground';
554
+				} elseif ($typec == 'DEL') {
555
+					$data['type'] = 'Delivery';
556
+				} elseif ($typec == 'DEP') {
557
+					$data['type'] = 'Departure';
558
+				} elseif ($typec == 'FSS') {
559
+					$data['type'] = 'Flight Service Station';
560
+				} elseif ($typec == 'CTR') {
561
+					$data['type'] = 'Control Radar or Centre';
562
+				} elseif ($data['type'] == '') {
563
+					$data['type'] = 'Observer';
564
+				}
431 565
 				
432 566
 				echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']);
433 567
 			}
@@ -447,26 +581,55 @@  discard block
 block discarded – undo
447 581
 		foreach ($all_data['acList'] as $line) {
448 582
 		    $data = array();
449 583
 		    $data['hex'] = $line['Icao']; // hex
450
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
451
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
452
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
453
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
454
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
455
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
584
+		    if (isset($line['Call'])) {
585
+		    	$data['ident'] = $line['Call'];
586
+		    }
587
+		    // ident
588
+		    if (isset($line['Alt'])) {
589
+		    	$data['altitude'] = $line['Alt'];
590
+		    }
591
+		    // altitude
592
+		    if (isset($line['Spd'])) {
593
+		    	$data['speed'] = $line['Spd'];
594
+		    }
595
+		    // speed
596
+		    if (isset($line['Trak'])) {
597
+		    	$data['heading'] = $line['Trak'];
598
+		    }
599
+		    // heading
600
+		    if (isset($line['Lat'])) {
601
+		    	$data['latitude'] = $line['Lat'];
602
+		    }
603
+		    // lat
604
+		    if (isset($line['Long'])) {
605
+		    	$data['longitude'] = $line['Long'];
606
+		    }
607
+		    // long
456 608
 		    //$data['verticalrate'] = $line['']; // verticale rate
457
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
609
+		    if (isset($line['Sqk'])) {
610
+		    	$data['squawk'] = $line['Sqk'];
611
+		    }
612
+		    // squawk
458 613
 		    $data['emergency'] = ''; // emergency
459
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
614
+		    if (isset($line['Reg'])) {
615
+		    	$data['registration'] = $line['Reg'];
616
+		    }
460 617
 		    /*
461 618
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
462 619
 		    else $data['datetime'] = date('Y-m-d H:i:s');
463 620
 		    */
464 621
 		    $data['datetime'] = date('Y-m-d H:i:s');
465
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
622
+		    if (isset($line['Type'])) {
623
+		    	$data['aircraft_icao'] = $line['Type'];
624
+		    }
466 625
 	    	    $data['format_source'] = 'aircraftlistjson';
467 626
 		    $data['id_source'] = $id_source;
468
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
469
-		    if (isset($data['datetime'])) $SI->add($data);
627
+		    if (isset($value['name']) && $value['name'] != '') {
628
+		    	$data['source_name'] = $value['name'];
629
+		    }
630
+		    if (isset($data['datetime'])) {
631
+		    	$SI->add($data);
632
+		    }
470 633
 		    unset($data);
471 634
 		}
472 635
 	    } else {
@@ -485,7 +648,9 @@  discard block
 block discarded – undo
485 648
 		    $data['datetime'] = date('Y-m-d H:i:s');
486 649
 	    	    $data['format_source'] = 'aircraftlistjson';
487 650
     		    $data['id_source'] = $id_source;
488
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
651
+		    if (isset($value['name']) && $value['name'] != '') {
652
+		    	$data['source_name'] = $value['name'];
653
+		    }
489 654
 		    $SI->add($data);
490 655
 		    unset($data);
491 656
 		}
@@ -520,7 +685,9 @@  discard block
 block discarded – undo
520 685
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
521 686
 	    	    $data['format_source'] = 'planeupdatefaa';
522 687
     		    $data['id_source'] = $id_source;
523
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
688
+		    if (isset($value['name']) && $value['name'] != '') {
689
+		    	$data['source_name'] = $value['name'];
690
+		    }
524 691
 		    $SI->add($data);
525 692
 		    unset($data);
526 693
 		}
@@ -579,7 +746,9 @@  discard block
 block discarded – undo
579 746
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
580 747
 	    	    $data['format_source'] = 'fr24json';
581 748
     		    $data['id_source'] = $id_source;
582
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
749
+		    if (isset($value['name']) && $value['name'] != '') {
750
+		    	$data['source_name'] = $value['name'];
751
+		    }
583 752
 		    $SI->add($data);
584 753
 		    unset($data);
585 754
 		}
@@ -602,23 +771,39 @@  discard block
 block discarded – undo
602 771
 		    if (isset($line['inf'])) {
603 772
 			$data = array();
604 773
 			$data['hex'] = $line['inf']['ia'];
605
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
774
+			if (isset($line['inf']['cs'])) {
775
+				$data['ident'] = $line['inf']['cs'];
776
+			}
777
+			//$line[13]
606 778
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
607
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
608
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
779
+	    		if (isset($line['inf']['gs'])) {
780
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
781
+	    		}
782
+	    		// speed
783
+	    		if (isset($line['inf']['tr'])) {
784
+	    			$data['heading'] = $line['inf']['tr'];
785
+	    		}
786
+	    		// heading
609 787
 	    		$data['latitude'] = $line['pt'][0]; // lat
610 788
 	    		$data['longitude'] = $line['pt'][1]; // long
611 789
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
612
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
790
+	    		if (isset($line['inf']['sq'])) {
791
+	    			$data['squawk'] = $line['inf']['sq'];
792
+	    		}
793
+	    		// squawk
613 794
 	    		//$data['aircraft_icao'] = $line[8];
614
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
795
+	    		if (isset($line['inf']['rc'])) {
796
+	    			$data['registration'] = $line['inf']['rc'];
797
+	    		}
615 798
 			//$data['departure_airport_iata'] = $line[11];
616 799
 			//$data['arrival_airport_iata'] = $line[12];
617 800
 	    		//$data['emergency'] = ''; // emergency
618 801
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
619 802
 	    		$data['format_source'] = 'radarvirtueljson';
620 803
     			$data['id_source'] = $id_source;
621
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
804
+			if (isset($value['name']) && $value['name'] != '') {
805
+				$data['source_name'] = $value['name'];
806
+			}
622 807
 			$SI->add($data);
623 808
 			unset($data);
624 809
 		    }
@@ -638,29 +823,62 @@  discard block
 block discarded – undo
638 823
 		    $data['id'] = $line['id'];
639 824
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
640 825
 		    $data['ident'] = $line['callsign']; // ident
641
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
642
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
643
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
644
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
645
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
646
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
826
+		    if (isset($line['pilotid'])) {
827
+		    	$data['pilot_id'] = $line['pilotid'];
828
+		    }
829
+		    // pilot id
830
+		    if (isset($line['name'])) {
831
+		    	$data['pilot_name'] = $line['name'];
832
+		    }
833
+		    // pilot name
834
+		    if (isset($line['alt'])) {
835
+		    	$data['altitude'] = $line['alt'];
836
+		    }
837
+		    // altitude
838
+		    if (isset($line['gs'])) {
839
+		    	$data['speed'] = $line['gs'];
840
+		    }
841
+		    // speed
842
+		    if (isset($line['heading'])) {
843
+		    	$data['heading'] = $line['heading'];
844
+		    }
845
+		    // heading
846
+		    if (isset($line['route'])) {
847
+		    	$data['waypoints'] = $line['route'];
848
+		    }
849
+		    // route
647 850
 		    $data['latitude'] = $line['lat']; // lat
648 851
 		    $data['longitude'] = $line['lon']; // long
649 852
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
650 853
 		    //$data['squawk'] = $line['squawk']; // squawk
651 854
 		    //$data['emergency'] = ''; // emergency
652
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
653
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
654
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
855
+		    if (isset($line['depicao'])) {
856
+		    	$data['departure_airport_icao'] = $line['depicao'];
857
+		    }
858
+		    if (isset($line['deptime'])) {
859
+		    	$data['departure_airport_time'] = $line['deptime'];
860
+		    }
861
+		    if (isset($line['arricao'])) {
862
+		    	$data['arrival_airport_icao'] = $line['arricao'];
863
+		    }
655 864
 		    //$data['arrival_airport_time'] = $line['arrtime'];
656
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
657
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
658
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
659
-		    else $data['info'] = '';
865
+		    if (isset($line['aircraft'])) {
866
+		    	$data['aircraft_icao'] = $line['aircraft'];
867
+		    }
868
+		    if (isset($line['transponder'])) {
869
+		    	$data['squawk'] = $line['transponder'];
870
+		    }
871
+		    if (isset($line['atis'])) {
872
+		    	$data['info'] = $line['atis'];
873
+		    } else {
874
+		    	$data['info'] = '';
875
+		    }
660 876
 		    $data['format_source'] = 'pireps';
661 877
     		    $data['id_source'] = $id_source;
662 878
 		    $data['datetime'] = date('Y-m-d H:i:s');
663
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
879
+		    if (isset($value['name']) && $value['name'] != '') {
880
+		    	$data['source_name'] = $value['name'];
881
+		    }
664 882
 		    if ($line['icon'] == 'plane') {
665 883
 			$SI->add($data);
666 884
 		    //    print_r($data);
@@ -669,15 +887,25 @@  discard block
 block discarded – undo
669 887
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
670 888
 			$typec = substr($data['ident'],-3);
671 889
 			$data['type'] = '';
672
-			if ($typec == 'APP') $data['type'] = 'Approach';
673
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
674
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
675
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
676
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
677
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
678
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
679
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
680
-			else $data['type'] = 'Observer';
890
+			if ($typec == 'APP') {
891
+				$data['type'] = 'Approach';
892
+			} elseif ($typec == 'TWR') {
893
+				$data['type'] = 'Tower';
894
+			} elseif ($typec == 'OBS') {
895
+				$data['type'] = 'Observer';
896
+			} elseif ($typec == 'GND') {
897
+				$data['type'] = 'Ground';
898
+			} elseif ($typec == 'DEL') {
899
+				$data['type'] = 'Delivery';
900
+			} elseif ($typec == 'DEP') {
901
+				$data['type'] = 'Departure';
902
+			} elseif ($typec == 'FSS') {
903
+				$data['type'] = 'Flight Service Station';
904
+			} elseif ($typec == 'CTR') {
905
+				$data['type'] = 'Control Radar or Centre';
906
+			} else {
907
+				$data['type'] = 'Observer';
908
+			}
681 909
 			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']);
682 910
 		    }
683 911
 		    unset($data);
@@ -688,17 +916,25 @@  discard block
 block discarded – undo
688 916
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
689 917
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
690 918
 	    //$buffer = $Common->getData($hosts[$id]);
691
-	    if ($globalDebug) echo 'Get Data...'."\n";
919
+	    if ($globalDebug) {
920
+	    	echo 'Get Data...'."\n";
921
+	    }
692 922
 	    $buffer = $Common->getData($value['host']);
693 923
 	    $all_data = json_decode($buffer,true);
694 924
 	    if ($buffer != '' && is_array($all_data)) {
695 925
 		foreach ($all_data as $line) {
696 926
 	    	    $data = array();
697 927
 	    	    //$data['id'] = $line['id']; // id not usable
698
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
928
+	    	    if (isset($line['pilotid'])) {
929
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
930
+	    	    }
699 931
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
700
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
701
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
932
+	    	    if (isset($line['pilotname'])) {
933
+	    	    	$data['pilot_name'] = $line['pilotname'];
934
+	    	    }
935
+	    	    if (isset($line['pilotid'])) {
936
+	    	    	$data['pilot_id'] = $line['pilotid'];
937
+	    	    }
702 938
 	    	    $data['ident'] = $line['flightnum']; // ident
703 939
 	    	    $data['altitude'] = $line['alt']; // altitude
704 940
 	    	    $data['speed'] = $line['gs']; // speed
@@ -716,27 +952,41 @@  discard block
 block discarded – undo
716 952
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
717 953
     		    $data['arrival_airport_time'] = $line['arrtime'];
718 954
     		    $data['registration'] = $line['aircraft'];
719
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
955
+		    if (isset($line['route'])) {
956
+		    	$data['waypoints'] = $line['route'];
957
+		    }
958
+		    // route
720 959
 		    if (isset($line['aircraftname'])) {
721 960
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
722 961
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
723 962
 	    		$aircraft_data = explode('-',$line['aircraftname']);
724
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
725
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
726
-	    		else {
963
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) {
964
+	    			$data['aircraft_icao'] = $aircraft_data[0];
965
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) {
966
+	    			$data['aircraft_icao'] = $aircraft_data[1];
967
+	    		} else {
727 968
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
728
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
729
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
969
+	    		    if (isset($aircraft_data[1])) {
970
+	    		    	$data['aircraft_icao'] = $aircraft_data[1];
971
+	    		    } else {
972
+	    		    	$data['aircraft_icao'] = $line['aircraftname'];
973
+	    		    }
730 974
 	    		}
731 975
 	    	    }
732
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
976
+    		    if (isset($line['route'])) {
977
+    		    	$data['waypoints'] = $line['route'];
978
+    		    }
733 979
     		    $data['id_source'] = $id_source;
734 980
 	    	    $data['format_source'] = 'phpvmacars';
735
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
981
+		    if (isset($value['name']) && $value['name'] != '') {
982
+		    	$data['source_name'] = $value['name'];
983
+		    }
736 984
 		    $SI->add($data);
737 985
 		    unset($data);
738 986
 		}
739
-		if ($globalDebug) echo 'No more data...'."\n";
987
+		if ($globalDebug) {
988
+			echo 'No more data...'."\n";
989
+		}
740 990
 		unset($buffer);
741 991
 		unset($all_data);
742 992
 	    }
@@ -744,7 +994,9 @@  discard block
 block discarded – undo
744 994
     	    $last_exec[$id]['last'] = time();
745 995
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
746 996
 	    //$buffer = $Common->getData($hosts[$id]);
747
-	    if ($globalDebug) echo 'Get Data...'."\n";
997
+	    if ($globalDebug) {
998
+	    	echo 'Get Data...'."\n";
999
+	    }
748 1000
 	    $buffer = $Common->getData($value['host']);
749 1001
 	    $all_data = json_decode($buffer,true);
750 1002
 	    if ($buffer != '' && is_array($all_data)) {
@@ -772,15 +1024,22 @@  discard block
 block discarded – undo
772 1024
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
773 1025
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
774 1026
     		    //$data['registration'] = $line['aircraft'];
775
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1027
+		    if (isset($line['route'])) {
1028
+		    	$data['waypoints'] = $line['route'];
1029
+		    }
1030
+		    // route
776 1031
 	    	    $data['aircraft_icao'] = $line['plane_type'];
777 1032
     		    $data['id_source'] = $id_source;
778 1033
 	    	    $data['format_source'] = 'vam';
779
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1034
+		    if (isset($value['name']) && $value['name'] != '') {
1035
+		    	$data['source_name'] = $value['name'];
1036
+		    }
780 1037
 		    $SI->add($data);
781 1038
 		    unset($data);
782 1039
 		}
783
-		if ($globalDebug) echo 'No more data...'."\n";
1040
+		if ($globalDebug) {
1041
+			echo 'No more data...'."\n";
1042
+		}
784 1043
 		unset($buffer);
785 1044
 		unset($all_data);
786 1045
 	    }
@@ -788,7 +1047,9 @@  discard block
 block discarded – undo
788 1047
     	    $last_exec[$id]['last'] = time();
789 1048
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
790 1049
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3') {
791
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1050
+	    if (function_exists('pcntl_fork')) {
1051
+	    	pcntl_signal_dispatch();
1052
+	    }
792 1053
     	    //$last_exec[$id]['last'] = time();
793 1054
 
794 1055
 	    //$read = array( $sockets[$id] );
@@ -796,7 +1057,9 @@  discard block
 block discarded – undo
796 1057
 	    $write = NULL;
797 1058
 	    $e = NULL;
798 1059
 	    $n = socket_select($read, $write, $e, $timeout);
799
-	    if ($e != NULL) var_dump($e);
1060
+	    if ($e != NULL) {
1061
+	    	var_dump($e);
1062
+	    }
800 1063
 	    if ($n > 0) {
801 1064
 		foreach ($read as $nb => $r) {
802 1065
 		    //$value = $formats[$nb];
@@ -817,7 +1080,9 @@  discard block
 block discarded – undo
817 1080
 		    if ($buffer != '') {
818 1081
 			$tt[$format] = 0;
819 1082
 			if ($format == 'acarssbs3') {
820
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1083
+                    	    if ($globalDebug) {
1084
+                    	    	echo 'ACARS : '.$buffer."\n";
1085
+                    	    }
821 1086
 			    $ACARS->add(trim($buffer));
822 1087
 			    $ACARS->deleteLiveAcarsData();
823 1088
 			} elseif ($format == 'raw') {
@@ -826,9 +1091,15 @@  discard block
 block discarded – undo
826 1091
 			    if (is_array($data)) {
827 1092
 				$data['datetime'] = date('Y-m-d H:i:s');
828 1093
 				$data['format_source'] = 'raw';
829
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
830
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
831
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1094
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1095
+					$data['source_name'] = $globalSources[$nb]['name'];
1096
+				}
1097
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1098
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1099
+    				}
1100
+                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1101
+                                	$SI->add($data);
1102
+                                }
832 1103
                             }
833 1104
                         } elseif ($format == 'flightgearsp') {
834 1105
                     	    //echo $buffer."\n";
@@ -846,11 +1117,15 @@  discard block
 block discarded – undo
846 1117
 				$data['speed'] = round($line[5]*1.94384);
847 1118
 				$data['datetime'] = date('Y-m-d H:i:s');
848 1119
 				$data['format_source'] = 'flightgearsp';
849
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1120
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1121
+					$SI->add($data);
1122
+				}
850 1123
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
851 1124
 			    }
852 1125
                         } elseif ($format == 'acars') {
853
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1126
+                    	    if ($globalDebug) {
1127
+                    	    	echo 'ACARS : '.$buffer."\n";
1128
+                    	    }
854 1129
 			    $ACARS->add(trim($buffer));
855 1130
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
856 1131
 			    $ACARS->deleteLiveAcarsData();
@@ -871,7 +1146,9 @@  discard block
 block discarded – undo
871 1146
 				    $aircraft_type = $line[10];
872 1147
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
873 1148
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
874
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1149
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1150
+				    	$SI->add($data);
1151
+				    }
875 1152
 				}
876 1153
 			    }
877 1154
 			} elseif ($format == 'beast') {
@@ -887,21 +1164,43 @@  discard block
 block discarded – undo
887 1164
     				$data['hex'] = $lined['hexid'];
888 1165
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
889 1166
     				$data['datetime'] = date('Y-m-d H:i:s');;
890
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
891
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
892
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
893
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
894
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
895
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
896
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1167
+    				if (isset($lined['ident'])) {
1168
+    					$data['ident'] = $lined['ident'];
1169
+    				}
1170
+    				if (isset($lined['lat'])) {
1171
+    					$data['latitude'] = $lined['lat'];
1172
+    				}
1173
+    				if (isset($lined['lon'])) {
1174
+    					$data['longitude'] = $lined['lon'];
1175
+    				}
1176
+    				if (isset($lined['speed'])) {
1177
+    					$data['speed'] = $lined['speed'];
1178
+    				}
1179
+    				if (isset($lined['squawk'])) {
1180
+    					$data['squawk'] = $lined['squawk'];
1181
+    				}
1182
+    				if (isset($lined['alt'])) {
1183
+    					$data['altitude'] = $lined['alt'];
1184
+    				}
1185
+    				if (isset($lined['heading'])) {
1186
+    					$data['heading'] = $lined['heading'];
1187
+    				}
897 1188
     				$data['id_source'] = $id_source;
898 1189
     				$data['format_source'] = 'tsv';
899
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
900
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
901
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1190
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1191
+    					$data['source_name'] = $globalSources[$nb]['name'];
1192
+    				}
1193
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1194
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1195
+    				}
1196
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1197
+    					$SI->add($data);
1198
+    				}
902 1199
     				unset($lined);
903 1200
     				unset($data);
904
-    			    } else $error = true;
1201
+    			    } else {
1202
+    			    	$error = true;
1203
+    			    }
905 1204
 			} elseif ($format == 'aprs' && $use_aprs) {
906 1205
 			    if ($aprs_connect == 0) {
907 1206
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -927,29 +1226,44 @@  discard block
 block discarded – undo
927 1226
 				    $data['latitude'] = $line['latitude'];
928 1227
 				    $data['longitude'] = $line['longitude'];
929 1228
 				    //$data['verticalrate'] = $line[16];
930
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
931
-				    else $data['speed'] = 0;
1229
+				    if (isset($line['speed'])) {
1230
+				    	$data['speed'] = $line['speed'];
1231
+				    } else {
1232
+				    	$data['speed'] = 0;
1233
+				    }
932 1234
 				    $data['altitude'] = $line['altitude'];
933
-				    if (isset($line['course'])) $data['heading'] = $line['course'];
1235
+				    if (isset($line['course'])) {
1236
+				    	$data['heading'] = $line['course'];
1237
+				    }
934 1238
 				    //else $data['heading'] = 0;
935 1239
 				    $data['aircraft_type'] = $line['stealth'];
936
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1240
+				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) {
1241
+				    	$data['noarchive'] = true;
1242
+				    }
937 1243
     				    $data['id_source'] = $id_source;
938 1244
 				    $data['format_source'] = 'aprs';
939 1245
 				    $data['source_name'] = $line['source'];
940
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1246
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1247
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1248
+    				    }
941 1249
 				    $currentdate = date('Y-m-d H:i:s');
942 1250
 				    $aprsdate = strtotime($data['datetime']);
943 1251
 				    // Accept data if time <= system time + 20s
944
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
945
-				    else {
946
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
947
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1252
+				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1253
+				    	$send = $SI->add($data);
1254
+				    } else {
1255
+					if ($line['stealth'] != 0) {
1256
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1257
+					} else {
1258
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1259
+					}
948 1260
 				    }
949 1261
 				    unset($data);
950 1262
 				} 
951 1263
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
952
-				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1264
+				elseif ($line == true && $globalDebug) {
1265
+					echo '!! Failed : '.$buffer."!!\n";
1266
+				}
953 1267
 			    }
954 1268
 			} else {
955 1269
 			    $line = explode(',', $buffer);
@@ -977,25 +1291,42 @@  discard block
 block discarded – undo
977 1291
     				$data['ground'] = $line[21];
978 1292
     				$data['emergency'] = $line[19];
979 1293
     				$data['format_source'] = 'sbs';
980
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
981
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1294
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1295
+					$data['source_name'] = $globalSources[$nb]['name'];
1296
+				}
1297
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1298
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1299
+    				}
982 1300
     				$data['id_source'] = $id_source;
983
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
984
-    				else $error = true;
1301
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1302
+    					$send = $SI->add($data);
1303
+    				} else {
1304
+    					$error = true;
1305
+    				}
985 1306
     				unset($data);
986
-    			    } else $error = true;
1307
+    			    } else {
1308
+    			    	$error = true;
1309
+    			    }
987 1310
 			    if ($error) {
988 1311
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
989
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
1312
+					if ($globalDebug) {
1313
+						echo "Not a message. Ignoring... \n";
1314
+					}
990 1315
 				} else {
991
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
1316
+					if ($globalDebug) {
1317
+						echo "Wrong line format. Ignoring... \n";
1318
+					}
992 1319
 					if ($globalDebug) {
993 1320
 						echo $buffer;
994 1321
 						print_r($line);
995 1322
 					}
996 1323
 					//socket_close($r);
997
-					if ($globalDebug) echo "Reconnect after an error...\n";
998
-					if ($format == 'aprs') $aprs_connect = 0;
1324
+					if ($globalDebug) {
1325
+						echo "Reconnect after an error...\n";
1326
+					}
1327
+					if ($format == 'aprs') {
1328
+						$aprs_connect = 0;
1329
+					}
999 1330
 					$sourceer[$nb] = $globalSources[$nb];
1000 1331
 					connect_all($sourceer);
1001 1332
 					$sourceer = array();
@@ -1003,10 +1334,14 @@  discard block
 block discarded – undo
1003 1334
 			    }
1004 1335
 			}
1005 1336
 			// Sleep for xxx microseconds
1006
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1337
+			if (isset($globalSBSSleep)) {
1338
+				usleep($globalSBSSleep);
1339
+			}
1007 1340
 		    } else {
1008 1341
 			if ($format == 'flightgearmp') {
1009
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1342
+			    	if ($globalDebug) {
1343
+			    		echo "Reconnect FlightGear MP...";
1344
+			    	}
1010 1345
 				//@socket_close($r);
1011 1346
 				sleep($globalMinFetch);
1012 1347
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1015,10 +1350,15 @@  discard block
 block discarded – undo
1015 1350
 				break;
1016 1351
 				
1017 1352
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1018
-			    if (isset($tt[$format])) $tt[$format]++;
1019
-			    else $tt[$format] = 0;
1353
+			    if (isset($tt[$format])) {
1354
+			    	$tt[$format]++;
1355
+			    } else {
1356
+			    	$tt[$format] = 0;
1357
+			    }
1020 1358
 			    if ($tt[$format] > 30) {
1021
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1359
+				if ($globalDebug) {
1360
+					echo "ERROR : Reconnect ".$format."...";
1361
+				}
1022 1362
 				//@socket_close($r);
1023 1363
 				sleep(2);
1024 1364
 				$aprs_connect = 0;
@@ -1034,12 +1374,18 @@  discard block
 block discarded – undo
1034 1374
 		}
1035 1375
 	    } else {
1036 1376
 		$error = socket_strerror(socket_last_error());
1037
-		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1377
+		if ($globalDebug) {
1378
+			echo "ERROR : socket_select give this error ".$error . "\n";
1379
+		}
1038 1380
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1039
-			if (isset($globalDebug)) echo "Restarting...\n";
1381
+			if (isset($globalDebug)) {
1382
+				echo "Restarting...\n";
1383
+			}
1040 1384
 			// Restart the script if possible
1041 1385
 			if (is_array($sockets)) {
1042
-			    if ($globalDebug) echo "Shutdown all sockets...";
1386
+			    if ($globalDebug) {
1387
+			    	echo "Shutdown all sockets...";
1388
+			    }
1043 1389
 			    
1044 1390
 			    foreach ($sockets as $sock) {
1045 1391
 				@socket_shutdown($sock,2);
@@ -1047,7 +1393,9 @@  discard block
 block discarded – undo
1047 1393
 			    }
1048 1394
 			    
1049 1395
 			}
1050
-			    if ($globalDebug) echo "Restart all connections...";
1396
+			    if ($globalDebug) {
1397
+			    	echo "Restart all connections...";
1398
+			    }
1051 1399
 			    sleep(2);
1052 1400
 			    $time = time();
1053 1401
 			    //connect_all($hosts);
@@ -1058,7 +1406,9 @@  discard block
 block discarded – undo
1058 1406
 	    }
1059 1407
 	}
1060 1408
 	if ($globalDaemon === false) {
1061
-	    if ($globalDebug) echo 'Check all...'."\n";
1409
+	    if ($globalDebug) {
1410
+	    	echo 'Check all...'."\n";
1411
+	    }
1062 1412
 	    $SI->checkAll();
1063 1413
 	}
1064 1414
     }
Please login to merge, or discard this patch.
Indentation   +695 added lines, -695 removed lines patch added patch discarded remove patch
@@ -19,47 +19,47 @@  discard block
 block discarded – undo
19 19
 // Check if schema is at latest version
20 20
 $Connection = new Connection();
21 21
 if ($Connection->latest() === false) {
22
-    echo "You MUST update to latest schema. Run install/index.php";
23
-    exit();
22
+	echo "You MUST update to latest schema. Run install/index.php";
23
+	exit();
24 24
 }
25 25
 if (PHP_SAPI != 'cli') {
26
-    echo "This script MUST be called from console, not a web browser.";
27
-    exit();
26
+	echo "This script MUST be called from console, not a web browser.";
27
+	exit();
28 28
 }
29 29
 
30 30
 // This is to be compatible with old version of settings.php
31 31
 if (!isset($globalSources)) {
32
-    if (isset($globalSBS1Hosts)) {
33
-        //$hosts = $globalSBS1Hosts;
34
-        foreach ($globalSBS1Hosts as $host) {
35
-	    $globalSources[] = array('host' => $host);
36
-    	}
37
-    } else {
38
-        if (!isset($globalSBS1Host)) {
39
-	    echo '$globalSources MUST be defined !';
40
-	    die;
32
+	if (isset($globalSBS1Hosts)) {
33
+		//$hosts = $globalSBS1Hosts;
34
+		foreach ($globalSBS1Hosts as $host) {
35
+		$globalSources[] = array('host' => $host);
36
+		}
37
+	} else {
38
+		if (!isset($globalSBS1Host)) {
39
+		echo '$globalSources MUST be defined !';
40
+		die;
41 41
 	}
42 42
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
43 43
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
44
-    }
44
+	}
45 45
 }
46 46
 
47 47
 $options = getopt('s::',array('source::','server','idsource::'));
48 48
 //if (isset($options['s'])) $hosts = array($options['s']);
49 49
 //elseif (isset($options['source'])) $hosts = array($options['source']);
50 50
 if (isset($options['s'])) {
51
-    $globalSources = array();
52
-    $globalSources[] = array('host' => $options['s']);
51
+	$globalSources = array();
52
+	$globalSources[] = array('host' => $options['s']);
53 53
 } elseif (isset($options['source'])) {
54
-    $globalSources = array();
55
-    $globalSources[] = array('host' => $options['source']);
54
+	$globalSources = array();
55
+	$globalSources[] = array('host' => $options['source']);
56 56
 }
57 57
 if (isset($options['server'])) $globalServer = TRUE;
58 58
 if (isset($options['idsource'])) $id_source = $options['idsource'];
59 59
 else $id_source = 1;
60 60
 if (isset($globalServer) && $globalServer) {
61
-    if ($globalDebug) echo "Using Server Mode\n";
62
-    $SI=new SpotterServer();
61
+	if ($globalDebug) echo "Using Server Mode\n";
62
+	$SI=new SpotterServer();
63 63
 } else $SI=new SpotterImport($Connection->db);
64 64
 //$APRS=new APRS($Connection->db);
65 65
 $SBS=new SBS();
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
 //$servertz = system('date +%Z');
70 70
 // signal handler - playing nice with sockets and dump1090
71 71
 if (function_exists('pcntl_fork')) {
72
-    pcntl_signal(SIGINT,  function() {
73
-        global $sockets;
74
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75
-        die("Bye!\n");
76
-    });
77
-    pcntl_signal_dispatch();
72
+	pcntl_signal(SIGINT,  function() {
73
+		global $sockets;
74
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
75
+		die("Bye!\n");
76
+	});
77
+	pcntl_signal_dispatch();
78 78
 }
79 79
 
80 80
 // let's try and connect
@@ -83,161 +83,161 @@  discard block
 block discarded – undo
83 83
 $aprs_full = false;
84 84
 
85 85
 function create_socket($host, $port, &$errno, &$errstr) {
86
-    $ip = gethostbyname($host);
87
-    $s = socket_create(AF_INET, SOCK_STREAM, 0);
88
-    $r = @socket_connect($s, $ip, $port);
89
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
90
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
91
-        return $s;
92
-    }
93
-    $errno = socket_last_error($s);
94
-    $errstr = socket_strerror($errno);
95
-    socket_close($s);
96
-    return false;
86
+	$ip = gethostbyname($host);
87
+	$s = socket_create(AF_INET, SOCK_STREAM, 0);
88
+	$r = @socket_connect($s, $ip, $port);
89
+	if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
90
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
91
+		return $s;
92
+	}
93
+	$errno = socket_last_error($s);
94
+	$errstr = socket_strerror($errno);
95
+	socket_close($s);
96
+	return false;
97 97
 }
98 98
 
99 99
 function create_socket_udp($host, $port, &$errno, &$errstr) {
100
-    echo "UDP !!";
101
-    $ip = gethostbyname($host);
102
-    $s = socket_create(AF_INET, SOCK_DGRAM, 0);
103
-    $r = @socket_bind($s, $ip, $port);
104
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
105
-        return $s;
106
-    }
107
-    $errno = socket_last_error($s);
108
-    $errstr = socket_strerror($errno);
109
-    socket_close($s);
110
-    return false;
100
+	echo "UDP !!";
101
+	$ip = gethostbyname($host);
102
+	$s = socket_create(AF_INET, SOCK_DGRAM, 0);
103
+	$r = @socket_bind($s, $ip, $port);
104
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
105
+		return $s;
106
+	}
107
+	$errno = socket_last_error($s);
108
+	$errstr = socket_strerror($errno);
109
+	socket_close($s);
110
+	return false;
111 111
 }
112 112
 
113 113
 function connect_all($hosts) {
114
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
115
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    if ($globalDebug) echo 'Connect to all...'."\n";
117
-    foreach ($hosts as $id => $value) {
114
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
115
+	global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
+	if ($globalDebug) echo 'Connect to all...'."\n";
117
+	foreach ($hosts as $id => $value) {
118 118
 	$host = $value['host'];
119 119
 	$globalSources[$id]['last_exec'] = 0;
120 120
 	// Here we check type of source(s)
121 121
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
-            if (preg_match('/deltadb.txt$/i',$host)) {
123
-        	//$formats[$id] = 'deltadbtxt';
124
-        	$globalSources[$id]['format'] = 'deltadbtxt';
125
-        	//$last_exec['deltadbtxt'] = 0;
126
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
127
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
128
-        	//$formats[$id] = 'vatsimtxt';
129
-        	$globalSources[$id]['format'] = 'vatsimtxt';
130
-        	//$last_exec['vatsimtxt'] = 0;
131
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
132
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
133
-        	//$formats[$id] = 'aircraftlistjson';
134
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
135
-        	//$last_exec['aircraftlistjson'] = 0;
136
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
137
-    	    } else if (preg_match('/opensky/i',$host)) {
138
-        	//$formats[$id] = 'aircraftlistjson';
139
-        	$globalSources[$id]['format'] = 'opensky';
140
-        	//$last_exec['aircraftlistjson'] = 0;
141
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
142
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
143
-        	//$formats[$id] = 'radarvirtueljson';
144
-        	$globalSources[$id]['format'] = 'radarvirtueljson';
145
-        	//$last_exec['radarvirtueljson'] = 0;
146
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
147
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
148
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
149
-        	    exit(0);
150
-        	}
151
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
152
-        	//$formats[$id] = 'planeupdatefaa';
153
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
154
-        	//$last_exec['planeupdatefaa'] = 0;
155
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
156
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
157
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
158
-        	    exit(0);
159
-        	}
160
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
161
-        	//$formats[$id] = 'phpvmacars';
162
-        	$globalSources[$id]['format'] = 'phpvmacars';
163
-        	//$last_exec['phpvmacars'] = 0;
164
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
165
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
166
-        	//$formats[$id] = 'phpvmacars';
167
-        	$globalSources[$id]['format'] = 'vam';
168
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
169
-            } else if (preg_match('/whazzup/i',$host)) {
170
-        	//$formats[$id] = 'whazzup';
171
-        	$globalSources[$id]['format'] = 'whazzup';
172
-        	//$last_exec['whazzup'] = 0;
173
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
174
-            } else if (preg_match('/recentpireps/i',$host)) {
175
-        	//$formats[$id] = 'pirepsjson';
176
-        	$globalSources[$id]['format'] = 'pirepsjson';
177
-        	//$last_exec['pirepsjson'] = 0;
178
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
179
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
180
-        	//$formats[$id] = 'fr24json';
181
-        	$globalSources[$id]['format'] = 'fr24json';
182
-        	//$last_exec['fr24json'] = 0;
183
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
184
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
185
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
186
-        	    exit(0);
187
-        	}
188
-            //} else if (preg_match('/10001/',$host)) {
189
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
190
-        	//$formats[$id] = 'tsv';
191
-        	$globalSources[$id]['format'] = 'tsv';
192
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
193
-            }
194
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
195
-        	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
196
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
197
-	    $hostport = explode(':',$host);
198
-	    if (isset($hostport[1])) {
122
+			if (preg_match('/deltadb.txt$/i',$host)) {
123
+			//$formats[$id] = 'deltadbtxt';
124
+			$globalSources[$id]['format'] = 'deltadbtxt';
125
+			//$last_exec['deltadbtxt'] = 0;
126
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
127
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
128
+			//$formats[$id] = 'vatsimtxt';
129
+			$globalSources[$id]['format'] = 'vatsimtxt';
130
+			//$last_exec['vatsimtxt'] = 0;
131
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
132
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
133
+			//$formats[$id] = 'aircraftlistjson';
134
+			$globalSources[$id]['format'] = 'aircraftlistjson';
135
+			//$last_exec['aircraftlistjson'] = 0;
136
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
137
+			} else if (preg_match('/opensky/i',$host)) {
138
+			//$formats[$id] = 'aircraftlistjson';
139
+			$globalSources[$id]['format'] = 'opensky';
140
+			//$last_exec['aircraftlistjson'] = 0;
141
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
142
+			} else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
143
+			//$formats[$id] = 'radarvirtueljson';
144
+			$globalSources[$id]['format'] = 'radarvirtueljson';
145
+			//$last_exec['radarvirtueljson'] = 0;
146
+			if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
147
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
148
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
149
+				exit(0);
150
+			}
151
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
152
+			//$formats[$id] = 'planeupdatefaa';
153
+			$globalSources[$id]['format'] = 'planeupdatefaa';
154
+			//$last_exec['planeupdatefaa'] = 0;
155
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
156
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
157
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
158
+				exit(0);
159
+			}
160
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
161
+			//$formats[$id] = 'phpvmacars';
162
+			$globalSources[$id]['format'] = 'phpvmacars';
163
+			//$last_exec['phpvmacars'] = 0;
164
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
165
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
166
+			//$formats[$id] = 'phpvmacars';
167
+			$globalSources[$id]['format'] = 'vam';
168
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
169
+			} else if (preg_match('/whazzup/i',$host)) {
170
+			//$formats[$id] = 'whazzup';
171
+			$globalSources[$id]['format'] = 'whazzup';
172
+			//$last_exec['whazzup'] = 0;
173
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
174
+			} else if (preg_match('/recentpireps/i',$host)) {
175
+			//$formats[$id] = 'pirepsjson';
176
+			$globalSources[$id]['format'] = 'pirepsjson';
177
+			//$last_exec['pirepsjson'] = 0;
178
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
179
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
180
+			//$formats[$id] = 'fr24json';
181
+			$globalSources[$id]['format'] = 'fr24json';
182
+			//$last_exec['fr24json'] = 0;
183
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
184
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
185
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
186
+				exit(0);
187
+			}
188
+			//} else if (preg_match('/10001/',$host)) {
189
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
190
+			//$formats[$id] = 'tsv';
191
+			$globalSources[$id]['format'] = 'tsv';
192
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
193
+			}
194
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
195
+			if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
196
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
197
+		$hostport = explode(':',$host);
198
+		if (isset($hostport[1])) {
199 199
 		$port = $hostport[1];
200 200
 		$hostn = $hostport[0];
201
-	    } else {
201
+		} else {
202 202
 		$port = $globalSources[$id]['port'];
203 203
 		$hostn = $globalSources[$id]['host'];
204
-	    }
205
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
206
-        	$s = create_socket($hostn,$port, $errno, $errstr);
207
-    	    } else {
208
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
209
-	    }
210
-	    if ($s) {
211
-    	        $sockets[$id] = $s;
212
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
213
-		    if (preg_match('/aprs/',$hostn)) {
204
+		}
205
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
206
+			$s = create_socket($hostn,$port, $errno, $errstr);
207
+			} else {
208
+			$s = create_socket_udp($hostn,$port, $errno, $errstr);
209
+		}
210
+		if ($s) {
211
+				$sockets[$id] = $s;
212
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
213
+			if (preg_match('/aprs/',$hostn)) {
214 214
 			//$formats[$id] = 'aprs';
215 215
 			$globalSources[$id]['format'] = 'aprs';
216 216
 			//$aprs_connect = 0;
217 217
 			//$use_aprs = true;
218
-    		    } elseif ($port == '10001') {
219
-        		//$formats[$id] = 'tsv';
220
-        		$globalSources[$id]['format'] = 'tsv';
221
-		    } elseif ($port == '30002') {
222
-        		//$formats[$id] = 'raw';
223
-        		$globalSources[$id]['format'] = 'raw';
224
-		    } elseif ($port == '5001') {
225
-        		//$formats[$id] = 'raw';
226
-        		$globalSources[$id]['format'] = 'flightgearmp';
227
-		    } elseif ($port == '30005') {
218
+				} elseif ($port == '10001') {
219
+				//$formats[$id] = 'tsv';
220
+				$globalSources[$id]['format'] = 'tsv';
221
+			} elseif ($port == '30002') {
222
+				//$formats[$id] = 'raw';
223
+				$globalSources[$id]['format'] = 'raw';
224
+			} elseif ($port == '5001') {
225
+				//$formats[$id] = 'raw';
226
+				$globalSources[$id]['format'] = 'flightgearmp';
227
+			} elseif ($port == '30005') {
228 228
 			// Not yet supported
229
-        		//$formats[$id] = 'beast';
230
-        		$globalSources[$id]['format'] = 'beast';
231
-		    //} else $formats[$id] = 'sbs';
232
-		    } else $globalSources[$id]['format'] = 'sbs';
233
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
229
+				//$formats[$id] = 'beast';
230
+				$globalSources[$id]['format'] = 'beast';
231
+			//} else $formats[$id] = 'sbs';
232
+			} else $globalSources[$id]['format'] = 'sbs';
233
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
234 234
 		}
235 235
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
236
-            } else {
236
+			} else {
237 237
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
238
-    	    }
239
-        }
240
-    }
238
+			}
239
+		}
240
+	}
241 241
 }
242 242
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
243 243
 
@@ -264,18 +264,18 @@  discard block
 block discarded – undo
264 264
 	die;
265 265
 }
266 266
 foreach ($globalSources as $key => $source) {
267
-    if (!isset($source['format'])) {
268
-        $globalSources[$key]['format'] = 'auto';
269
-    }
267
+	if (!isset($source['format'])) {
268
+		$globalSources[$key]['format'] = 'auto';
269
+	}
270 270
 }
271 271
 connect_all($globalSources);
272 272
 foreach ($globalSources as $key => $source) {
273
-    if (isset($source['format']) && $source['format'] == 'aprs') {
273
+	if (isset($source['format']) && $source['format'] == 'aprs') {
274 274
 	$aprs_connect = 0;
275 275
 	$use_aprs = true;
276 276
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
277 277
 	break;
278
-    }
278
+	}
279 279
 }
280 280
 
281 281
 if ($use_aprs) {
@@ -315,67 +315,67 @@  discard block
 block discarded – undo
315 315
 
316 316
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
317 317
 while ($i > 0) {
318
-    if (!$globalDaemon) $i = $endtime-time();
319
-    // Delete old ATC
320
-    if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
318
+	if (!$globalDaemon) $i = $endtime-time();
319
+	// Delete old ATC
320
+	if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
321 321
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
322
-        $ATC->deleteOldATC();
323
-    }
322
+		$ATC->deleteOldATC();
323
+	}
324 324
     
325
-    if (count($last_exec) > 0) {
325
+	if (count($last_exec) > 0) {
326 326
 	$max = $globalMinFetch;
327 327
 	foreach ($last_exec as $last) {
328
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
328
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
329 329
 	}
330 330
 	if ($max != $globalMinFetch) {
331
-	    if ($globalDebug) echo 'Sleeping...'."\n";
332
-	    sleep($globalMinFetch-$max+2);
331
+		if ($globalDebug) echo 'Sleeping...'."\n";
332
+		sleep($globalMinFetch-$max+2);
333
+	}
333 334
 	}
334
-    }
335 335
 
336 336
     
337
-    //foreach ($formats as $id => $value) {
338
-    foreach ($globalSources as $id => $value) {
337
+	//foreach ($formats as $id => $value) {
338
+	foreach ($globalSources as $id => $value) {
339 339
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
340 340
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
341
-	    //$buffer = $Common->getData($hosts[$id]);
342
-	    $buffer = $Common->getData($value['host']);
343
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
344
-	    $buffer = explode('\n',$buffer);
345
-	    foreach ($buffer as $line) {
346
-    		if ($line != '' && count($line) > 7) {
347
-    		    $line = explode(',', $line);
348
-	            $data = array();
349
-	            $data['hex'] = $line[1]; // hex
350
-	            $data['ident'] = $line[2]; // ident
351
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
352
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
353
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
354
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
355
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
356
-	            $data['verticalrate'] = ''; // vertical rate
357
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
358
-	            $data['emergency'] = ''; // emergency
359
-		    $data['datetime'] = date('Y-m-d H:i:s');
360
-		    $data['format_source'] = 'deltadbtxt';
361
-    		    $data['id_source'] = $id_source;
362
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
363
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
364
-    		    $SI->add($data);
365
-		    unset($data);
366
-    		}
367
-    	    }
368
-    	    $last_exec[$id]['last'] = time();
341
+		//$buffer = $Common->getData($hosts[$id]);
342
+		$buffer = $Common->getData($value['host']);
343
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
344
+		$buffer = explode('\n',$buffer);
345
+		foreach ($buffer as $line) {
346
+			if ($line != '' && count($line) > 7) {
347
+				$line = explode(',', $line);
348
+				$data = array();
349
+				$data['hex'] = $line[1]; // hex
350
+				$data['ident'] = $line[2]; // ident
351
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
352
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
353
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
354
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
355
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
356
+				$data['verticalrate'] = ''; // vertical rate
357
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
358
+				$data['emergency'] = ''; // emergency
359
+			$data['datetime'] = date('Y-m-d H:i:s');
360
+			$data['format_source'] = 'deltadbtxt';
361
+				$data['id_source'] = $id_source;
362
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
363
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
364
+				$SI->add($data);
365
+			unset($data);
366
+			}
367
+			}
368
+			$last_exec[$id]['last'] = time();
369 369
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
370 370
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $value[' last_exec'] > $globalMinFetch))) {
371
-	    //$buffer = $Common->getData($hosts[$id]);
372
-	    $buffer = $Common->getData($value['host']);
373
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
374
-	    $buffer = explode('\n',$buffer);
375
-	    foreach ($buffer as $line) {
376
-    		if ($line != '') {
377
-    		    $line = explode(':', $line);
378
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
371
+		//$buffer = $Common->getData($hosts[$id]);
372
+		$buffer = $Common->getData($value['host']);
373
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
374
+		$buffer = explode('\n',$buffer);
375
+		foreach ($buffer as $line) {
376
+			if ($line != '') {
377
+				$line = explode(':', $line);
378
+				if (count($line) > 30 && $line[0] != 'callsign') {
379 379
 			$data = array();
380 380
 			$data['id'] = $line[1].'-'.$line[0];
381 381
 			$data['pilot_id'] = $line[1];
@@ -387,36 +387,36 @@  discard block
 block discarded – undo
387 387
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
388 388
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
389 389
 			$data['latitude'] = $line[5]; // lat
390
-	        	$data['longitude'] = $line[6]; // long
391
-	        	$data['verticalrate'] = ''; // vertical rate
392
-	        	$data['squawk'] = ''; // squawk
393
-	        	$data['emergency'] = ''; // emergency
394
-	        	$data['waypoints'] = $line[30];
390
+				$data['longitude'] = $line[6]; // long
391
+				$data['verticalrate'] = ''; // vertical rate
392
+				$data['squawk'] = ''; // squawk
393
+				$data['emergency'] = ''; // emergency
394
+				$data['waypoints'] = $line[30];
395 395
 			$data['datetime'] = date('Y-m-d H:i:s');
396 396
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
397 397
 			if (isset($line[37])) $data['last_update'] = $line[37];
398
-		        $data['departure_airport_icao'] = $line[11];
399
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
400
-		        $data['arrival_airport_icao'] = $line[13];
398
+				$data['departure_airport_icao'] = $line[11];
399
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
400
+				$data['arrival_airport_icao'] = $line[13];
401 401
 			$data['frequency'] = $line[4];
402 402
 			$data['type'] = $line[18];
403 403
 			$data['range'] = $line[19];
404 404
 			if (isset($line[35])) $data['info'] = $line[35];
405
-    			$data['id_source'] = $id_source;
406
-	    		//$data['arrival_airport_time'] = ;
407
-	    		if ($line[9] != '') {
408
-	    		    $aircraft_data = explode('/',$line[9]);
409
-	    		    if (isset($aircraft_data[1])) {
410
-	    			$data['aircraft_icao'] = $aircraft_data[1];
411
-	    		    }
412
-        		}
413
-	    		/*
405
+				$data['id_source'] = $id_source;
406
+				//$data['arrival_airport_time'] = ;
407
+				if ($line[9] != '') {
408
+					$aircraft_data = explode('/',$line[9]);
409
+					if (isset($aircraft_data[1])) {
410
+					$data['aircraft_icao'] = $aircraft_data[1];
411
+					}
412
+				}
413
+				/*
414 414
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
415 415
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
416 416
 	    		*/
417
-	    		$data['format_source'] = $value['format'];
417
+				$data['format_source'] = $value['format'];
418 418
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
419
-    			if ($line[3] == 'PILOT') $SI->add($data);
419
+				if ($line[3] == 'PILOT') $SI->add($data);
420 420
 			elseif ($line[3] == 'ATC') {
421 421
 				//print_r($data);
422 422
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -434,240 +434,240 @@  discard block
 block discarded – undo
434 434
 				
435 435
 				echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']);
436 436
 			}
437
-    			unset($data);
438
-    		    }
439
-    		}
440
-    	    }
441
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
442
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
443
-    	    $last_exec[$id]['last'] = time();
444
-    	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
445
-    	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
446
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
447
-	    if ($buffer != '') {
448
-	    $all_data = json_decode($buffer,true);
449
-	    if (isset($all_data['acList'])) {
437
+				unset($data);
438
+				}
439
+			}
440
+			}
441
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
442
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
443
+			$last_exec[$id]['last'] = time();
444
+		//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
445
+		} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
446
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
447
+		if ($buffer != '') {
448
+		$all_data = json_decode($buffer,true);
449
+		if (isset($all_data['acList'])) {
450 450
 		foreach ($all_data['acList'] as $line) {
451
-		    $data = array();
452
-		    $data['hex'] = $line['Icao']; // hex
453
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
454
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
455
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
456
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
457
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
458
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
459
-		    //$data['verticalrate'] = $line['']; // verticale rate
460
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
461
-		    $data['emergency'] = ''; // emergency
462
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
463
-		    /*
451
+			$data = array();
452
+			$data['hex'] = $line['Icao']; // hex
453
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
454
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
455
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
456
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
457
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
458
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
459
+			//$data['verticalrate'] = $line['']; // verticale rate
460
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
461
+			$data['emergency'] = ''; // emergency
462
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
463
+			/*
464 464
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
465 465
 		    else $data['datetime'] = date('Y-m-d H:i:s');
466 466
 		    */
467
-		    $data['datetime'] = date('Y-m-d H:i:s');
468
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
469
-	    	    $data['format_source'] = 'aircraftlistjson';
470
-		    $data['id_source'] = $id_source;
471
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
472
-		    if (isset($data['datetime'])) $SI->add($data);
473
-		    unset($data);
467
+			$data['datetime'] = date('Y-m-d H:i:s');
468
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
469
+				$data['format_source'] = 'aircraftlistjson';
470
+			$data['id_source'] = $id_source;
471
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
472
+			if (isset($data['datetime'])) $SI->add($data);
473
+			unset($data);
474 474
 		}
475
-	    } else {
475
+		} else {
476 476
 		foreach ($all_data as $line) {
477
-		    $data = array();
478
-		    $data['hex'] = $line['hex']; // hex
479
-		    $data['ident'] = $line['flight']; // ident
480
-		    $data['altitude'] = $line['altitude']; // altitude
481
-		    $data['speed'] = $line['speed']; // speed
482
-		    $data['heading'] = $line['track']; // heading
483
-		    $data['latitude'] = $line['lat']; // lat
484
-		    $data['longitude'] = $line['lon']; // long
485
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
486
-		    $data['squawk'] = $line['squawk']; // squawk
487
-		    $data['emergency'] = ''; // emergency
488
-		    $data['datetime'] = date('Y-m-d H:i:s');
489
-	    	    $data['format_source'] = 'aircraftlistjson';
490
-    		    $data['id_source'] = $id_source;
491
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
492
-		    $SI->add($data);
493
-		    unset($data);
477
+			$data = array();
478
+			$data['hex'] = $line['hex']; // hex
479
+			$data['ident'] = $line['flight']; // ident
480
+			$data['altitude'] = $line['altitude']; // altitude
481
+			$data['speed'] = $line['speed']; // speed
482
+			$data['heading'] = $line['track']; // heading
483
+			$data['latitude'] = $line['lat']; // lat
484
+			$data['longitude'] = $line['lon']; // long
485
+			$data['verticalrate'] = $line['vrt']; // verticale rate
486
+			$data['squawk'] = $line['squawk']; // squawk
487
+			$data['emergency'] = ''; // emergency
488
+			$data['datetime'] = date('Y-m-d H:i:s');
489
+				$data['format_source'] = 'aircraftlistjson';
490
+				$data['id_source'] = $id_source;
491
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
492
+			$SI->add($data);
493
+			unset($data);
494
+		}
495
+		}
494 496
 		}
495
-	    }
496
-	    }
497
-    	    //$last_exec['aircraftlistjson'] = time();
498
-    	    $last_exec[$id]['last'] = time();
499
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
500
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
501
-	    $buffer = $Common->getData($value['host']);
502
-	    $all_data = json_decode($buffer,true);
503
-	    if (isset($all_data['planes'])) {
497
+			//$last_exec['aircraftlistjson'] = time();
498
+			$last_exec[$id]['last'] = time();
499
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
500
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
501
+		$buffer = $Common->getData($value['host']);
502
+		$all_data = json_decode($buffer,true);
503
+		if (isset($all_data['planes'])) {
504 504
 		foreach ($all_data['planes'] as $key => $line) {
505
-		    $data = array();
506
-		    $data['hex'] = $key; // hex
507
-		    $data['ident'] = $line[3]; // ident
508
-		    $data['altitude'] = $line[6]; // altitude
509
-		    $data['speed'] = $line[8]; // speed
510
-		    $data['heading'] = $line[7]; // heading
511
-		    $data['latitude'] = $line[4]; // lat
512
-		    $data['longitude'] = $line[5]; // long
513
-		    //$data['verticalrate'] = $line[]; // verticale rate
514
-		    $data['squawk'] = $line[10]; // squawk
515
-		    $data['emergency'] = ''; // emergency
516
-		    $data['registration'] = $line[2];
517
-		    $data['aircraft_icao'] = $line[0];
518
-		    $deparr = explode('-',$line[1]);
519
-		    if (count($deparr) == 2) {
505
+			$data = array();
506
+			$data['hex'] = $key; // hex
507
+			$data['ident'] = $line[3]; // ident
508
+			$data['altitude'] = $line[6]; // altitude
509
+			$data['speed'] = $line[8]; // speed
510
+			$data['heading'] = $line[7]; // heading
511
+			$data['latitude'] = $line[4]; // lat
512
+			$data['longitude'] = $line[5]; // long
513
+			//$data['verticalrate'] = $line[]; // verticale rate
514
+			$data['squawk'] = $line[10]; // squawk
515
+			$data['emergency'] = ''; // emergency
516
+			$data['registration'] = $line[2];
517
+			$data['aircraft_icao'] = $line[0];
518
+			$deparr = explode('-',$line[1]);
519
+			if (count($deparr) == 2) {
520 520
 			$data['departure_airport_icao'] = $deparr[0];
521 521
 			$data['arrival_airport_icao'] = $deparr[1];
522
-		    }
523
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
524
-	    	    $data['format_source'] = 'planeupdatefaa';
525
-    		    $data['id_source'] = $id_source;
526
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
527
-		    $SI->add($data);
528
-		    unset($data);
522
+			}
523
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
524
+				$data['format_source'] = 'planeupdatefaa';
525
+				$data['id_source'] = $id_source;
526
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
527
+			$SI->add($data);
528
+			unset($data);
529 529
 		}
530
-	    }
531
-    	    //$last_exec['planeupdatefaa'] = time();
532
-    	    $last_exec[$id]['last'] = time();
533
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
534
-	    $buffer = $Common->getData($value['host']);
535
-	    $all_data = json_decode($buffer,true);
536
-	    if (isset($all_data['states'])) {
530
+		}
531
+			//$last_exec['planeupdatefaa'] = time();
532
+			$last_exec[$id]['last'] = time();
533
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
534
+		$buffer = $Common->getData($value['host']);
535
+		$all_data = json_decode($buffer,true);
536
+		if (isset($all_data['states'])) {
537 537
 		foreach ($all_data['states'] as $key => $line) {
538
-		    $data = array();
539
-		    $data['hex'] = $line[0]; // hex
540
-		    $data['ident'] = trim($line[1]); // ident
541
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
542
-		    $data['speed'] = round($line[9]*1.94384); // speed
543
-		    $data['heading'] = round($line[10]); // heading
544
-		    $data['latitude'] = $line[5]; // lat
545
-		    $data['longitude'] = $line[6]; // long
546
-		    $data['verticalrate'] = $line[11]; // verticale rate
547
-		    //$data['squawk'] = $line[10]; // squawk
548
-		    //$data['emergency'] = ''; // emergency
549
-		    //$data['registration'] = $line[2];
550
-		    //$data['aircraft_icao'] = $line[0];
551
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
552
-	    	    $data['format_source'] = 'opensky';
553
-    		    $data['id_source'] = $id_source;
554
-		    $SI->add($data);
555
-		    unset($data);
538
+			$data = array();
539
+			$data['hex'] = $line[0]; // hex
540
+			$data['ident'] = trim($line[1]); // ident
541
+			$data['altitude'] = round($line[7]*3.28084); // altitude
542
+			$data['speed'] = round($line[9]*1.94384); // speed
543
+			$data['heading'] = round($line[10]); // heading
544
+			$data['latitude'] = $line[5]; // lat
545
+			$data['longitude'] = $line[6]; // long
546
+			$data['verticalrate'] = $line[11]; // verticale rate
547
+			//$data['squawk'] = $line[10]; // squawk
548
+			//$data['emergency'] = ''; // emergency
549
+			//$data['registration'] = $line[2];
550
+			//$data['aircraft_icao'] = $line[0];
551
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
552
+				$data['format_source'] = 'opensky';
553
+				$data['id_source'] = $id_source;
554
+			$SI->add($data);
555
+			unset($data);
556 556
 		}
557
-	    }
558
-    	    //$last_exec['planeupdatefaa'] = time();
559
-    	    $last_exec[$id]['last'] = time();
560
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
561
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
562
-	    //$buffer = $Common->getData($hosts[$id]);
563
-	    $buffer = $Common->getData($value['host']);
564
-	    $all_data = json_decode($buffer,true);
565
-	    foreach ($all_data as $key => $line) {
557
+		}
558
+			//$last_exec['planeupdatefaa'] = time();
559
+			$last_exec[$id]['last'] = time();
560
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
561
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
562
+		//$buffer = $Common->getData($hosts[$id]);
563
+		$buffer = $Common->getData($value['host']);
564
+		$all_data = json_decode($buffer,true);
565
+		foreach ($all_data as $key => $line) {
566 566
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
567
-		    $data = array();
568
-		    $data['hex'] = $line[0];
569
-		    $data['ident'] = $line[16]; //$line[13]
570
-	    	    $data['altitude'] = $line[4]; // altitude
571
-	    	    $data['speed'] = $line[5]; // speed
572
-	    	    $data['heading'] = $line[3]; // heading
573
-	    	    $data['latitude'] = $line[1]; // lat
574
-	    	    $data['longitude'] = $line[2]; // long
575
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
576
-	    	    $data['squawk'] = $line[6]; // squawk
577
-	    	    $data['aircraft_icao'] = $line[8];
578
-	    	    $data['registration'] = $line[9];
579
-		    $data['departure_airport_iata'] = $line[11];
580
-		    $data['arrival_airport_iata'] = $line[12];
581
-	    	    $data['emergency'] = ''; // emergency
582
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
583
-	    	    $data['format_source'] = 'fr24json';
584
-    		    $data['id_source'] = $id_source;
585
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
586
-		    $SI->add($data);
587
-		    unset($data);
567
+			$data = array();
568
+			$data['hex'] = $line[0];
569
+			$data['ident'] = $line[16]; //$line[13]
570
+				$data['altitude'] = $line[4]; // altitude
571
+				$data['speed'] = $line[5]; // speed
572
+				$data['heading'] = $line[3]; // heading
573
+				$data['latitude'] = $line[1]; // lat
574
+				$data['longitude'] = $line[2]; // long
575
+				$data['verticalrate'] = $line[15]; // verticale rate
576
+				$data['squawk'] = $line[6]; // squawk
577
+				$data['aircraft_icao'] = $line[8];
578
+				$data['registration'] = $line[9];
579
+			$data['departure_airport_iata'] = $line[11];
580
+			$data['arrival_airport_iata'] = $line[12];
581
+				$data['emergency'] = ''; // emergency
582
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
583
+				$data['format_source'] = 'fr24json';
584
+				$data['id_source'] = $id_source;
585
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
586
+			$SI->add($data);
587
+			unset($data);
588 588
 		}
589
-	    }
590
-    	    //$last_exec['fr24json'] = time();
591
-    	    $last_exec[$id]['last'] = time();
592
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
593
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
594
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
595
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
596
-	    //echo $buffer;
597
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
598
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
599
-	    $all_data = json_decode($buffer,true);
600
-	    if (json_last_error() != JSON_ERROR_NONE) {
589
+		}
590
+			//$last_exec['fr24json'] = time();
591
+			$last_exec[$id]['last'] = time();
592
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
593
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
594
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
595
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
596
+		//echo $buffer;
597
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
598
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
599
+		$all_data = json_decode($buffer,true);
600
+		if (json_last_error() != JSON_ERROR_NONE) {
601 601
 		die(json_last_error_msg());
602
-	    }
603
-	    if (isset($all_data['mrkrs'])) {
602
+		}
603
+		if (isset($all_data['mrkrs'])) {
604 604
 		foreach ($all_data['mrkrs'] as $key => $line) {
605
-		    if (isset($line['inf'])) {
605
+			if (isset($line['inf'])) {
606 606
 			$data = array();
607 607
 			$data['hex'] = $line['inf']['ia'];
608 608
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
609
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
610
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
611
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
612
-	    		$data['latitude'] = $line['pt'][0]; // lat
613
-	    		$data['longitude'] = $line['pt'][1]; // long
614
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
615
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
616
-	    		//$data['aircraft_icao'] = $line[8];
617
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
609
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
610
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
611
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
612
+				$data['latitude'] = $line['pt'][0]; // lat
613
+				$data['longitude'] = $line['pt'][1]; // long
614
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
615
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
616
+				//$data['aircraft_icao'] = $line[8];
617
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
618 618
 			//$data['departure_airport_iata'] = $line[11];
619 619
 			//$data['arrival_airport_iata'] = $line[12];
620
-	    		//$data['emergency'] = ''; // emergency
620
+				//$data['emergency'] = ''; // emergency
621 621
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
622
-	    		$data['format_source'] = 'radarvirtueljson';
623
-    			$data['id_source'] = $id_source;
622
+				$data['format_source'] = 'radarvirtueljson';
623
+				$data['id_source'] = $id_source;
624 624
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
625 625
 			$SI->add($data);
626 626
 			unset($data);
627
-		    }
627
+			}
628 628
 		}
629
-	    }
630
-    	    //$last_exec['radarvirtueljson'] = time();
631
-    	    $last_exec[$id]['last'] = time();
632
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
633
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
634
-	    //$buffer = $Common->getData($hosts[$id]);
635
-	    $buffer = $Common->getData($value['host'].'?'.time());
636
-	    $all_data = json_decode(utf8_encode($buffer),true);
629
+		}
630
+			//$last_exec['radarvirtueljson'] = time();
631
+			$last_exec[$id]['last'] = time();
632
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
633
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
634
+		//$buffer = $Common->getData($hosts[$id]);
635
+		$buffer = $Common->getData($value['host'].'?'.time());
636
+		$all_data = json_decode(utf8_encode($buffer),true);
637 637
 	    
638
-	    if (isset($all_data['pireps'])) {
639
-	        foreach ($all_data['pireps'] as $line) {
640
-		    $data = array();
641
-		    $data['id'] = $line['id'];
642
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
643
-		    $data['ident'] = $line['callsign']; // ident
644
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
645
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
646
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
647
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
648
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
649
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
650
-		    $data['latitude'] = $line['lat']; // lat
651
-		    $data['longitude'] = $line['lon']; // long
652
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
653
-		    //$data['squawk'] = $line['squawk']; // squawk
654
-		    //$data['emergency'] = ''; // emergency
655
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
656
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
657
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
658
-		    //$data['arrival_airport_time'] = $line['arrtime'];
659
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
660
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
661
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
662
-		    else $data['info'] = '';
663
-		    $data['format_source'] = 'pireps';
664
-    		    $data['id_source'] = $id_source;
665
-		    $data['datetime'] = date('Y-m-d H:i:s');
666
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
667
-		    if ($line['icon'] == 'plane') {
638
+		if (isset($all_data['pireps'])) {
639
+			foreach ($all_data['pireps'] as $line) {
640
+			$data = array();
641
+			$data['id'] = $line['id'];
642
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
643
+			$data['ident'] = $line['callsign']; // ident
644
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
645
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
646
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
647
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
648
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
649
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
650
+			$data['latitude'] = $line['lat']; // lat
651
+			$data['longitude'] = $line['lon']; // long
652
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
653
+			//$data['squawk'] = $line['squawk']; // squawk
654
+			//$data['emergency'] = ''; // emergency
655
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
656
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
657
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
658
+			//$data['arrival_airport_time'] = $line['arrtime'];
659
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
660
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
661
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
662
+			else $data['info'] = '';
663
+			$data['format_source'] = 'pireps';
664
+				$data['id_source'] = $id_source;
665
+			$data['datetime'] = date('Y-m-d H:i:s');
666
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
667
+			if ($line['icon'] == 'plane') {
668 668
 			$SI->add($data);
669
-		    //    print_r($data);
670
-    		    } elseif ($line['icon'] == 'ct') {
669
+			//    print_r($data);
670
+				} elseif ($line['icon'] == 'ct') {
671 671
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
672 672
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
673 673
 			$typec = substr($data['ident'],-3);
@@ -682,160 +682,160 @@  discard block
 block discarded – undo
682 682
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
683 683
 			else $data['type'] = 'Observer';
684 684
 			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']);
685
-		    }
686
-		    unset($data);
685
+			}
686
+			unset($data);
687 687
 		}
688
-	    }
689
-    	    //$last_exec['pirepsjson'] = time();
690
-    	    $last_exec[$id]['last'] = time();
691
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
692
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
693
-	    //$buffer = $Common->getData($hosts[$id]);
694
-	    if ($globalDebug) echo 'Get Data...'."\n";
695
-	    $buffer = $Common->getData($value['host']);
696
-	    $all_data = json_decode($buffer,true);
697
-	    if ($buffer != '' && is_array($all_data)) {
688
+		}
689
+			//$last_exec['pirepsjson'] = time();
690
+			$last_exec[$id]['last'] = time();
691
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
692
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
693
+		//$buffer = $Common->getData($hosts[$id]);
694
+		if ($globalDebug) echo 'Get Data...'."\n";
695
+		$buffer = $Common->getData($value['host']);
696
+		$all_data = json_decode($buffer,true);
697
+		if ($buffer != '' && is_array($all_data)) {
698 698
 		foreach ($all_data as $line) {
699
-	    	    $data = array();
700
-	    	    //$data['id'] = $line['id']; // id not usable
701
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
702
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
703
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
704
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
705
-	    	    $data['ident'] = $line['flightnum']; // ident
706
-	    	    $data['altitude'] = $line['alt']; // altitude
707
-	    	    $data['speed'] = $line['gs']; // speed
708
-	    	    $data['heading'] = $line['heading']; // heading
709
-	    	    $data['latitude'] = $line['lat']; // lat
710
-	    	    $data['longitude'] = $line['lng']; // long
711
-	    	    $data['verticalrate'] = ''; // verticale rate
712
-	    	    $data['squawk'] = ''; // squawk
713
-	    	    $data['emergency'] = ''; // emergency
714
-	    	    //$data['datetime'] = $line['lastupdate'];
715
-	    	    $data['last_update'] = $line['lastupdate'];
716
-		    $data['datetime'] = date('Y-m-d H:i:s');
717
-	    	    $data['departure_airport_icao'] = $line['depicao'];
718
-	    	    $data['departure_airport_time'] = $line['deptime'];
719
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
720
-    		    $data['arrival_airport_time'] = $line['arrtime'];
721
-    		    $data['registration'] = $line['aircraft'];
722
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
723
-		    if (isset($line['aircraftname'])) {
699
+				$data = array();
700
+				//$data['id'] = $line['id']; // id not usable
701
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
702
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
703
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
704
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
705
+				$data['ident'] = $line['flightnum']; // ident
706
+				$data['altitude'] = $line['alt']; // altitude
707
+				$data['speed'] = $line['gs']; // speed
708
+				$data['heading'] = $line['heading']; // heading
709
+				$data['latitude'] = $line['lat']; // lat
710
+				$data['longitude'] = $line['lng']; // long
711
+				$data['verticalrate'] = ''; // verticale rate
712
+				$data['squawk'] = ''; // squawk
713
+				$data['emergency'] = ''; // emergency
714
+				//$data['datetime'] = $line['lastupdate'];
715
+				$data['last_update'] = $line['lastupdate'];
716
+			$data['datetime'] = date('Y-m-d H:i:s');
717
+				$data['departure_airport_icao'] = $line['depicao'];
718
+				$data['departure_airport_time'] = $line['deptime'];
719
+				$data['arrival_airport_icao'] = $line['arricao'];
720
+				$data['arrival_airport_time'] = $line['arrtime'];
721
+				$data['registration'] = $line['aircraft'];
722
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
723
+			if (isset($line['aircraftname'])) {
724 724
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
725 725
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
726
-	    		$aircraft_data = explode('-',$line['aircraftname']);
727
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
728
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
729
-	    		else {
730
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
731
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
732
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
733
-	    		}
734
-	    	    }
735
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
736
-    		    $data['id_source'] = $id_source;
737
-	    	    $data['format_source'] = 'phpvmacars';
738
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
739
-		    $SI->add($data);
740
-		    unset($data);
726
+				$aircraft_data = explode('-',$line['aircraftname']);
727
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
728
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
729
+				else {
730
+					$aircraft_data = explode(' ',$line['aircraftname']);
731
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
732
+					else $data['aircraft_icao'] = $line['aircraftname'];
733
+				}
734
+				}
735
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
736
+				$data['id_source'] = $id_source;
737
+				$data['format_source'] = 'phpvmacars';
738
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
739
+			$SI->add($data);
740
+			unset($data);
741 741
 		}
742 742
 		if ($globalDebug) echo 'No more data...'."\n";
743 743
 		unset($buffer);
744 744
 		unset($all_data);
745
-	    }
746
-    	    //$last_exec['phpvmacars'] = time();
747
-    	    $last_exec[$id]['last'] = time();
748
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
749
-	    //$buffer = $Common->getData($hosts[$id]);
750
-	    if ($globalDebug) echo 'Get Data...'."\n";
751
-	    $buffer = $Common->getData($value['host']);
752
-	    $all_data = json_decode($buffer,true);
753
-	    if ($buffer != '' && is_array($all_data)) {
745
+		}
746
+			//$last_exec['phpvmacars'] = time();
747
+			$last_exec[$id]['last'] = time();
748
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
749
+		//$buffer = $Common->getData($hosts[$id]);
750
+		if ($globalDebug) echo 'Get Data...'."\n";
751
+		$buffer = $Common->getData($value['host']);
752
+		$all_data = json_decode($buffer,true);
753
+		if ($buffer != '' && is_array($all_data)) {
754 754
 		foreach ($all_data as $line) {
755
-	    	    $data = array();
756
-	    	    //$data['id'] = $line['id']; // id not usable
757
-	    	    $data['id'] = trim($line['flight_id']);
758
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
759
-	    	    $data['pilot_name'] = $line['pilot_name'];
760
-	    	    $data['pilot_id'] = $line['pilot_id'];
761
-	    	    $data['ident'] = trim($line['callsign']); // ident
762
-	    	    $data['altitude'] = $line['altitude']; // altitude
763
-	    	    $data['speed'] = $line['gs']; // speed
764
-	    	    $data['heading'] = $line['heading']; // heading
765
-	    	    $data['latitude'] = $line['latitude']; // lat
766
-	    	    $data['longitude'] = $line['longitude']; // long
767
-	    	    $data['verticalrate'] = ''; // verticale rate
768
-	    	    $data['squawk'] = ''; // squawk
769
-	    	    $data['emergency'] = ''; // emergency
770
-	    	    //$data['datetime'] = $line['lastupdate'];
771
-	    	    $data['last_update'] = $line['last_update'];
772
-		    $data['datetime'] = date('Y-m-d H:i:s');
773
-	    	    $data['departure_airport_icao'] = $line['departure'];
774
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
775
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
776
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
777
-    		    //$data['registration'] = $line['aircraft'];
778
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
779
-	    	    $data['aircraft_icao'] = $line['plane_type'];
780
-    		    $data['id_source'] = $id_source;
781
-	    	    $data['format_source'] = 'vam';
782
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
783
-		    $SI->add($data);
784
-		    unset($data);
755
+				$data = array();
756
+				//$data['id'] = $line['id']; // id not usable
757
+				$data['id'] = trim($line['flight_id']);
758
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
759
+				$data['pilot_name'] = $line['pilot_name'];
760
+				$data['pilot_id'] = $line['pilot_id'];
761
+				$data['ident'] = trim($line['callsign']); // ident
762
+				$data['altitude'] = $line['altitude']; // altitude
763
+				$data['speed'] = $line['gs']; // speed
764
+				$data['heading'] = $line['heading']; // heading
765
+				$data['latitude'] = $line['latitude']; // lat
766
+				$data['longitude'] = $line['longitude']; // long
767
+				$data['verticalrate'] = ''; // verticale rate
768
+				$data['squawk'] = ''; // squawk
769
+				$data['emergency'] = ''; // emergency
770
+				//$data['datetime'] = $line['lastupdate'];
771
+				$data['last_update'] = $line['last_update'];
772
+			$data['datetime'] = date('Y-m-d H:i:s');
773
+				$data['departure_airport_icao'] = $line['departure'];
774
+				//$data['departure_airport_time'] = $line['departure_time'];
775
+				$data['arrival_airport_icao'] = $line['arrival'];
776
+				//$data['arrival_airport_time'] = $line['arrival_time'];
777
+				//$data['registration'] = $line['aircraft'];
778
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
779
+				$data['aircraft_icao'] = $line['plane_type'];
780
+				$data['id_source'] = $id_source;
781
+				$data['format_source'] = 'vam';
782
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
783
+			$SI->add($data);
784
+			unset($data);
785 785
 		}
786 786
 		if ($globalDebug) echo 'No more data...'."\n";
787 787
 		unset($buffer);
788 788
 		unset($all_data);
789
-	    }
790
-    	    //$last_exec['phpvmacars'] = time();
791
-    	    $last_exec[$id]['last'] = time();
789
+		}
790
+			//$last_exec['phpvmacars'] = time();
791
+			$last_exec[$id]['last'] = time();
792 792
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
793 793
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3') {
794
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
795
-    	    //$last_exec[$id]['last'] = time();
794
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
795
+			//$last_exec[$id]['last'] = time();
796 796
 
797
-	    //$read = array( $sockets[$id] );
798
-	    $read = $sockets;
799
-	    $write = NULL;
800
-	    $e = NULL;
801
-	    $n = socket_select($read, $write, $e, $timeout);
802
-	    if ($e != NULL) var_dump($e);
803
-	    if ($n > 0) {
797
+		//$read = array( $sockets[$id] );
798
+		$read = $sockets;
799
+		$write = NULL;
800
+		$e = NULL;
801
+		$n = socket_select($read, $write, $e, $timeout);
802
+		if ($e != NULL) var_dump($e);
803
+		if ($n > 0) {
804 804
 		foreach ($read as $nb => $r) {
805
-		    //$value = $formats[$nb];
806
-		    $format = $globalSources[$nb]['format'];
807
-        	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
808
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
809
-        	    } else {
810
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
811
-	    	    }
812
-        	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
813
-        	    //echo $buffer."\n";
814
-		    // lets play nice and handle signals such as ctrl-c/kill properly
815
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
816
-		    $error = false;
817
-		    //$SI::del();
818
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
819
-		    // SBS format is CSV format
820
-		    if ($buffer != '') {
805
+			//$value = $formats[$nb];
806
+			$format = $globalSources[$nb]['format'];
807
+				if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
808
+				$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
809
+				} else {
810
+					$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
811
+				}
812
+				//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
813
+				//echo $buffer."\n";
814
+			// lets play nice and handle signals such as ctrl-c/kill properly
815
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
816
+			$error = false;
817
+			//$SI::del();
818
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
819
+			// SBS format is CSV format
820
+			if ($buffer != '') {
821 821
 			$tt[$format] = 0;
822 822
 			if ($format == 'acarssbs3') {
823
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
824
-			    $ACARS->add(trim($buffer));
825
-			    $ACARS->deleteLiveAcarsData();
823
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
824
+				$ACARS->add(trim($buffer));
825
+				$ACARS->deleteLiveAcarsData();
826 826
 			} elseif ($format == 'raw') {
827
-			    // AVR format
828
-			    $data = $SBS->parse($buffer);
829
-			    if (is_array($data)) {
827
+				// AVR format
828
+				$data = $SBS->parse($buffer);
829
+				if (is_array($data)) {
830 830
 				$data['datetime'] = date('Y-m-d H:i:s');
831 831
 				$data['format_source'] = 'raw';
832 832
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
833
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
834
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
835
-                            }
836
-                        } elseif ($format == 'flightgearsp') {
837
-                    	    //echo $buffer."\n";
838
-                    	    if (strlen($buffer) > 5) {
833
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
834
+								if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
835
+							}
836
+						} elseif ($format == 'flightgearsp') {
837
+							//echo $buffer."\n";
838
+							if (strlen($buffer) > 5) {
839 839
 				$line = explode(',',$buffer);
840 840
 				$data = array();
841 841
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -851,114 +851,114 @@  discard block
 block discarded – undo
851 851
 				$data['format_source'] = 'flightgearsp';
852 852
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
853 853
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
854
-			    }
855
-                        } elseif ($format == 'acars') {
856
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
857
-			    $ACARS->add(trim($buffer));
858
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
859
-			    $ACARS->deleteLiveAcarsData();
854
+				}
855
+						} elseif ($format == 'acars') {
856
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
857
+				$ACARS->add(trim($buffer));
858
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
859
+				$ACARS->deleteLiveAcarsData();
860 860
 			} elseif ($format == 'flightgearmp') {
861
-			    if (substr($buffer,0,1) != '#') {
861
+				if (substr($buffer,0,1) != '#') {
862 862
 				$data = array();
863 863
 				//echo $buffer."\n";
864 864
 				$line = explode(' ',$buffer);
865 865
 				if (count($line) == 11) {
866
-				    $userserver = explode('@',$line[0]);
867
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
868
-				    $data['ident'] = $userserver[0];
869
-				    $data['registration'] = $userserver[0];
870
-				    $data['latitude'] = $line[4];
871
-				    $data['longitude'] = $line[5];
872
-				    $data['altitude'] = $line[6];
873
-				    $data['datetime'] = date('Y-m-d H:i:s');
874
-				    $aircraft_type = $line[10];
875
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
876
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
877
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
866
+					$userserver = explode('@',$line[0]);
867
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
868
+					$data['ident'] = $userserver[0];
869
+					$data['registration'] = $userserver[0];
870
+					$data['latitude'] = $line[4];
871
+					$data['longitude'] = $line[5];
872
+					$data['altitude'] = $line[6];
873
+					$data['datetime'] = date('Y-m-d H:i:s');
874
+					$aircraft_type = $line[10];
875
+					$aircraft_type = preg_split(':/:',$aircraft_type);
876
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
877
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
878
+				}
878 879
 				}
879
-			    }
880 880
 			} elseif ($format == 'beast') {
881
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
882
-			    die;
881
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
882
+				die;
883 883
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
884
-			    $line = explode("\t", $buffer);
885
-			    for($k = 0; $k < count($line); $k=$k+2) {
884
+				$line = explode("\t", $buffer);
885
+				for($k = 0; $k < count($line); $k=$k+2) {
886 886
 				$key = $line[$k];
887
-			        $lined[$key] = $line[$k+1];
888
-			    }
889
-    			    if (count($lined) > 3) {
890
-    				$data['hex'] = $lined['hexid'];
891
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
892
-    				$data['datetime'] = date('Y-m-d H:i:s');;
893
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
894
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
895
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
896
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
897
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
898
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
899
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
900
-    				$data['id_source'] = $id_source;
901
-    				$data['format_source'] = 'tsv';
902
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
903
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
904
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
905
-    				unset($lined);
906
-    				unset($data);
907
-    			    } else $error = true;
887
+					$lined[$key] = $line[$k+1];
888
+				}
889
+					if (count($lined) > 3) {
890
+					$data['hex'] = $lined['hexid'];
891
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
892
+					$data['datetime'] = date('Y-m-d H:i:s');;
893
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
894
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
895
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
896
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
897
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
898
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
899
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
900
+					$data['id_source'] = $id_source;
901
+					$data['format_source'] = 'tsv';
902
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
903
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
904
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
905
+					unset($lined);
906
+					unset($data);
907
+					} else $error = true;
908 908
 			} elseif ($format == 'aprs' && $use_aprs) {
909
-			    if ($aprs_connect == 0) {
909
+				if ($aprs_connect == 0) {
910 910
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
911 911
 				$aprs_connect = 1;
912
-			    }
913
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
912
+				}
913
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
914 914
 				$aprs_last_tx = time();
915 915
 				$data_aprs = "# Keep alive";
916 916
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
917
-			    }
918
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
919
-			    $buffer = str_replace('APRS <- ','',$buffer);
920
-			    $buffer = str_replace('APRS -> ','',$buffer);
921
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
917
+				}
918
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
919
+				$buffer = str_replace('APRS <- ','',$buffer);
920
+				$buffer = str_replace('APRS -> ','',$buffer);
921
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
922 922
 				$line = $APRS->parse($buffer);
923 923
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
924
-				    $data = array();
925
-				    //print_r($line);
926
-				    $data['hex'] = $line['address'];
927
-				    $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
928
-				    //$data['datetime'] = date('Y-m-d H:i:s');
929
-				    $data['ident'] = $line['ident'];
930
-				    $data['latitude'] = $line['latitude'];
931
-				    $data['longitude'] = $line['longitude'];
932
-				    //$data['verticalrate'] = $line[16];
933
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
934
-				    else $data['speed'] = 0;
935
-				    $data['altitude'] = $line['altitude'];
936
-				    if (isset($line['course'])) $data['heading'] = $line['course'];
937
-				    //else $data['heading'] = 0;
938
-				    $data['aircraft_type'] = $line['stealth'];
939
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
940
-    				    $data['id_source'] = $id_source;
941
-				    $data['format_source'] = 'aprs';
942
-				    $data['source_name'] = $line['source'];
943
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
944
-				    $currentdate = date('Y-m-d H:i:s');
945
-				    $aprsdate = strtotime($data['datetime']);
946
-				    // Accept data if time <= system time + 20s
947
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
948
-				    else {
924
+					$data = array();
925
+					//print_r($line);
926
+					$data['hex'] = $line['address'];
927
+					$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
928
+					//$data['datetime'] = date('Y-m-d H:i:s');
929
+					$data['ident'] = $line['ident'];
930
+					$data['latitude'] = $line['latitude'];
931
+					$data['longitude'] = $line['longitude'];
932
+					//$data['verticalrate'] = $line[16];
933
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
934
+					else $data['speed'] = 0;
935
+					$data['altitude'] = $line['altitude'];
936
+					if (isset($line['course'])) $data['heading'] = $line['course'];
937
+					//else $data['heading'] = 0;
938
+					$data['aircraft_type'] = $line['stealth'];
939
+					if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
940
+						$data['id_source'] = $id_source;
941
+					$data['format_source'] = 'aprs';
942
+					$data['source_name'] = $line['source'];
943
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
944
+					$currentdate = date('Y-m-d H:i:s');
945
+					$aprsdate = strtotime($data['datetime']);
946
+					// Accept data if time <= system time + 20s
947
+					if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
948
+					else {
949 949
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
950 950
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
951
-				    }
952
-				    unset($data);
951
+					}
952
+					unset($data);
953 953
 				} 
954 954
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
955 955
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
956
-			    }
956
+				}
957 957
 			} else {
958
-			    $line = explode(',', $buffer);
959
-    			    if (count($line) > 20) {
960
-    			    	$data['hex'] = $line[4];
961
-    				/*
958
+				$line = explode(',', $buffer);
959
+					if (count($line) > 20) {
960
+						$data['hex'] = $line[4];
961
+					/*
962 962
     				$data['datetime'] = $line[6].' '.$line[7];
963 963
     					date_default_timezone_set($globalTimezone);
964 964
     					$datetime = new DateTime($data['datetime']);
@@ -966,28 +966,28 @@  discard block
 block discarded – undo
966 966
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
967 967
     					date_default_timezone_set('UTC');
968 968
     				*/
969
-    				// Force datetime to current UTC datetime
970
-    				$data['datetime'] = date('Y-m-d H:i:s');
971
-    				$data['ident'] = trim($line[10]);
972
-    				$data['latitude'] = $line[14];
973
-    				$data['longitude'] = $line[15];
974
-    				$data['verticalrate'] = $line[16];
975
-    				$data['emergency'] = $line[20];
976
-    				$data['speed'] = $line[12];
977
-    				$data['squawk'] = $line[17];
978
-    				$data['altitude'] = $line[11];
979
-    				$data['heading'] = $line[13];
980
-    				$data['ground'] = $line[21];
981
-    				$data['emergency'] = $line[19];
982
-    				$data['format_source'] = 'sbs';
969
+					// Force datetime to current UTC datetime
970
+					$data['datetime'] = date('Y-m-d H:i:s');
971
+					$data['ident'] = trim($line[10]);
972
+					$data['latitude'] = $line[14];
973
+					$data['longitude'] = $line[15];
974
+					$data['verticalrate'] = $line[16];
975
+					$data['emergency'] = $line[20];
976
+					$data['speed'] = $line[12];
977
+					$data['squawk'] = $line[17];
978
+					$data['altitude'] = $line[11];
979
+					$data['heading'] = $line[13];
980
+					$data['ground'] = $line[21];
981
+					$data['emergency'] = $line[19];
982
+					$data['format_source'] = 'sbs';
983 983
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
984
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
985
-    				$data['id_source'] = $id_source;
986
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
987
-    				else $error = true;
988
-    				unset($data);
989
-    			    } else $error = true;
990
-			    if ($error) {
984
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
985
+					$data['id_source'] = $id_source;
986
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
987
+					else $error = true;
988
+					unset($data);
989
+					} else $error = true;
990
+				if ($error) {
991 991
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
992 992
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
993 993
 				} else {
@@ -1003,13 +1003,13 @@  discard block
 block discarded – undo
1003 1003
 					connect_all($sourceer);
1004 1004
 					$sourceer = array();
1005 1005
 				}
1006
-			    }
1006
+				}
1007 1007
 			}
1008 1008
 			// Sleep for xxx microseconds
1009 1009
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1010
-		    } else {
1010
+			} else {
1011 1011
 			if ($format == 'flightgearmp') {
1012
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1012
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1013 1013
 				//@socket_close($r);
1014 1014
 				sleep($globalMinFetch);
1015 1015
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1018,9 +1018,9 @@  discard block
 block discarded – undo
1018 1018
 				break;
1019 1019
 				
1020 1020
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1021
-			    if (isset($tt[$format])) $tt[$format]++;
1022
-			    else $tt[$format] = 0;
1023
-			    if ($tt[$format] > 30) {
1021
+				if (isset($tt[$format])) $tt[$format]++;
1022
+				else $tt[$format] = 0;
1023
+				if ($tt[$format] > 30) {
1024 1024
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1025 1025
 				//@socket_close($r);
1026 1026
 				sleep(2);
@@ -1031,40 +1031,40 @@  discard block
 block discarded – undo
1031 1031
 				//connect_all($globalSources);
1032 1032
 				$tt[$format]=0;
1033 1033
 				break;
1034
-			    }
1034
+				}
1035
+			}
1035 1036
 			}
1036
-		    }
1037 1037
 		}
1038
-	    } else {
1038
+		} else {
1039 1039
 		$error = socket_strerror(socket_last_error());
1040 1040
 		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1041 1041
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) {
1042 1042
 			if (isset($globalDebug)) echo "Restarting...\n";
1043 1043
 			// Restart the script if possible
1044 1044
 			if (is_array($sockets)) {
1045
-			    if ($globalDebug) echo "Shutdown all sockets...";
1045
+				if ($globalDebug) echo "Shutdown all sockets...";
1046 1046
 			    
1047
-			    foreach ($sockets as $sock) {
1047
+				foreach ($sockets as $sock) {
1048 1048
 				@socket_shutdown($sock,2);
1049 1049
 				@socket_close($sock);
1050
-			    }
1050
+				}
1051 1051
 			    
1052 1052
 			}
1053
-			    if ($globalDebug) echo "Restart all connections...";
1054
-			    sleep(2);
1055
-			    $time = time();
1056
-			    //connect_all($hosts);
1057
-			    $aprs_connect = 0;
1058
-			    connect_all($globalSources);
1053
+				if ($globalDebug) echo "Restart all connections...";
1054
+				sleep(2);
1055
+				$time = time();
1056
+				//connect_all($hosts);
1057
+				$aprs_connect = 0;
1058
+				connect_all($globalSources);
1059 1059
 
1060 1060
 		}
1061
-	    }
1061
+		}
1062 1062
 	}
1063 1063
 	if ($globalDaemon === false) {
1064
-	    if ($globalDebug) echo 'Check all...'."\n";
1065
-	    $SI->checkAll();
1064
+		if ($globalDebug) echo 'Check all...'."\n";
1065
+		$SI->checkAll();
1066
+	}
1066 1067
 	}
1067
-    }
1068 1068
 }
1069 1069
 
1070 1070
 ?>
Please login to merge, or discard this patch.
install/VAM/VAM-json.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,27 +11,27 @@
 block discarded – undo
11 11
 	die();
12 12
 }
13 13
 $query = 'select * from vam_live_flights rc, gvausers gu where gu.gvauser_id = rc.gvauser_id';  
14
-$json_data=array();  
14
+$json_data = array();  
15 15
 $result = $db->query($query);
16 16
 while ($rec = $result->fetch_assoc())
17 17
 {  
18
-	$json_array['gvauser_id']=$rec['gvauser_id']; // users "pilot unique ID" "40"
19
-	$json_array['flight_id']=$rec['flight_id']; // flight_id
20
-	$json_array['pilot_id']=$rec['callsign']; // users pilot_id "VAM500"
21
-	$json_array['callsign']=substr($rec['flight_id'],-7);  // substr icao Flight "AFR524"
22
-	$json_array['pilot_name']=$rec['name'] .' '.$rec['surname'] ;  // Users "name + surname"
23
-	$json_array['plane_type']=$rec['plane_type'];  // type Plane "B739"
24
-	$json_array['departure']=$rec['departure'];  // departure ICAO
25
-	$json_array['arrival']=$rec['arrival'];     // arrival Ident
26
-	$json_array['latitude']=$rec['latitude'];  // return 55.7328860921521
27
-	$json_array['longitude']=$rec['longitude'];  // return 8.87433614409404
28
-	$json_array['altitude']=$rec['altitude'];  // return "147"
29
-	$json_array['heading']=$rec['heading'];  // return "307"
30
-	$json_array['ias']=$rec['ias'];  // return speed "IAS"
31
-	$json_array['gs']=$rec['gs'];  // return speed "GS"
18
+	$json_array['gvauser_id'] = $rec['gvauser_id']; // users "pilot unique ID" "40"
19
+	$json_array['flight_id'] = $rec['flight_id']; // flight_id
20
+	$json_array['pilot_id'] = $rec['callsign']; // users pilot_id "VAM500"
21
+	$json_array['callsign'] = substr($rec['flight_id'], -7); // substr icao Flight "AFR524"
22
+	$json_array['pilot_name'] = $rec['name'].' '.$rec['surname']; // Users "name + surname"
23
+	$json_array['plane_type'] = $rec['plane_type']; // type Plane "B739"
24
+	$json_array['departure'] = $rec['departure']; // departure ICAO
25
+	$json_array['arrival'] = $rec['arrival']; // arrival Ident
26
+	$json_array['latitude'] = $rec['latitude']; // return 55.7328860921521
27
+	$json_array['longitude'] = $rec['longitude']; // return 8.87433614409404
28
+	$json_array['altitude'] = $rec['altitude']; // return "147"
29
+	$json_array['heading'] = $rec['heading']; // return "307"
30
+	$json_array['ias'] = $rec['ias']; // return speed "IAS"
31
+	$json_array['gs'] = $rec['gs']; // return speed "GS"
32 32
 	// $json_array['routes']=$rec['routes'];  // (unusable)
33
-	$json_array['flight_status']=$rec['flight_status'];  // "return Status"
34
-	$json_array['last_update']=$rec['last_update'];  // return "DateTime"
33
+	$json_array['flight_status'] = $rec['flight_status']; // "return Status"
34
+	$json_array['last_update'] = $rec['last_update']; // return "DateTime"
35 35
 	$json_data[] = $json_array;
36 36
  }  
37 37
 echo json_encode($json_data);
Please login to merge, or discard this patch.
statistics-pilot.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
 
8 8
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
9 9
 if ($airline_icao == 'all') {
10
-    unset($_COOKIE['stats_airline_icao']);
11
-    setcookie('stats_airline_icao', '', time()-3600);
12
-    $airline_icao = '';
10
+	unset($_COOKIE['stats_airline_icao']);
11
+	setcookie('stats_airline_icao', '', time()-3600);
12
+	$airline_icao = '';
13 13
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
14
-    $airline_icao = $_COOKIE['stats_airline_icao'];
14
+	$airline_icao = $_COOKIE['stats_airline_icao'];
15 15
 } elseif ($airline_icao == '' && isset($globalFilter)) {
16
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
16
+	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
17 17
 }
18 18
 setcookie('stats_airline_icao',$airline_icao);
19 19
 
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
           function drawChart() {
35 35
             var data = google.visualization.arrayToDataTable([
36 36
             	["'._("Pilot").'", "'._("# of times").'"], ';
37
-            	$pilot_data = '';
37
+				$pilot_data = '';
38 38
 		foreach($pilot_array as $pilot_item)
39 39
 		{
40 40
 			$pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
41 41
 		}
42 42
 		$pilot_data = substr($pilot_data, 0, -1);
43 43
 		print $pilot_data;
44
-            print ']);
44
+			print ']);
45 45
     
46 46
             var options = {
47 47
             	chartArea: {"width": "80%", "height": "60%"},
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,17 +6,17 @@  discard block
 block discarded – undo
6 6
 $title = _("Statistics").' - '._("Most common Pilots");
7 7
 
8 8
 if (!isset($filter_name)) $filter_name = '';
9
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
9
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == 'all') {
11 11
     unset($_COOKIE['stats_airline_icao']);
12
-    setcookie('stats_airline_icao', '', time()-3600);
12
+    setcookie('stats_airline_icao', '', time() - 3600);
13 13
     $airline_icao = '';
14 14
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
15 15
     $airline_icao = $_COOKIE['stats_airline_icao'];
16 16
 } elseif ($airline_icao == '' && isset($globalFilter)) {
17 17
     if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
18 18
 }
19
-setcookie('stats_airline_icao',$airline_icao);
19
+setcookie('stats_airline_icao', $airline_icao);
20 20
 
21 21
 require_once('header.php');
22 22
 include('statistics-sub-menu.php');
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	</div>
28 28
 	<p>'._("Below are the <strong>Top 10</strong> most common pilot.").'</p>';
29 29
 	  
30
-	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name);
30
+	$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name);
31 31
 	print '<div id="chart" class="chart" width="100%"></div>
32 32
       	<script> 
33 33
       		google.load("visualization", "1", {packages:["corechart"]});
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
             var data = google.visualization.arrayToDataTable([
37 37
             	["'._("Pilot").'", "'._("# of times").'"], ';
38 38
             	$pilot_data = '';
39
-		foreach($pilot_array as $pilot_item)
39
+		foreach ($pilot_array as $pilot_item)
40 40
 		{
41 41
 			$pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
42 42
 		}
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	print '</thead>';
70 70
 	print '<tbody>';
71 71
 	$i = 1;
72
-	foreach($pilot_array as $pilot_item)
72
+	foreach ($pilot_array as $pilot_item)
73 73
 	{
74 74
 		print '<tr>';
75 75
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@  discard block
 block discarded – undo
5 5
 $Stats = new Stats();
6 6
 $title = _("Statistics").' - '._("Most common Callsign");
7 7
 
8
-if (!isset($filter_name)) $filter_name = '';
8
+if (!isset($filter_name)) {
9
+	$filter_name = '';
10
+}
9 11
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 12
 if ($airline_icao == 'all') {
11 13
     unset($_COOKIE['stats_airline_icao']);
@@ -14,8 +16,10 @@  discard block
 block discarded – undo
14 16
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
15 17
     $airline_icao = $_COOKIE['stats_airline_icao'];
16 18
 } elseif ($airline_icao == '' && isset($globalFilter)) {
17
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
18
-}
19
+    if (isset($globalFilter['airline'])) {
20
+    	$airline_icao = $globalFilter['airline'][0];
21
+    }
22
+    }
19 23
 setcookie('stats_airline_icao',$airline_icao);
20 24
 
21 25
 require_once('header.php');
Please login to merge, or discard this patch.
statistics-owner.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
 
8 8
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
9 9
 if ($airline_icao == 'all') {
10
-    unset($_COOKIE['stats_airline_icao']);
11
-    setcookie('stats_airline_icao', '', time()-3600);
12
-    $airline_icao = '';
10
+	unset($_COOKIE['stats_airline_icao']);
11
+	setcookie('stats_airline_icao', '', time()-3600);
12
+	$airline_icao = '';
13 13
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
14
-    $airline_icao = $_COOKIE['stats_airline_icao'];
14
+	$airline_icao = $_COOKIE['stats_airline_icao'];
15 15
 } elseif ($airline_icao == '' && isset($globalFilter)) {
16
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
16
+	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
17 17
 }
18 18
 setcookie('stats_airline_icao',$airline_icao);
19 19
 
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
           function drawChart() {
34 34
             var data = google.visualization.arrayToDataTable([
35 35
             	["'._("Owner").'", "'._("# of times").'"], ';
36
-            	$owner_data = '';
36
+				$owner_data = '';
37 37
 		foreach($owner_array as $owner_item)
38 38
 		{
39 39
 			$owner_data .= '[ "'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
40 40
 		}
41 41
 		$owner_data = substr($owner_data, 0, -1);
42 42
 		print $owner_data;
43
-            print ']);
43
+			print ']);
44 44
     
45 45
             var options = {
46 46
             	chartArea: {"width": "80%", "height": "60%"},
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,17 +6,17 @@  discard block
 block discarded – undo
6 6
 $title = _("Statistics").' - '._("Most common owners");
7 7
 
8 8
 if (!isset($filter_name)) $filter_name = '';
9
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
9
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == 'all') {
11 11
     unset($_COOKIE['stats_airline_icao']);
12
-    setcookie('stats_airline_icao', '', time()-3600);
12
+    setcookie('stats_airline_icao', '', time() - 3600);
13 13
     $airline_icao = '';
14 14
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
15 15
     $airline_icao = $_COOKIE['stats_airline_icao'];
16 16
 } elseif ($airline_icao == '' && isset($globalFilter)) {
17 17
     if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
18 18
 }
19
-setcookie('stats_airline_icao',$airline_icao);
19
+setcookie('stats_airline_icao', $airline_icao);
20 20
 
21 21
 require_once('header.php');
22 22
 include('statistics-sub-menu.php');
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	</div>
27 27
 	<p>'._("Below are the <strong>Top 10</strong> most common owner.").'</p>';
28 28
  
29
-	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name);
29
+	$owner_array = $Stats->countAllOwners(true, $airline_icao, $filter_name);
30 30
 	print '<div id="chart" class="chart" width="100%"></div>
31 31
       	<script> 
32 32
       		google.load("visualization", "1", {packages:["corechart"]});
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
             var data = google.visualization.arrayToDataTable([
36 36
             	["'._("Owner").'", "'._("# of times").'"], ';
37 37
             	$owner_data = '';
38
-		foreach($owner_array as $owner_item)
38
+		foreach ($owner_array as $owner_item)
39 39
 		{
40 40
 			$owner_data .= '[ "'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
41 41
 		}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	print '</thead>';
69 69
 	print '<tbody>';
70 70
 	$i = 1;
71
-	foreach($owner_array as $owner_item)
71
+	foreach ($owner_array as $owner_item)
72 72
 	{
73 73
 		print '<tr>';
74 74
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@  discard block
 block discarded – undo
5 5
 $Stats = new Stats();
6 6
 $title = _("Statistics").' - '._("Most common Callsign");
7 7
 
8
-if (!isset($filter_name)) $filter_name = '';
8
+if (!isset($filter_name)) {
9
+	$filter_name = '';
10
+}
9 11
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 12
 if ($airline_icao == 'all') {
11 13
     unset($_COOKIE['stats_airline_icao']);
@@ -14,8 +16,10 @@  discard block
 block discarded – undo
14 16
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
15 17
     $airline_icao = $_COOKIE['stats_airline_icao'];
16 18
 } elseif ($airline_icao == '' && isset($globalFilter)) {
17
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
18
-}
19
+    if (isset($globalFilter['airline'])) {
20
+    	$airline_icao = $globalFilter['airline'][0];
21
+    }
22
+    }
19 23
 setcookie('stats_airline_icao',$airline_icao);
20 24
 
21 25
 require_once('header.php');
Please login to merge, or discard this patch.
statistics-registration.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
 
8 8
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
9 9
 if ($airline_icao == 'all') {
10
-    unset($_COOKIE['stats_airline_icao']);
11
-    setcookie('stats_airline_icao', '', time()-3600);
12
-    $airline_icao = '';
10
+	unset($_COOKIE['stats_airline_icao']);
11
+	setcookie('stats_airline_icao', '', time()-3600);
12
+	$airline_icao = '';
13 13
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
14
-    $airline_icao = $_COOKIE['stats_airline_icao'];
14
+	$airline_icao = $_COOKIE['stats_airline_icao'];
15 15
 } elseif ($airline_icao == '' && isset($globalFilter)) {
16
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
16
+	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
17 17
 }
18 18
 setcookie('stats_airline_icao',$airline_icao);
19 19
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
           function drawChart() {
35 35
             var data = google.visualization.arrayToDataTable([
36 36
             	["'._("Aircraft Manufacturer").'", "'._("# of times").'"], ';
37
-            	$registration_data = '';
37
+				$registration_data = '';
38 38
 foreach($registration_array as $registration_item)
39 39
 {
40 40
 	$registration_data .= '[ "'.$registration_item['registration'].' - '.$registration_item['aircraft_name'].' ('.$registration_item['aircraft_icao'].')",'.$registration_item['aircraft_registration_count'].'],';
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,17 +6,17 @@  discard block
 block discarded – undo
6 6
 $title = _("Statistics").' - '._("Most common Aircraft Registrations");
7 7
 
8 8
 if (!isset($filter_name)) $filter_name = '';
9
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
9
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == 'all') {
11 11
     unset($_COOKIE['stats_airline_icao']);
12
-    setcookie('stats_airline_icao', '', time()-3600);
12
+    setcookie('stats_airline_icao', '', time() - 3600);
13 13
     $airline_icao = '';
14 14
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
15 15
     $airline_icao = $_COOKIE['stats_airline_icao'];
16 16
 } elseif ($airline_icao == '' && isset($globalFilter)) {
17 17
     if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
18 18
 }
19
-setcookie('stats_airline_icao',$airline_icao);
19
+setcookie('stats_airline_icao', $airline_icao);
20 20
 
21 21
 require_once('header.php');
22 22
 include('statistics-sub-menu.php'); 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	</div>
28 28
     	<p>'._("Below are the <strong>Top 10</strong> most common aircraft registrations.").'</p>';
29 29
   
30
-$registration_array = $Stats->countAllAircraftRegistrations(true,$airline_icao,$filter_name);
30
+$registration_array = $Stats->countAllAircraftRegistrations(true, $airline_icao, $filter_name);
31 31
 print '<div id="chart" class="chart" width="100%"></div>
32 32
       	    <script> 
33 33
       		google.load("visualization", "1", {packages:["corechart"]});
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
             var data = google.visualization.arrayToDataTable([
37 37
             	["'._("Aircraft Manufacturer").'", "'._("# of times").'"], ';
38 38
             	$registration_data = '';
39
-foreach($registration_array as $registration_item)
39
+foreach ($registration_array as $registration_item)
40 40
 {
41 41
 	$registration_data .= '[ "'.$registration_item['registration'].' - '.$registration_item['aircraft_name'].' ('.$registration_item['aircraft_icao'].')",'.$registration_item['aircraft_registration_count'].'],';
42 42
 }
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	print '</thead>';
72 72
 	print '<tbody>';
73 73
 	$i = 1;
74
-	foreach($registration_array as $registration_item)
74
+	foreach ($registration_array as $registration_item)
75 75
 	{
76 76
 		print '<tr>';
77 77
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@  discard block
 block discarded – undo
5 5
 $Stats = new Stats();
6 6
 $title = _("Statistics").' - '._("Most common Callsign");
7 7
 
8
-if (!isset($filter_name)) $filter_name = '';
8
+if (!isset($filter_name)) {
9
+	$filter_name = '';
10
+}
9 11
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 12
 if ($airline_icao == 'all') {
11 13
     unset($_COOKIE['stats_airline_icao']);
@@ -14,8 +16,10 @@  discard block
 block discarded – undo
14 16
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
15 17
     $airline_icao = $_COOKIE['stats_airline_icao'];
16 18
 } elseif ($airline_icao == '' && isset($globalFilter)) {
17
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
18
-}
19
+    if (isset($globalFilter['airline'])) {
20
+    	$airline_icao = $globalFilter['airline'][0];
21
+    }
22
+    }
19 23
 setcookie('stats_airline_icao',$airline_icao);
20 24
 
21 25
 require_once('header.php');
Please login to merge, or discard this patch.
statistics-country.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@
 block discarded – undo
7 7
 
8 8
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
9 9
 if ($airline_icao == 'all') {
10
-    unset($_COOKIE['stats_airline_icao']);
11
-    setcookie('stats_airline_icao', '', time()-3600);
12
-    $airline_icao = '';
10
+	unset($_COOKIE['stats_airline_icao']);
11
+	setcookie('stats_airline_icao', '', time()-3600);
12
+	$airline_icao = '';
13 13
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
14
-    $airline_icao = $_COOKIE['stats_airline_icao'];
14
+	$airline_icao = $_COOKIE['stats_airline_icao'];
15 15
 } elseif ($airline_icao == '' && isset($globalFilter)) {
16
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
16
+	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
17 17
 }
18 18
 setcookie('stats_airline_icao',$airline_icao);
19 19
 
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,17 +6,17 @@  discard block
 block discarded – undo
6 6
 $title = _("Statistics").' - '._("Most common Country a flight was over");
7 7
 
8 8
 if (!isset($filter_name)) $filter_name = '';
9
-$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
9
+$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == 'all') {
11 11
     unset($_COOKIE['stats_airline_icao']);
12
-    setcookie('stats_airline_icao', '', time()-3600);
12
+    setcookie('stats_airline_icao', '', time() - 3600);
13 13
     $airline_icao = '';
14 14
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
15 15
     $airline_icao = $_COOKIE['stats_airline_icao'];
16 16
 } elseif ($airline_icao == '' && isset($globalFilter)) {
17 17
     if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
18 18
 }
19
-setcookie('stats_airline_icao',$airline_icao);
19
+setcookie('stats_airline_icao', $airline_icao);
20 20
 
21 21
 require_once('header.php');
22 22
 include('statistics-sub-menu.php'); 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	  </div>
28 28
 	<p>'._("Below are the <strong>Top 10</strong> most common country a flight was over.").'</p>';
29 29
 
30
-$flightover_array = $Stats->countAllFlightOverCountries(true,$airline_icao,$filter_name);
30
+$flightover_array = $Stats->countAllFlightOverCountries(true, $airline_icao, $filter_name);
31 31
 print '<div id="chart" class="chart" width="100%"></div>
32 32
       	<script> 
33 33
       		google.load("visualization", "1", {packages:["corechart"]});
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
             var data = google.visualization.arrayToDataTable([
37 37
             	["'._("Country").'", "'._("# of times").'"], ';
38 38
 $flightover_data = '';
39
-foreach($flightover_array as $flightover_item)
39
+foreach ($flightover_array as $flightover_item)
40 40
 {
41 41
 	$flightover_data .= '[ "'.$flightover_item['flight_country'].' ('.$flightover_item['flight_country_iso2'].')",'.$flightover_item['flight_count'].'],';
42 42
 }
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	print '</thead>';
72 72
 	print '<tbody>';
73 73
 	$i = 1;
74
-	foreach($flightover_array as $flightover_item)
74
+	foreach ($flightover_array as $flightover_item)
75 75
 	{
76 76
 		print '<tr>';
77 77
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@  discard block
 block discarded – undo
5 5
 $Stats = new Stats();
6 6
 $title = _("Statistics").' - '._("Most common Callsign");
7 7
 
8
-if (!isset($filter_name)) $filter_name = '';
8
+if (!isset($filter_name)) {
9
+	$filter_name = '';
10
+}
9 11
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 12
 if ($airline_icao == 'all') {
11 13
     unset($_COOKIE['stats_airline_icao']);
@@ -14,8 +16,10 @@  discard block
 block discarded – undo
14 16
 } elseif ($airline_icao == '' && isset($_COOKIE['stats_airline_icao'])) {
15 17
     $airline_icao = $_COOKIE['stats_airline_icao'];
16 18
 } elseif ($airline_icao == '' && isset($globalFilter)) {
17
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
18
-}
19
+    if (isset($globalFilter['airline'])) {
20
+    	$airline_icao = $globalFilter['airline'][0];
21
+    }
22
+    }
19 23
 setcookie('stats_airline_icao',$airline_icao);
20 24
 
21 25
 require_once('header.php');
Please login to merge, or discard this patch.