Completed
Push — master ( 362b52...c440c8 )
by Yannick
09:25
created
location-data.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 $Source = new Source();
6 6
 
7 7
 if (isset($_GET['sourceid'])) {
8
-	$sourceid = filter_input(INPUT_GET,'sourceid',FILTER_SANITIZE_NUMBER_INT);
8
+	$sourceid = filter_input(INPUT_GET, 'sourceid', FILTER_SANITIZE_NUMBER_INT);
9 9
 	$source_data = $Source->getLocationInfoById($sourceid);
10 10
 	if (isset($source_data[0])) {
11 11
  ?>
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 print '</div>';
35 35
 
36 36
 if ($spotter_item['city'] != '') print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>';
37
-if ($spotter_item['country'] !='') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
38
-print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],3).', '.round($spotter_item['longitude'],3).'</div>';
37
+if ($spotter_item['country'] != '') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
38
+print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'], 3).', '.round($spotter_item['longitude'], 3).'</div>';
39 39
 /*
40 40
 if ($spotter_item['atc_range'] > 0) {
41 41
     print '<div><span>'._("Range").'</span>';
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 }
45 45
 */
46 46
 if ($spotter_item['type'] == 'wx') {
47
-	$weather = json_decode($spotter_item['description'],true);
47
+	$weather = json_decode($spotter_item['description'], true);
48 48
 	//print_r($weather);
49 49
 	if (isset($weather['temp'])) print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>';
50 50
 	if (isset($weather['pressure'])) print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'°hPa</div>';
Please login to merge, or discard this patch.
Braces   +32 added lines, -11 removed lines patch added patch discarded remove patch
@@ -17,8 +17,11 @@  discard block
 block discarded – undo
17 17
 date_default_timezone_set('UTC');
18 18
 
19 19
 print '<div class="top">';
20
-if ($spotter_item['name'] != '') print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['name'].'</div>';
21
-else print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['location_id'].'</div>';
20
+if ($spotter_item['name'] != '') {
21
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['name'].'</div>';
22
+} else {
23
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['location_id'].'</div>';
24
+}
22 25
 print '</div>';
23 26
 
24 27
 print '</div></div>';
@@ -33,8 +36,12 @@  discard block
 block discarded – undo
33 36
 print $spotter_item['last_seen'].' UTC';
34 37
 print '</div>';
35 38
 
36
-if ($spotter_item['city'] != '') print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>';
37
-if ($spotter_item['country'] !='') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
39
+if ($spotter_item['city'] != '') {
40
+	print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>';
41
+}
42
+if ($spotter_item['country'] !='') {
43
+	print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
44
+}
38 45
 print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],3).', '.round($spotter_item['longitude'],3).'</div>';
39 46
 /*
40 47
 if ($spotter_item['atc_range'] > 0) {
@@ -46,13 +53,27 @@  discard block
 block discarded – undo
46 53
 if ($spotter_item['type'] == 'wx') {
47 54
 	$weather = json_decode($spotter_item['description'],true);
48 55
 	//print_r($weather);
49
-	if (isset($weather['temp'])) print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>';
50
-	if (isset($weather['pressure'])) print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'°hPa</div>';
51
-	if (isset($weather['wind_gust'])) print '<div><span>'._("Wind Gust").'</span>'.$weather['wind_gust'].' km/h</div>';
52
-	if (isset($weather['humidity'])) print '<div><span>'._("Humidity").'</span>'.$weather['humidity'].'%</div>';
53
-	if (isset($weather['rain'])) print '<div><span>'._("Rain").'</span>'.$weather['rain'].' mm</div>';
54
-	if (isset($weather['precipitation'])) print '<div><span>'._("Precipitation 24H").'</span>'.$weather['precipitation'].' mm</div>';
55
-	if (isset($weather['precipitation24h'])) print '<div><span>'._("Precipitation Today").'</span>'.$weather['precipitation24h'].' mm</div>';
56
+	if (isset($weather['temp'])) {
57
+		print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>';
58
+	}
59
+	if (isset($weather['pressure'])) {
60
+		print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'°hPa</div>';
61
+	}
62
+	if (isset($weather['wind_gust'])) {
63
+		print '<div><span>'._("Wind Gust").'</span>'.$weather['wind_gust'].' km/h</div>';
64
+	}
65
+	if (isset($weather['humidity'])) {
66
+		print '<div><span>'._("Humidity").'</span>'.$weather['humidity'].'%</div>';
67
+	}
68
+	if (isset($weather['rain'])) {
69
+		print '<div><span>'._("Rain").'</span>'.$weather['rain'].' mm</div>';
70
+	}
71
+	if (isset($weather['precipitation'])) {
72
+		print '<div><span>'._("Precipitation 24H").'</span>'.$weather['precipitation'].' mm</div>';
73
+	}
74
+	if (isset($weather['precipitation24h'])) {
75
+		print '<div><span>'._("Precipitation Today").'</span>'.$weather['precipitation24h'].' mm</div>';
76
+	}
56 77
 	$spotter_item['description'] = $weather['comment'];
57 78
 }
58 79
 print '</div>';
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Indentation   +940 added lines, -940 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,42 +25,42 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->latest() === false) {
28
-    echo "You MUST update to latest schema. Run install/index.php";
29
-    exit();
28
+	echo "You MUST update to latest schema. Run install/index.php";
29
+	exit();
30 30
 }
31 31
 if (PHP_SAPI != 'cli') {
32
-    echo "This script MUST be called from console, not a web browser.";
32
+	echo "This script MUST be called from console, not a web browser.";
33 33
 //    exit();
34 34
 }
35 35
 
36 36
 // This is to be compatible with old version of settings.php
37 37
 if (!isset($globalSources)) {
38
-    if (isset($globalSBS1Hosts)) {
39
-        //$hosts = $globalSBS1Hosts;
40
-        foreach ($globalSBS1Hosts as $host) {
41
-	    $globalSources[] = array('host' => $host);
42
-    	}
43
-    } else {
44
-        if (!isset($globalSBS1Host)) {
45
-	    echo '$globalSources MUST be defined !';
46
-	    die;
38
+	if (isset($globalSBS1Hosts)) {
39
+		//$hosts = $globalSBS1Hosts;
40
+		foreach ($globalSBS1Hosts as $host) {
41
+		$globalSources[] = array('host' => $host);
42
+		}
43
+	} else {
44
+		if (!isset($globalSBS1Host)) {
45
+		echo '$globalSources MUST be defined !';
46
+		die;
47 47
 	}
48 48
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
49 49
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
50
-    }
50
+	}
51 51
 }
52 52
 
53 53
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
54 54
 //if (isset($options['s'])) $hosts = array($options['s']);
55 55
 //elseif (isset($options['source'])) $hosts = array($options['source']);
56 56
 if (isset($options['s'])) {
57
-    $globalSources = array();
58
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
59
-    else $globalSources[] = array('host' => $options['s']);
57
+	$globalSources = array();
58
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
59
+	else $globalSources[] = array('host' => $options['s']);
60 60
 } elseif (isset($options['source'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['source']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['source']);
64 64
 }
65 65
 if (isset($options['aprsserverhost'])) {
66 66
 	$globalServerAPRS = TRUE;
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 if (isset($options['idsource'])) $id_source = $options['idsource'];
76 76
 else $id_source = 1;
77 77
 if (isset($globalServer) && $globalServer) {
78
-    if ($globalDebug) echo "Using Server Mode\n";
79
-    $SI=new SpotterServer();
78
+	if ($globalDebug) echo "Using Server Mode\n";
79
+	$SI=new SpotterServer();
80 80
 /*
81 81
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
82 82
     $SI = new adsb2aprs();
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 } else $SI=new SpotterImport($Connection->db);
86 86
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
87 87
 if (isset($globalMarine) && $globalMarine) {
88
-    $AIS = new AIS();
89
-    $MI = new MarineImport($Connection->db);
88
+	$AIS = new AIS();
89
+	$MI = new MarineImport($Connection->db);
90 90
 }
91 91
 //$APRS=new APRS($Connection->db);
92 92
 $SBS=new SBS();
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 //$servertz = system('date +%Z');
98 98
 // signal handler - playing nice with sockets and dump1090
99 99
 if (function_exists('pcntl_fork')) {
100
-    pcntl_signal(SIGINT,  function() {
101
-        global $sockets;
102
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
103
-        die("Bye!\n");
104
-    });
105
-    pcntl_signal_dispatch();
100
+	pcntl_signal(SIGINT,  function() {
101
+		global $sockets;
102
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
103
+		die("Bye!\n");
104
+	});
105
+	pcntl_signal_dispatch();
106 106
 }
107 107
 
108 108
 // let's try and connect
@@ -112,36 +112,36 @@  discard block
 block discarded – undo
112 112
 $reset = 0;
113 113
 
114 114
 function connect_all($hosts) {
115
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
117
-    $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
119
-    foreach ($hosts as $id => $value) {
115
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
117
+	$reset++;
118
+	if ($globalDebug) echo 'Connect to all...'."\n";
119
+	foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123 123
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
125
-        	//$formats[$id] = 'deltadbtxt';
126
-        	$globalSources[$id]['format'] = 'deltadbtxt';
127
-        	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
-        	//$formats[$id] = 'vatsimtxt';
131
-        	$globalSources[$id]['format'] = 'vatsimtxt';
132
-        	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135
-        	//$formats[$id] = 'aircraftlistjson';
136
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
137
-        	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
140
-        	//$formats[$id] = 'aircraftlistjson';
141
-        	$globalSources[$id]['format'] = 'opensky';
142
-        	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
-    	    /*
124
+			if (preg_match('/deltadb.txt$/i',$host)) {
125
+			//$formats[$id] = 'deltadbtxt';
126
+			$globalSources[$id]['format'] = 'deltadbtxt';
127
+			//$last_exec['deltadbtxt'] = 0;
128
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
+			//$formats[$id] = 'vatsimtxt';
131
+			$globalSources[$id]['format'] = 'vatsimtxt';
132
+			//$last_exec['vatsimtxt'] = 0;
133
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
135
+			//$formats[$id] = 'aircraftlistjson';
136
+			$globalSources[$id]['format'] = 'aircraftlistjson';
137
+			//$last_exec['aircraftlistjson'] = 0;
138
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
+			} else if (preg_match('/opensky/i',$host)) {
140
+			//$formats[$id] = 'aircraftlistjson';
141
+			$globalSources[$id]['format'] = 'opensky';
142
+			//$last_exec['aircraftlistjson'] = 0;
143
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
+			/*
145 145
     	    // Disabled for now, site change source format
146 146
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
147 147
         	//$formats[$id] = 'radarvirtueljson';
@@ -153,118 +153,118 @@  discard block
 block discarded – undo
153 153
         	    exit(0);
154 154
         	}
155 155
     	    */
156
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
157
-        	//$formats[$id] = 'planeupdatefaa';
158
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
159
-        	//$last_exec['planeupdatefaa'] = 0;
160
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
161
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
162
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163
-        	    exit(0);
164
-        	}
165
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
166
-        	//$formats[$id] = 'phpvmacars';
167
-        	$globalSources[$id]['format'] = 'phpvmacars';
168
-        	//$last_exec['phpvmacars'] = 0;
169
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
170
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
171
-        	//$formats[$id] = 'phpvmacars';
172
-        	$globalSources[$id]['format'] = 'vam';
173
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
174
-            } else if (preg_match('/whazzup/i',$host)) {
175
-        	//$formats[$id] = 'whazzup';
176
-        	$globalSources[$id]['format'] = 'whazzup';
177
-        	//$last_exec['whazzup'] = 0;
178
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
179
-            } else if (preg_match('/airwhere/i',$host)) {
180
-        	$globalSources[$id]['format'] = 'airwhere';
181
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
182
-            } else if (preg_match('/recentpireps/i',$host)) {
183
-        	//$formats[$id] = 'pirepsjson';
184
-        	$globalSources[$id]['format'] = 'pirepsjson';
185
-        	//$last_exec['pirepsjson'] = 0;
186
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
187
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
188
-        	//$formats[$id] = 'fr24json';
189
-        	$globalSources[$id]['format'] = 'fr24json';
190
-        	//$last_exec['fr24json'] = 0;
191
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
192
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
193
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
194
-        	    exit(0);
195
-        	}
196
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
197
-        	//$formats[$id] = 'fr24json';
198
-        	$globalSources[$id]['format'] = 'myshiptracking';
199
-        	//$last_exec['fr24json'] = 0;
200
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
201
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
202
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
203
-        	    exit(0);
204
-        	}
205
-            //} else if (preg_match('/10001/',$host)) {
206
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
207
-        	//$formats[$id] = 'tsv';
208
-        	$globalSources[$id]['format'] = 'tsv';
209
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
210
-            }
211
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
212
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
213
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
214
-    		    if ($idf !== false) {
215
-    			$httpfeeds[$id] = $idf;
216
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
217
-    		    }
218
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
219
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
220
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
221
-	    $hostport = explode(':',$host);
222
-	    if (isset($hostport[1])) {
156
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
157
+			//$formats[$id] = 'planeupdatefaa';
158
+			$globalSources[$id]['format'] = 'planeupdatefaa';
159
+			//$last_exec['planeupdatefaa'] = 0;
160
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
161
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
162
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163
+				exit(0);
164
+			}
165
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
166
+			//$formats[$id] = 'phpvmacars';
167
+			$globalSources[$id]['format'] = 'phpvmacars';
168
+			//$last_exec['phpvmacars'] = 0;
169
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
170
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
171
+			//$formats[$id] = 'phpvmacars';
172
+			$globalSources[$id]['format'] = 'vam';
173
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
174
+			} else if (preg_match('/whazzup/i',$host)) {
175
+			//$formats[$id] = 'whazzup';
176
+			$globalSources[$id]['format'] = 'whazzup';
177
+			//$last_exec['whazzup'] = 0;
178
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
179
+			} else if (preg_match('/airwhere/i',$host)) {
180
+			$globalSources[$id]['format'] = 'airwhere';
181
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
182
+			} else if (preg_match('/recentpireps/i',$host)) {
183
+			//$formats[$id] = 'pirepsjson';
184
+			$globalSources[$id]['format'] = 'pirepsjson';
185
+			//$last_exec['pirepsjson'] = 0;
186
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
187
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
188
+			//$formats[$id] = 'fr24json';
189
+			$globalSources[$id]['format'] = 'fr24json';
190
+			//$last_exec['fr24json'] = 0;
191
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
192
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
193
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
194
+				exit(0);
195
+			}
196
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
197
+			//$formats[$id] = 'fr24json';
198
+			$globalSources[$id]['format'] = 'myshiptracking';
199
+			//$last_exec['fr24json'] = 0;
200
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
201
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
202
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
203
+				exit(0);
204
+			}
205
+			//} else if (preg_match('/10001/',$host)) {
206
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
207
+			//$formats[$id] = 'tsv';
208
+			$globalSources[$id]['format'] = 'tsv';
209
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
210
+			}
211
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
212
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
213
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
214
+				if ($idf !== false) {
215
+				$httpfeeds[$id] = $idf;
216
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
217
+				}
218
+				elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
219
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
220
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
221
+		$hostport = explode(':',$host);
222
+		if (isset($hostport[1])) {
223 223
 		$port = $hostport[1];
224 224
 		$hostn = $hostport[0];
225
-	    } else {
225
+		} else {
226 226
 		$port = $globalSources[$id]['port'];
227 227
 		$hostn = $globalSources[$id]['host'];
228
-	    }
229
-	    $Common = new Common();
230
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
231
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
232
-    	    } else {
233
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
234
-	    }
235
-	    if ($s) {
236
-    	        $sockets[$id] = $s;
237
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
238
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
228
+		}
229
+		$Common = new Common();
230
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
231
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
232
+			} else {
233
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
234
+		}
235
+		if ($s) {
236
+				$sockets[$id] = $s;
237
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
238
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
239 239
 			//$formats[$id] = 'aprs';
240 240
 			$globalSources[$id]['format'] = 'aprs';
241 241
 			//$aprs_connect = 0;
242 242
 			//$use_aprs = true;
243
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
243
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
244 244
 			$globalSources[$id]['format'] = 'vrstcp';
245
-    		    } elseif ($port == '10001') {
246
-        		//$formats[$id] = 'tsv';
247
-        		$globalSources[$id]['format'] = 'tsv';
248
-		    } elseif ($port == '30002') {
249
-        		//$formats[$id] = 'raw';
250
-        		$globalSources[$id]['format'] = 'raw';
251
-		    } elseif ($port == '5001') {
252
-        		//$formats[$id] = 'raw';
253
-        		$globalSources[$id]['format'] = 'flightgearmp';
254
-		    } elseif ($port == '30005') {
245
+				} elseif ($port == '10001') {
246
+				//$formats[$id] = 'tsv';
247
+				$globalSources[$id]['format'] = 'tsv';
248
+			} elseif ($port == '30002') {
249
+				//$formats[$id] = 'raw';
250
+				$globalSources[$id]['format'] = 'raw';
251
+			} elseif ($port == '5001') {
252
+				//$formats[$id] = 'raw';
253
+				$globalSources[$id]['format'] = 'flightgearmp';
254
+			} elseif ($port == '30005') {
255 255
 			// Not yet supported
256
-        		//$formats[$id] = 'beast';
257
-        		$globalSources[$id]['format'] = 'beast';
258
-		    //} else $formats[$id] = 'sbs';
259
-		    } else $globalSources[$id]['format'] = 'sbs';
260
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
256
+				//$formats[$id] = 'beast';
257
+				$globalSources[$id]['format'] = 'beast';
258
+			//} else $formats[$id] = 'sbs';
259
+			} else $globalSources[$id]['format'] = 'sbs';
260
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
261 261
 		}
262 262
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
263
-            } else {
263
+			} else {
264 264
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
265
-    	    }
266
-        }
267
-    }
265
+			}
266
+		}
267
+	}
268 268
 }
269 269
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
270 270
 
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 //connect_all($globalSources);
288 288
 
289 289
 if (isset($globalProxy) && $globalProxy) {
290
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
290
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
291 291
 } else {
292
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
292
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
293 293
 }
294 294
 
295 295
 // APRS Configuration
@@ -298,21 +298,21 @@  discard block
 block discarded – undo
298 298
 	die;
299 299
 }
300 300
 foreach ($globalSources as $key => $source) {
301
-    if (!isset($source['format'])) {
302
-        $globalSources[$key]['format'] = 'auto';
303
-    }
304
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
305
-        unset($globalSources[$key]);
306
-    }
301
+	if (!isset($source['format'])) {
302
+		$globalSources[$key]['format'] = 'auto';
303
+	}
304
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
305
+		unset($globalSources[$key]);
306
+	}
307 307
 }
308 308
 connect_all($globalSources);
309 309
 foreach ($globalSources as $key => $source) {
310
-    if (isset($source['format']) && $source['format'] == 'aprs') {
310
+	if (isset($source['format']) && $source['format'] == 'aprs') {
311 311
 	$aprs_connect = 0;
312 312
 	$use_aprs = true;
313 313
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
314 314
 	break;
315
-    }
315
+	}
316 316
 }
317 317
 
318 318
 if ($use_aprs) {
@@ -353,115 +353,115 @@  discard block
 block discarded – undo
353 353
 
354 354
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
355 355
 while ($i > 0) {
356
-    if (!$globalDaemon) $i = $endtime-time();
357
-    // Delete old ATC
358
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
356
+	if (!$globalDaemon) $i = $endtime-time();
357
+	// Delete old ATC
358
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
359 359
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
360
-        $ATC->deleteOldATC();
361
-    }
360
+		$ATC->deleteOldATC();
361
+	}
362 362
     
363
-    if (count($last_exec) == count($globalSources)) {
363
+	if (count($last_exec) == count($globalSources)) {
364 364
 	$max = $globalMinFetch;
365 365
 	foreach ($last_exec as $last) {
366
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
366
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
367 367
 	}
368 368
 	if ($max != $globalMinFetch) {
369
-	    if ($globalDebug) echo 'Sleeping...'."\n";
370
-	    sleep($globalMinFetch-$max+2);
369
+		if ($globalDebug) echo 'Sleeping...'."\n";
370
+		sleep($globalMinFetch-$max+2);
371
+	}
371 372
 	}
372
-    }
373 373
 
374 374
     
375
-    //foreach ($formats as $id => $value) {
376
-    foreach ($globalSources as $id => $value) {
375
+	//foreach ($formats as $id => $value) {
376
+	foreach ($globalSources as $id => $value) {
377 377
 	date_default_timezone_set('UTC');
378 378
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
379 379
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
380
-	    //$buffer = $Common->getData($hosts[$id]);
381
-	    $buffer = $Common->getData($value['host']);
382
-	    if ($buffer != '') $reset = 0;
383
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
384
-	    $buffer = explode('\n',$buffer);
385
-	    foreach ($buffer as $line) {
386
-    		if ($line != '' && count($line) > 7) {
387
-    		    $line = explode(',', $line);
388
-	            $data = array();
389
-	            $data['hex'] = $line[1]; // hex
390
-	            $data['ident'] = $line[2]; // ident
391
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
392
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
393
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
394
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
395
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
396
-	            $data['verticalrate'] = ''; // vertical rate
397
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
398
-	            $data['emergency'] = ''; // emergency
399
-		    $data['datetime'] = date('Y-m-d H:i:s');
400
-		    $data['format_source'] = 'deltadbtxt';
401
-    		    $data['id_source'] = $id_source;
402
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
403
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
404
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
405
-    		    $SI->add($data);
406
-		    unset($data);
407
-    		}
408
-    	    }
409
-    	    $last_exec[$id]['last'] = time();
380
+		//$buffer = $Common->getData($hosts[$id]);
381
+		$buffer = $Common->getData($value['host']);
382
+		if ($buffer != '') $reset = 0;
383
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
384
+		$buffer = explode('\n',$buffer);
385
+		foreach ($buffer as $line) {
386
+			if ($line != '' && count($line) > 7) {
387
+				$line = explode(',', $line);
388
+				$data = array();
389
+				$data['hex'] = $line[1]; // hex
390
+				$data['ident'] = $line[2]; // ident
391
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
392
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
393
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
394
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
395
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
396
+				$data['verticalrate'] = ''; // vertical rate
397
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
398
+				$data['emergency'] = ''; // emergency
399
+			$data['datetime'] = date('Y-m-d H:i:s');
400
+			$data['format_source'] = 'deltadbtxt';
401
+				$data['id_source'] = $id_source;
402
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
403
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
404
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
405
+				$SI->add($data);
406
+			unset($data);
407
+			}
408
+			}
409
+			$last_exec[$id]['last'] = time();
410 410
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
411
-	    date_default_timezone_set('CET');
412
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
413
-	    date_default_timezone_set('UTC');
414
-	    if ($buffer != '') $reset = 0;
415
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
416
-	    $buffer = explode('\n',$buffer);
417
-	    foreach ($buffer as $line) {
411
+		date_default_timezone_set('CET');
412
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
413
+		date_default_timezone_set('UTC');
414
+		if ($buffer != '') $reset = 0;
415
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
416
+		$buffer = explode('\n',$buffer);
417
+		foreach ($buffer as $line) {
418 418
 		if ($line != '') {
419
-		    //echo "'".$line."'\n";
420
-		    $add = false;
421
-		    $ais_data = $AIS->parse_line(trim($line));
422
-		    $data = array();
423
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
424
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
425
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
426
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
427
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
428
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
429
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
430
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
431
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
432
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
433
-		    if (isset($ais_data['timestamp'])) {
419
+			//echo "'".$line."'\n";
420
+			$add = false;
421
+			$ais_data = $AIS->parse_line(trim($line));
422
+			$data = array();
423
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
424
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
425
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
426
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
427
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
428
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
429
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
430
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
431
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
432
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
433
+			if (isset($ais_data['timestamp'])) {
434 434
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
435 435
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
436
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
437
-			    $add = true;
436
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
437
+				$add = true;
438 438
 			}
439
-		    } else {
439
+			} else {
440 440
 			$data['datetime'] = date('Y-m-d H:i:s');
441 441
 			$add = true;
442
-		    }
443
-		    $data['format_source'] = 'aisnmeatxt';
444
-    		    $data['id_source'] = $id_source;
445
-		    //print_r($data);
446
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
447
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
448
-		    unset($data);
442
+			}
443
+			$data['format_source'] = 'aisnmeatxt';
444
+				$data['id_source'] = $id_source;
445
+			//print_r($data);
446
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
447
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
448
+			unset($data);
449 449
 		}
450
-    	    }
451
-    	    $last_exec[$id]['last'] = time();
450
+			}
451
+			$last_exec[$id]['last'] = time();
452 452
 	} elseif ($value['format'] == 'aisnmeahttp') {
453
-	    $arr = $httpfeeds;
454
-	    $w = $e = null;
453
+		$arr = $httpfeeds;
454
+		$w = $e = null;
455 455
 	    
456
-	    if (isset($arr[$id])) {
456
+		if (isset($arr[$id])) {
457 457
 		$nn = stream_select($arr,$w,$e,$timeout);
458 458
 		if ($nn > 0) {
459
-		    foreach ($httpfeeds as $feed) {
459
+			foreach ($httpfeeds as $feed) {
460 460
 			$buffer = stream_get_line($feed,2000,"\n");
461 461
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
462 462
 			$buffer = explode('\n',$buffer);
463 463
 			foreach ($buffer as $line) {
464
-			    if ($line != '') {
464
+				if ($line != '') {
465 465
 				$ais_data = $AIS->parse_line(trim($line));
466 466
 				$data = array();
467 467
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -479,96 +479,96 @@  discard block
 block discarded – undo
479 479
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
480 480
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
481 481
 				if (isset($ais_data['timestamp'])) {
482
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
482
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
483 483
 				} else {
484
-				    $data['datetime'] = date('Y-m-d H:i:s');
484
+					$data['datetime'] = date('Y-m-d H:i:s');
485 485
 				}
486 486
 				$data['format_source'] = 'aisnmeahttp';
487 487
 				$data['id_source'] = $id_source;
488 488
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
489 489
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
490 490
 				unset($data);
491
-			    }
491
+				}
492
+			}
492 493
 			}
493
-		    }
494 494
 		} else {
495
-		    $format = $value['format'];
496
-		    if (isset($tt[$format])) $tt[$format]++;
497
-		    else $tt[$format] = 0;
498
-		    if ($tt[$format] > 30) {
495
+			$format = $value['format'];
496
+			if (isset($tt[$format])) $tt[$format]++;
497
+			else $tt[$format] = 0;
498
+			if ($tt[$format] > 30) {
499 499
 			if ($globalDebug) echo 'Reconnect...'."\n";
500 500
 			sleep(2);
501 501
 			$sourceeen[] = $value;
502 502
 			connect_all($sourceeen);
503 503
 			$sourceeen = array();
504
-		    }
504
+			}
505
+		}
505 506
 		}
506
-	    }
507 507
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
508
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
509
-	    if ($buffer != '') {
508
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
509
+		if ($buffer != '') {
510 510
 		//echo $buffer;
511 511
 		$all_data = json_decode($buffer,true);
512 512
 		//print_r($all_data);
513 513
 		if (isset($all_data[0]['DATA'])) {
514
-		    foreach ($all_data[0]['DATA'] as $line) {
514
+			foreach ($all_data[0]['DATA'] as $line) {
515 515
 			if ($line != '') {
516
-			    $data = array();
517
-			    $data['ident'] = $line['NAME'];
518
-			    $data['mmsi'] = $line['MMSI'];
519
-			    $data['speed'] = $line['SOG'];
520
-			    $data['heading'] = $line['COG'];
521
-			    $data['latitude'] = $line['LAT'];
522
-			    $data['longitude'] = $line['LNG'];
523
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
524
-			    $data['imo'] = $line['IMO'];
525
-			    //$data['arrival_code'] = $ais_data['destination'];
526
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
527
-			    $data['format_source'] = 'myshiptracking';
528
-			    $data['id_source'] = $id_source;
529
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
530
-			    $MI->add($data);
531
-			    unset($data);
516
+				$data = array();
517
+				$data['ident'] = $line['NAME'];
518
+				$data['mmsi'] = $line['MMSI'];
519
+				$data['speed'] = $line['SOG'];
520
+				$data['heading'] = $line['COG'];
521
+				$data['latitude'] = $line['LAT'];
522
+				$data['longitude'] = $line['LNG'];
523
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
524
+				$data['imo'] = $line['IMO'];
525
+				//$data['arrival_code'] = $ais_data['destination'];
526
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
527
+				$data['format_source'] = 'myshiptracking';
528
+				$data['id_source'] = $id_source;
529
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
530
+				$MI->add($data);
531
+				unset($data);
532
+			}
532 533
 			}
533
-		    }
534 534
 		}
535
-	    }
536
-	    $last_exec[$id]['last'] = time();
535
+		}
536
+		$last_exec[$id]['last'] = time();
537 537
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
538
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
539
-	    if ($buffer != '') {
538
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
539
+		if ($buffer != '') {
540 540
 		$all_data = json_decode($buffer,true);
541 541
 		if (isset($all_data[0]['mmsi'])) {
542
-		    foreach ($all_data as $line) {
542
+			foreach ($all_data as $line) {
543 543
 			if ($line != '') {
544
-			    $data = array();
545
-			    $data['ident'] = $line['shipname'];
546
-			    $data['callsign'] = $line['callsign'];
547
-			    $data['mmsi'] = $line['mmsi'];
548
-			    $data['speed'] = $line['sog'];
549
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
550
-			    $data['latitude'] = $line['latitude'];
551
-			    $data['longitude'] = $line['longitude'];
552
-			    $data['type_id'] = $line['shiptype'];
553
-			    $data['arrival_code'] = $line['destination'];
554
-			    $data['datetime'] = $line['time'];
555
-			    $data['format_source'] = 'boatbeaconapp';
556
-			    $data['id_source'] = $id_source;
557
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
558
-			    $MI->add($data);
559
-			    unset($data);
544
+				$data = array();
545
+				$data['ident'] = $line['shipname'];
546
+				$data['callsign'] = $line['callsign'];
547
+				$data['mmsi'] = $line['mmsi'];
548
+				$data['speed'] = $line['sog'];
549
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
550
+				$data['latitude'] = $line['latitude'];
551
+				$data['longitude'] = $line['longitude'];
552
+				$data['type_id'] = $line['shiptype'];
553
+				$data['arrival_code'] = $line['destination'];
554
+				$data['datetime'] = $line['time'];
555
+				$data['format_source'] = 'boatbeaconapp';
556
+				$data['id_source'] = $id_source;
557
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
558
+				$MI->add($data);
559
+				unset($data);
560
+			}
560 561
 			}
561
-		    }
562 562
 		}
563 563
 		
564
-	    }
565
-    	    $last_exec[$id]['last'] = time();
564
+		}
565
+			$last_exec[$id]['last'] = time();
566 566
 	} elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
567
-	    $buffer = $Common->getData($value['host']);
568
-	    if ($buffer != '') {
567
+		$buffer = $Common->getData($value['host']);
568
+		if ($buffer != '') {
569 569
 		$all_data = json_decode($buffer,true);
570 570
 		if (isset($all_data['features'][0]['id'])) {
571
-		    foreach ($all_data['features'] as $line) {
571
+			foreach ($all_data['features'] as $line) {
572 572
 			$data = array();
573 573
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
574 574
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
@@ -587,59 +587,59 @@  discard block
 block discarded – undo
587 587
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
588 588
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
589 589
 			unset($data);
590
-		    }
590
+			}
591 591
 		}
592 592
 		
593
-	    }
594
-    	    $last_exec[$id]['last'] = time();
593
+		}
594
+			$last_exec[$id]['last'] = time();
595 595
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
596
-	    echo 'download...';
597
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
598
-	    echo 'done !'."\n";
599
-	    if ($buffer != '') $reset = 0;
600
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
601
-	    $buffer = explode('\n',$buffer);
602
-	    foreach ($buffer as $line) {
596
+		echo 'download...';
597
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
598
+		echo 'done !'."\n";
599
+		if ($buffer != '') $reset = 0;
600
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
601
+		$buffer = explode('\n',$buffer);
602
+		foreach ($buffer as $line) {
603 603
 		if ($line != '') {
604
-		    $data = array();
605
-		    $data['mmsi'] = (int)substr($line,0,9);
606
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
607
-		    //$data['status'] = substr($line,21,2);
608
-		    //$data['type'] = substr($line,24,3);
609
-		    $data['latitude'] = substr($line,29,9);
610
-		    $data['longitude'] = substr($line,41,9);
611
-		    $data['speed'] = round(substr($line,51,5));
612
-		    //$data['course'] = substr($line,57,5);
613
-		    $data['heading'] = round(substr($line,63,3));
614
-		    //$data['draft'] = substr($line,67,4);
615
-		    //$data['length'] = substr($line,72,3);
616
-		    //$data['beam'] = substr($line,76,2);
617
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
618
-		    //$data['callsign'] = trim(substr($line,100,7);
619
-		    //$data['dest'] = substr($line,108,20);
620
-		    //$data['etaDate'] = substr($line,129,5);
621
-		    //$data['etaTime'] = substr($line,135,5);
622
-		    $data['format_source'] = 'shipplotter';
623
-    		    $data['id_source'] = $id_source;
624
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
625
-		    //print_r($data);
626
-		    echo 'Add...'."\n";
627
-		    $MI->add($data);
628
-		    unset($data);
604
+			$data = array();
605
+			$data['mmsi'] = (int)substr($line,0,9);
606
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
607
+			//$data['status'] = substr($line,21,2);
608
+			//$data['type'] = substr($line,24,3);
609
+			$data['latitude'] = substr($line,29,9);
610
+			$data['longitude'] = substr($line,41,9);
611
+			$data['speed'] = round(substr($line,51,5));
612
+			//$data['course'] = substr($line,57,5);
613
+			$data['heading'] = round(substr($line,63,3));
614
+			//$data['draft'] = substr($line,67,4);
615
+			//$data['length'] = substr($line,72,3);
616
+			//$data['beam'] = substr($line,76,2);
617
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
618
+			//$data['callsign'] = trim(substr($line,100,7);
619
+			//$data['dest'] = substr($line,108,20);
620
+			//$data['etaDate'] = substr($line,129,5);
621
+			//$data['etaTime'] = substr($line,135,5);
622
+			$data['format_source'] = 'shipplotter';
623
+				$data['id_source'] = $id_source;
624
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
625
+			//print_r($data);
626
+			echo 'Add...'."\n";
627
+			$MI->add($data);
628
+			unset($data);
629 629
 		}
630
-    	    }
631
-    	    $last_exec[$id]['last'] = time();
630
+			}
631
+			$last_exec[$id]['last'] = time();
632 632
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
633 633
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
634
-	    //$buffer = $Common->getData($hosts[$id]);
635
-	    $buffer = $Common->getData($value['host']);
636
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
637
-	    $buffer = explode('\n',$buffer);
638
-	    $reset = 0;
639
-	    foreach ($buffer as $line) {
640
-    		if ($line != '') {
641
-    		    $line = explode(':', $line);
642
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
634
+		//$buffer = $Common->getData($hosts[$id]);
635
+		$buffer = $Common->getData($value['host']);
636
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
637
+		$buffer = explode('\n',$buffer);
638
+		$reset = 0;
639
+		foreach ($buffer as $line) {
640
+			if ($line != '') {
641
+				$line = explode(':', $line);
642
+				if (count($line) > 30 && $line[0] != 'callsign') {
643 643
 			$data = array();
644 644
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
645 645
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -652,37 +652,37 @@  discard block
 block discarded – undo
652 652
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
653 653
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
654 654
 			$data['latitude'] = $line[5]; // lat
655
-	        	$data['longitude'] = $line[6]; // long
656
-	        	$data['verticalrate'] = ''; // vertical rate
657
-	        	$data['squawk'] = ''; // squawk
658
-	        	$data['emergency'] = ''; // emergency
659
-	        	$data['waypoints'] = $line[30];
655
+				$data['longitude'] = $line[6]; // long
656
+				$data['verticalrate'] = ''; // vertical rate
657
+				$data['squawk'] = ''; // squawk
658
+				$data['emergency'] = ''; // emergency
659
+				$data['waypoints'] = $line[30];
660 660
 			$data['datetime'] = date('Y-m-d H:i:s');
661 661
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
662 662
 			//if (isset($line[37])) $data['last_update'] = $line[37];
663
-		        $data['departure_airport_icao'] = $line[11];
664
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
665
-		        $data['arrival_airport_icao'] = $line[13];
663
+				$data['departure_airport_icao'] = $line[11];
664
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
665
+				$data['arrival_airport_icao'] = $line[13];
666 666
 			$data['frequency'] = $line[4];
667 667
 			$data['type'] = $line[18];
668 668
 			$data['range'] = $line[19];
669 669
 			if (isset($line[35])) $data['info'] = $line[35];
670
-    			$data['id_source'] = $id_source;
671
-	    		//$data['arrival_airport_time'] = ;
672
-	    		if ($line[9] != '') {
673
-	    		    $aircraft_data = explode('/',$line[9]);
674
-	    		    if (isset($aircraft_data[1])) {
675
-	    			$data['aircraft_icao'] = $aircraft_data[1];
676
-	    		    }
677
-        		}
678
-	    		/*
670
+				$data['id_source'] = $id_source;
671
+				//$data['arrival_airport_time'] = ;
672
+				if ($line[9] != '') {
673
+					$aircraft_data = explode('/',$line[9]);
674
+					if (isset($aircraft_data[1])) {
675
+					$data['aircraft_icao'] = $aircraft_data[1];
676
+					}
677
+				}
678
+				/*
679 679
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
680 680
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
681 681
 	    		*/
682
-	    		$data['format_source'] = $value['format'];
682
+				$data['format_source'] = $value['format'];
683 683
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
684 684
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
685
-    			if ($line[3] == 'PILOT') $SI->add($data);
685
+				if ($line[3] == 'PILOT') $SI->add($data);
686 686
 			elseif ($line[3] == 'ATC') {
687 687
 				//print_r($data);
688 688
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -703,16 +703,16 @@  discard block
 block discarded – undo
703 703
 					else 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'],$data['format_source'],$data['source_name']);
704 704
 				}
705 705
 			}
706
-    			unset($data);
707
-    		    }
708
-    		}
709
-    	    }
710
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
711
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
712
-    	    $last_exec[$id]['last'] = time();
713
-    	} elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
714
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
715
-	    if ($buffer != '') {
706
+				unset($data);
707
+				}
708
+			}
709
+			}
710
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
711
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
712
+			$last_exec[$id]['last'] = time();
713
+		} elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
714
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
715
+		if ($buffer != '') {
716 716
 		$all_data = simplexml_load_string($buffer);
717 717
 		foreach($all_data->children() as $childdata) {
718 718
 			$data = array();
@@ -734,10 +734,10 @@  discard block
 block discarded – undo
734 734
 			$SI->add($data);
735 735
 			unset($data);
736 736
 		}
737
-	    }
738
-	    $Source->deleteOldLocationByType('gs');
739
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
740
-	    if ($buffer != '') {
737
+		}
738
+		$Source->deleteOldLocationByType('gs');
739
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
740
+		if ($buffer != '') {
741 741
 		$all_data = simplexml_load_string($buffer);
742 742
 		foreach($all_data->children() as $childdata) {
743 743
 			$data = array();
@@ -755,249 +755,249 @@  discard block
 block discarded – undo
755 755
 			}
756 756
 			unset($data);
757 757
 		}
758
-	    }
759
-	    $last_exec[$id]['last'] = time();
758
+		}
759
+		$last_exec[$id]['last'] = time();
760 760
 	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
761
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
762
-	    if ($buffer != '') {
763
-	    $all_data = json_decode($buffer,true);
764
-	    if (isset($all_data['acList'])) {
761
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
762
+		if ($buffer != '') {
763
+		$all_data = json_decode($buffer,true);
764
+		if (isset($all_data['acList'])) {
765 765
 		$reset = 0;
766 766
 		foreach ($all_data['acList'] as $line) {
767
-		    $data = array();
768
-		    $data['hex'] = $line['Icao']; // hex
769
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
770
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
771
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
772
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
773
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
774
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
775
-		    //$data['verticalrate'] = $line['']; // verticale rate
776
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
777
-		    $data['emergency'] = ''; // emergency
778
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
767
+			$data = array();
768
+			$data['hex'] = $line['Icao']; // hex
769
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
770
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
771
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
772
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
773
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
774
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
775
+			//$data['verticalrate'] = $line['']; // verticale rate
776
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
777
+			$data['emergency'] = ''; // emergency
778
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
779 779
 		    
780
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
781
-		    else $data['datetime'] = date('Y-m-d H:i:s');
780
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
781
+			else $data['datetime'] = date('Y-m-d H:i:s');
782 782
 		    
783
-		    //$data['datetime'] = date('Y-m-d H:i:s');
784
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
785
-	    	    $data['format_source'] = 'aircraftlistjson';
786
-		    $data['id_source'] = $id_source;
787
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
788
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
789
-		    if (isset($data['latitude'])) $SI->add($data);
790
-		    unset($data);
783
+			//$data['datetime'] = date('Y-m-d H:i:s');
784
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
785
+				$data['format_source'] = 'aircraftlistjson';
786
+			$data['id_source'] = $id_source;
787
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
788
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
789
+			if (isset($data['latitude'])) $SI->add($data);
790
+			unset($data);
791 791
 		}
792
-	    } elseif (is_array($all_data)) {
792
+		} elseif (is_array($all_data)) {
793 793
 		$reset = 0;
794 794
 		foreach ($all_data as $line) {
795
-		    $data = array();
796
-		    $data['hex'] = $line['hex']; // hex
797
-		    $data['ident'] = $line['flight']; // ident
798
-		    $data['altitude'] = $line['altitude']; // altitude
799
-		    $data['speed'] = $line['speed']; // speed
800
-		    $data['heading'] = $line['track']; // heading
801
-		    $data['latitude'] = $line['lat']; // lat
802
-		    $data['longitude'] = $line['lon']; // long
803
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
804
-		    $data['squawk'] = $line['squawk']; // squawk
805
-		    $data['emergency'] = ''; // emergency
806
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
807
-		    else $data['datetime'] = date('Y-m-d H:i:s');
808
-	    	    $data['format_source'] = 'aircraftlistjson';
809
-    		    $data['id_source'] = $id_source;
810
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
811
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
812
-		    $SI->add($data);
813
-		    unset($data);
795
+			$data = array();
796
+			$data['hex'] = $line['hex']; // hex
797
+			$data['ident'] = $line['flight']; // ident
798
+			$data['altitude'] = $line['altitude']; // altitude
799
+			$data['speed'] = $line['speed']; // speed
800
+			$data['heading'] = $line['track']; // heading
801
+			$data['latitude'] = $line['lat']; // lat
802
+			$data['longitude'] = $line['lon']; // long
803
+			$data['verticalrate'] = $line['vrt']; // verticale rate
804
+			$data['squawk'] = $line['squawk']; // squawk
805
+			$data['emergency'] = ''; // emergency
806
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
807
+			else $data['datetime'] = date('Y-m-d H:i:s');
808
+				$data['format_source'] = 'aircraftlistjson';
809
+				$data['id_source'] = $id_source;
810
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
811
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
812
+			$SI->add($data);
813
+			unset($data);
814
+		}
814 815
 		}
815
-	    }
816
-	    }
817
-    	    //$last_exec['aircraftlistjson'] = time();
818
-    	    $last_exec[$id]['last'] = time();
819
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
820
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
821
-	    $buffer = $Common->getData($value['host']);
822
-	    $all_data = json_decode($buffer,true);
823
-	    if (isset($all_data['planes'])) {
816
+		}
817
+			//$last_exec['aircraftlistjson'] = time();
818
+			$last_exec[$id]['last'] = time();
819
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
820
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
821
+		$buffer = $Common->getData($value['host']);
822
+		$all_data = json_decode($buffer,true);
823
+		if (isset($all_data['planes'])) {
824 824
 		$reset = 0;
825 825
 		foreach ($all_data['planes'] as $key => $line) {
826
-		    $data = array();
827
-		    $data['hex'] = $key; // hex
828
-		    $data['ident'] = $line[3]; // ident
829
-		    $data['altitude'] = $line[6]; // altitude
830
-		    $data['speed'] = $line[8]; // speed
831
-		    $data['heading'] = $line[7]; // heading
832
-		    $data['latitude'] = $line[4]; // lat
833
-		    $data['longitude'] = $line[5]; // long
834
-		    //$data['verticalrate'] = $line[]; // verticale rate
835
-		    $data['squawk'] = $line[10]; // squawk
836
-		    $data['emergency'] = ''; // emergency
837
-		    $data['registration'] = $line[2];
838
-		    $data['aircraft_icao'] = $line[0];
839
-		    $deparr = explode('-',$line[1]);
840
-		    if (count($deparr) == 2) {
826
+			$data = array();
827
+			$data['hex'] = $key; // hex
828
+			$data['ident'] = $line[3]; // ident
829
+			$data['altitude'] = $line[6]; // altitude
830
+			$data['speed'] = $line[8]; // speed
831
+			$data['heading'] = $line[7]; // heading
832
+			$data['latitude'] = $line[4]; // lat
833
+			$data['longitude'] = $line[5]; // long
834
+			//$data['verticalrate'] = $line[]; // verticale rate
835
+			$data['squawk'] = $line[10]; // squawk
836
+			$data['emergency'] = ''; // emergency
837
+			$data['registration'] = $line[2];
838
+			$data['aircraft_icao'] = $line[0];
839
+			$deparr = explode('-',$line[1]);
840
+			if (count($deparr) == 2) {
841 841
 			$data['departure_airport_icao'] = $deparr[0];
842 842
 			$data['arrival_airport_icao'] = $deparr[1];
843
-		    }
844
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
845
-	    	    $data['format_source'] = 'planeupdatefaa';
846
-    		    $data['id_source'] = $id_source;
847
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
848
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
849
-		    $SI->add($data);
850
-		    unset($data);
843
+			}
844
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
845
+				$data['format_source'] = 'planeupdatefaa';
846
+				$data['id_source'] = $id_source;
847
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
848
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
849
+			$SI->add($data);
850
+			unset($data);
851 851
 		}
852
-	    }
853
-    	    //$last_exec['planeupdatefaa'] = time();
854
-    	    $last_exec[$id]['last'] = time();
855
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
856
-	    $buffer = $Common->getData($value['host']);
857
-	    $all_data = json_decode($buffer,true);
858
-	    if (isset($all_data['states'])) {
852
+		}
853
+			//$last_exec['planeupdatefaa'] = time();
854
+			$last_exec[$id]['last'] = time();
855
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
856
+		$buffer = $Common->getData($value['host']);
857
+		$all_data = json_decode($buffer,true);
858
+		if (isset($all_data['states'])) {
859 859
 		$reset = 0;
860 860
 		foreach ($all_data['states'] as $key => $line) {
861
-		    $data = array();
862
-		    $data['hex'] = $line[0]; // hex
863
-		    $data['ident'] = trim($line[1]); // ident
864
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
865
-		    $data['speed'] = round($line[9]*1.94384); // speed
866
-		    $data['heading'] = round($line[10]); // heading
867
-		    $data['latitude'] = $line[6]; // lat
868
-		    $data['longitude'] = $line[5]; // long
869
-		    $data['verticalrate'] = $line[11]; // verticale rate
870
-		    //$data['squawk'] = $line[10]; // squawk
871
-		    //$data['emergency'] = ''; // emergency
872
-		    //$data['registration'] = $line[2];
873
-		    //$data['aircraft_icao'] = $line[0];
874
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
875
-	    	    $data['format_source'] = 'opensky';
876
-    		    $data['id_source'] = $id_source;
877
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
878
-		    $SI->add($data);
879
-		    unset($data);
861
+			$data = array();
862
+			$data['hex'] = $line[0]; // hex
863
+			$data['ident'] = trim($line[1]); // ident
864
+			$data['altitude'] = round($line[7]*3.28084); // altitude
865
+			$data['speed'] = round($line[9]*1.94384); // speed
866
+			$data['heading'] = round($line[10]); // heading
867
+			$data['latitude'] = $line[6]; // lat
868
+			$data['longitude'] = $line[5]; // long
869
+			$data['verticalrate'] = $line[11]; // verticale rate
870
+			//$data['squawk'] = $line[10]; // squawk
871
+			//$data['emergency'] = ''; // emergency
872
+			//$data['registration'] = $line[2];
873
+			//$data['aircraft_icao'] = $line[0];
874
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
875
+				$data['format_source'] = 'opensky';
876
+				$data['id_source'] = $id_source;
877
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
878
+			$SI->add($data);
879
+			unset($data);
880
+		}
880 881
 		}
881
-	    }
882
-    	    //$last_exec['planeupdatefaa'] = time();
883
-    	    $last_exec[$id]['last'] = time();
884
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
885
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
886
-	    //$buffer = $Common->getData($hosts[$id]);
887
-	    $buffer = $Common->getData($value['host']);
888
-	    $all_data = json_decode($buffer,true);
889
-	    if (!empty($all_data)) $reset = 0;
890
-	    foreach ($all_data as $key => $line) {
882
+			//$last_exec['planeupdatefaa'] = time();
883
+			$last_exec[$id]['last'] = time();
884
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
885
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
886
+		//$buffer = $Common->getData($hosts[$id]);
887
+		$buffer = $Common->getData($value['host']);
888
+		$all_data = json_decode($buffer,true);
889
+		if (!empty($all_data)) $reset = 0;
890
+		foreach ($all_data as $key => $line) {
891 891
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
892
-		    $data = array();
893
-		    $data['hex'] = $line[0];
894
-		    $data['ident'] = $line[16]; //$line[13]
895
-	    	    $data['altitude'] = $line[4]; // altitude
896
-	    	    $data['speed'] = $line[5]; // speed
897
-	    	    $data['heading'] = $line[3]; // heading
898
-	    	    $data['latitude'] = $line[1]; // lat
899
-	    	    $data['longitude'] = $line[2]; // long
900
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
901
-	    	    $data['squawk'] = $line[6]; // squawk
902
-	    	    $data['aircraft_icao'] = $line[8];
903
-	    	    $data['registration'] = $line[9];
904
-		    $data['departure_airport_iata'] = $line[11];
905
-		    $data['arrival_airport_iata'] = $line[12];
906
-	    	    $data['emergency'] = ''; // emergency
907
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
908
-	    	    $data['format_source'] = 'fr24json';
909
-    		    $data['id_source'] = $id_source;
910
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
911
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
912
-		    $SI->add($data);
913
-		    unset($data);
892
+			$data = array();
893
+			$data['hex'] = $line[0];
894
+			$data['ident'] = $line[16]; //$line[13]
895
+				$data['altitude'] = $line[4]; // altitude
896
+				$data['speed'] = $line[5]; // speed
897
+				$data['heading'] = $line[3]; // heading
898
+				$data['latitude'] = $line[1]; // lat
899
+				$data['longitude'] = $line[2]; // long
900
+				$data['verticalrate'] = $line[15]; // verticale rate
901
+				$data['squawk'] = $line[6]; // squawk
902
+				$data['aircraft_icao'] = $line[8];
903
+				$data['registration'] = $line[9];
904
+			$data['departure_airport_iata'] = $line[11];
905
+			$data['arrival_airport_iata'] = $line[12];
906
+				$data['emergency'] = ''; // emergency
907
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
908
+				$data['format_source'] = 'fr24json';
909
+				$data['id_source'] = $id_source;
910
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
911
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
912
+			$SI->add($data);
913
+			unset($data);
914 914
 		}
915
-	    }
916
-    	    //$last_exec['fr24json'] = time();
917
-    	    $last_exec[$id]['last'] = time();
918
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
919
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
920
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
921
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
922
-	    //echo $buffer;
923
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
924
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
925
-	    $all_data = json_decode($buffer,true);
926
-	    if (json_last_error() != JSON_ERROR_NONE) {
915
+		}
916
+			//$last_exec['fr24json'] = time();
917
+			$last_exec[$id]['last'] = time();
918
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
919
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
920
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
921
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
922
+		//echo $buffer;
923
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
924
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
925
+		$all_data = json_decode($buffer,true);
926
+		if (json_last_error() != JSON_ERROR_NONE) {
927 927
 		die(json_last_error_msg());
928
-	    }
929
-	    if (isset($all_data['mrkrs'])) {
928
+		}
929
+		if (isset($all_data['mrkrs'])) {
930 930
 		$reset = 0;
931 931
 		foreach ($all_data['mrkrs'] as $key => $line) {
932
-		    if (isset($line['inf'])) {
932
+			if (isset($line['inf'])) {
933 933
 			$data = array();
934 934
 			$data['hex'] = $line['inf']['ia'];
935 935
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
936
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
937
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
938
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
939
-	    		$data['latitude'] = $line['pt'][0]; // lat
940
-	    		$data['longitude'] = $line['pt'][1]; // long
941
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
942
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
943
-	    		//$data['aircraft_icao'] = $line[8];
944
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
936
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
937
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
938
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
939
+				$data['latitude'] = $line['pt'][0]; // lat
940
+				$data['longitude'] = $line['pt'][1]; // long
941
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
942
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
943
+				//$data['aircraft_icao'] = $line[8];
944
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
945 945
 			//$data['departure_airport_iata'] = $line[11];
946 946
 			//$data['arrival_airport_iata'] = $line[12];
947
-	    		//$data['emergency'] = ''; // emergency
947
+				//$data['emergency'] = ''; // emergency
948 948
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
949
-	    		$data['format_source'] = 'radarvirtueljson';
950
-    			$data['id_source'] = $id_source;
949
+				$data['format_source'] = 'radarvirtueljson';
950
+				$data['id_source'] = $id_source;
951 951
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
952 952
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
953 953
 			$SI->add($data);
954 954
 			unset($data);
955
-		    }
955
+			}
956
+		}
956 957
 		}
957
-	    }
958
-    	    //$last_exec['radarvirtueljson'] = time();
959
-    	    $last_exec[$id]['last'] = time();
960
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
961
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
962
-	    //$buffer = $Common->getData($hosts[$id]);
963
-	    $buffer = $Common->getData($value['host'].'?'.time());
964
-	    $all_data = json_decode(utf8_encode($buffer),true);
958
+			//$last_exec['radarvirtueljson'] = time();
959
+			$last_exec[$id]['last'] = time();
960
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
961
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
962
+		//$buffer = $Common->getData($hosts[$id]);
963
+		$buffer = $Common->getData($value['host'].'?'.time());
964
+		$all_data = json_decode(utf8_encode($buffer),true);
965 965
 	    
966
-	    if (isset($all_data['pireps'])) {
966
+		if (isset($all_data['pireps'])) {
967 967
 		$reset = 0;
968
-	        foreach ($all_data['pireps'] as $line) {
969
-		    $data = array();
970
-		    $data['id'] = $line['id'];
971
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
972
-		    $data['ident'] = $line['callsign']; // ident
973
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
974
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
975
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
976
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
977
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
978
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
979
-		    $data['latitude'] = $line['lat']; // lat
980
-		    $data['longitude'] = $line['lon']; // long
981
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
982
-		    //$data['squawk'] = $line['squawk']; // squawk
983
-		    //$data['emergency'] = ''; // emergency
984
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
985
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
986
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
987
-		    //$data['arrival_airport_time'] = $line['arrtime'];
988
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
989
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
990
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
991
-		    else $data['info'] = '';
992
-		    $data['format_source'] = 'pireps';
993
-    		    $data['id_source'] = $id_source;
994
-		    $data['datetime'] = date('Y-m-d H:i:s');
995
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
996
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
997
-		    if ($line['icon'] == 'plane') {
968
+			foreach ($all_data['pireps'] as $line) {
969
+			$data = array();
970
+			$data['id'] = $line['id'];
971
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
972
+			$data['ident'] = $line['callsign']; // ident
973
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
974
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
975
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
976
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
977
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
978
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
979
+			$data['latitude'] = $line['lat']; // lat
980
+			$data['longitude'] = $line['lon']; // long
981
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
982
+			//$data['squawk'] = $line['squawk']; // squawk
983
+			//$data['emergency'] = ''; // emergency
984
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
985
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
986
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
987
+			//$data['arrival_airport_time'] = $line['arrtime'];
988
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
989
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
990
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
991
+			else $data['info'] = '';
992
+			$data['format_source'] = 'pireps';
993
+				$data['id_source'] = $id_source;
994
+			$data['datetime'] = date('Y-m-d H:i:s');
995
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
996
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
997
+			if ($line['icon'] == 'plane') {
998 998
 			$SI->add($data);
999
-		    //    print_r($data);
1000
-    		    } elseif ($line['icon'] == 'ct') {
999
+			//    print_r($data);
1000
+				} elseif ($line['icon'] == 'ct') {
1001 1001
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1002 1002
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1003 1003
 			$typec = substr($data['ident'],-3);
@@ -1012,203 +1012,203 @@  discard block
 block discarded – undo
1012 1012
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1013 1013
 			else $data['type'] = 'Observer';
1014 1014
 			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1015
-		    }
1016
-		    unset($data);
1015
+			}
1016
+			unset($data);
1017
+		}
1017 1018
 		}
1018
-	    }
1019
-    	    //$last_exec['pirepsjson'] = time();
1020
-    	    $last_exec[$id]['last'] = time();
1021
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1022
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1023
-	    //$buffer = $Common->getData($hosts[$id]);
1024
-	    if ($globalDebug) echo 'Get Data...'."\n";
1025
-	    $buffer = $Common->getData($value['host']);
1026
-	    $all_data = json_decode($buffer,true);
1027
-	    if ($buffer != '' && is_array($all_data)) {
1019
+			//$last_exec['pirepsjson'] = time();
1020
+			$last_exec[$id]['last'] = time();
1021
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1022
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1023
+		//$buffer = $Common->getData($hosts[$id]);
1024
+		if ($globalDebug) echo 'Get Data...'."\n";
1025
+		$buffer = $Common->getData($value['host']);
1026
+		$all_data = json_decode($buffer,true);
1027
+		if ($buffer != '' && is_array($all_data)) {
1028 1028
 		$reset = 0;
1029 1029
 		foreach ($all_data as $line) {
1030
-	    	    $data = array();
1031
-	    	    //$data['id'] = $line['id']; // id not usable
1032
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1033
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1034
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1035
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1036
-	    	    $data['ident'] = $line['flightnum']; // ident
1037
-	    	    $data['altitude'] = $line['alt']; // altitude
1038
-	    	    $data['speed'] = $line['gs']; // speed
1039
-	    	    $data['heading'] = $line['heading']; // heading
1040
-	    	    $data['latitude'] = $line['lat']; // lat
1041
-	    	    $data['longitude'] = $line['lng']; // long
1042
-	    	    $data['verticalrate'] = ''; // verticale rate
1043
-	    	    $data['squawk'] = ''; // squawk
1044
-	    	    $data['emergency'] = ''; // emergency
1045
-	    	    //$data['datetime'] = $line['lastupdate'];
1046
-	    	    //$data['last_update'] = $line['lastupdate'];
1047
-	    	    if (isset($value['timezone'])) {
1048
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1049
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1050
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1051
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1052
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1053
-	    	    $data['departure_airport_time'] = $line['deptime'];
1054
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1055
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1056
-    		    $data['registration'] = $line['aircraft'];
1057
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1058
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1059
-		    if (isset($line['aircraftname'])) {
1030
+				$data = array();
1031
+				//$data['id'] = $line['id']; // id not usable
1032
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1033
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1034
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1035
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1036
+				$data['ident'] = $line['flightnum']; // ident
1037
+				$data['altitude'] = $line['alt']; // altitude
1038
+				$data['speed'] = $line['gs']; // speed
1039
+				$data['heading'] = $line['heading']; // heading
1040
+				$data['latitude'] = $line['lat']; // lat
1041
+				$data['longitude'] = $line['lng']; // long
1042
+				$data['verticalrate'] = ''; // verticale rate
1043
+				$data['squawk'] = ''; // squawk
1044
+				$data['emergency'] = ''; // emergency
1045
+				//$data['datetime'] = $line['lastupdate'];
1046
+				//$data['last_update'] = $line['lastupdate'];
1047
+				if (isset($value['timezone'])) {
1048
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1049
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1050
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1051
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1052
+				$data['departure_airport_icao'] = $line['depicao'];
1053
+				$data['departure_airport_time'] = $line['deptime'];
1054
+				$data['arrival_airport_icao'] = $line['arricao'];
1055
+				$data['arrival_airport_time'] = $line['arrtime'];
1056
+				$data['registration'] = $line['aircraft'];
1057
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1058
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1059
+			if (isset($line['aircraftname'])) {
1060 1060
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1061 1061
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1062
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1063
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1064
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1065
-	    		else {
1066
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1067
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1068
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1069
-	    		}
1070
-	    	    }
1071
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1072
-    		    $data['id_source'] = $id_source;
1073
-	    	    $data['format_source'] = 'phpvmacars';
1074
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1075
-		    $SI->add($data);
1076
-		    unset($data);
1062
+				$aircraft_data = explode('-',$line['aircraftname']);
1063
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1064
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1065
+				else {
1066
+					$aircraft_data = explode(' ',$line['aircraftname']);
1067
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1068
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1069
+				}
1070
+				}
1071
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1072
+				$data['id_source'] = $id_source;
1073
+				$data['format_source'] = 'phpvmacars';
1074
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1075
+			$SI->add($data);
1076
+			unset($data);
1077 1077
 		}
1078 1078
 		if ($globalDebug) echo 'No more data...'."\n";
1079 1079
 		unset($buffer);
1080 1080
 		unset($all_data);
1081
-	    }
1082
-    	    //$last_exec['phpvmacars'] = time();
1083
-    	    $last_exec[$id]['last'] = time();
1084
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1085
-	    //$buffer = $Common->getData($hosts[$id]);
1086
-	    if ($globalDebug) echo 'Get Data...'."\n";
1087
-	    $buffer = $Common->getData($value['host']);
1088
-	    $all_data = json_decode($buffer,true);
1089
-	    if ($buffer != '' && is_array($all_data)) {
1081
+		}
1082
+			//$last_exec['phpvmacars'] = time();
1083
+			$last_exec[$id]['last'] = time();
1084
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1085
+		//$buffer = $Common->getData($hosts[$id]);
1086
+		if ($globalDebug) echo 'Get Data...'."\n";
1087
+		$buffer = $Common->getData($value['host']);
1088
+		$all_data = json_decode($buffer,true);
1089
+		if ($buffer != '' && is_array($all_data)) {
1090 1090
 		$reset = 0;
1091 1091
 		foreach ($all_data as $line) {
1092
-	    	    $data = array();
1093
-	    	    //$data['id'] = $line['id']; // id not usable
1094
-	    	    $data['id'] = trim($line['flight_id']);
1095
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1096
-	    	    $data['pilot_name'] = $line['pilot_name'];
1097
-	    	    $data['pilot_id'] = $line['pilot_id'];
1098
-	    	    $data['ident'] = trim($line['callsign']); // ident
1099
-	    	    $data['altitude'] = $line['altitude']; // altitude
1100
-	    	    $data['speed'] = $line['gs']; // speed
1101
-	    	    $data['heading'] = $line['heading']; // heading
1102
-	    	    $data['latitude'] = $line['latitude']; // lat
1103
-	    	    $data['longitude'] = $line['longitude']; // long
1104
-	    	    $data['verticalrate'] = ''; // verticale rate
1105
-	    	    $data['squawk'] = ''; // squawk
1106
-	    	    $data['emergency'] = ''; // emergency
1107
-	    	    //$data['datetime'] = $line['lastupdate'];
1108
-	    	    $data['last_update'] = $line['last_update'];
1109
-		    $data['datetime'] = date('Y-m-d H:i:s');
1110
-	    	    $data['departure_airport_icao'] = $line['departure'];
1111
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1112
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1113
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1114
-    		    //$data['registration'] = $line['aircraft'];
1115
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1116
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1117
-    		    $data['id_source'] = $id_source;
1118
-	    	    $data['format_source'] = 'vam';
1119
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1120
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1121
-		    $SI->add($data);
1122
-		    unset($data);
1092
+				$data = array();
1093
+				//$data['id'] = $line['id']; // id not usable
1094
+				$data['id'] = trim($line['flight_id']);
1095
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1096
+				$data['pilot_name'] = $line['pilot_name'];
1097
+				$data['pilot_id'] = $line['pilot_id'];
1098
+				$data['ident'] = trim($line['callsign']); // ident
1099
+				$data['altitude'] = $line['altitude']; // altitude
1100
+				$data['speed'] = $line['gs']; // speed
1101
+				$data['heading'] = $line['heading']; // heading
1102
+				$data['latitude'] = $line['latitude']; // lat
1103
+				$data['longitude'] = $line['longitude']; // long
1104
+				$data['verticalrate'] = ''; // verticale rate
1105
+				$data['squawk'] = ''; // squawk
1106
+				$data['emergency'] = ''; // emergency
1107
+				//$data['datetime'] = $line['lastupdate'];
1108
+				$data['last_update'] = $line['last_update'];
1109
+			$data['datetime'] = date('Y-m-d H:i:s');
1110
+				$data['departure_airport_icao'] = $line['departure'];
1111
+				//$data['departure_airport_time'] = $line['departure_time'];
1112
+				$data['arrival_airport_icao'] = $line['arrival'];
1113
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1114
+				//$data['registration'] = $line['aircraft'];
1115
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1116
+				$data['aircraft_icao'] = $line['plane_type'];
1117
+				$data['id_source'] = $id_source;
1118
+				$data['format_source'] = 'vam';
1119
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1120
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1121
+			$SI->add($data);
1122
+			unset($data);
1123 1123
 		}
1124 1124
 		if ($globalDebug) echo 'No more data...'."\n";
1125 1125
 		unset($buffer);
1126 1126
 		unset($all_data);
1127
-	    }
1128
-    	    //$last_exec['phpvmacars'] = time();
1129
-    	    $last_exec[$id]['last'] = time();
1127
+		}
1128
+			//$last_exec['phpvmacars'] = time();
1129
+			$last_exec[$id]['last'] = time();
1130 1130
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1131 1131
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1132
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1133
-    	    //$last_exec[$id]['last'] = time();
1132
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1133
+			//$last_exec[$id]['last'] = time();
1134 1134
 
1135
-	    //$read = array( $sockets[$id] );
1136
-	    $read = $sockets;
1137
-	    $write = NULL;
1138
-	    $e = NULL;
1139
-	    $n = socket_select($read, $write, $e, $timeout);
1140
-	    if ($e != NULL) var_dump($e);
1141
-	    if ($n > 0) {
1135
+		//$read = array( $sockets[$id] );
1136
+		$read = $sockets;
1137
+		$write = NULL;
1138
+		$e = NULL;
1139
+		$n = socket_select($read, $write, $e, $timeout);
1140
+		if ($e != NULL) var_dump($e);
1141
+		if ($n > 0) {
1142 1142
 		$reset = 0;
1143 1143
 		foreach ($read as $nb => $r) {
1144
-		    //$value = $formats[$nb];
1145
-		    $format = $globalSources[$nb]['format'];
1146
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1144
+			//$value = $formats[$nb];
1145
+			$format = $globalSources[$nb]['format'];
1146
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1147 1147
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1148
-		    } elseif ($format == 'vrstcp') {
1148
+			} elseif ($format == 'vrstcp') {
1149 1149
 			$buffer = @socket_read($r, 6000);
1150
-		    } else {
1150
+			} else {
1151 1151
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1152
-		    }
1153
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1154
-		    //echo $buffer."\n";
1155
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1156
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1157
-		    $error = false;
1158
-		    //$SI::del();
1159
-		    if ($format == 'vrstcp') {
1152
+			}
1153
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1154
+			//echo $buffer."\n";
1155
+			// lets play nice and handle signals such as ctrl-c/kill properly
1156
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1157
+			$error = false;
1158
+			//$SI::del();
1159
+			if ($format == 'vrstcp') {
1160 1160
 			$buffer = explode('},{',$buffer);
1161
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1162
-		    // SBS format is CSV format
1163
-		    if ($buffer !== FALSE && $buffer != '') {
1161
+			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1162
+			// SBS format is CSV format
1163
+			if ($buffer !== FALSE && $buffer != '') {
1164 1164
 			$tt[$format] = 0;
1165 1165
 			if ($format == 'acarssbs3') {
1166
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1167
-			    $ACARS->add(trim($buffer));
1168
-			    $ACARS->deleteLiveAcarsData();
1166
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1167
+				$ACARS->add(trim($buffer));
1168
+				$ACARS->deleteLiveAcarsData();
1169 1169
 			} elseif ($format == 'raw') {
1170
-			    // AVR format
1171
-			    $data = $SBS->parse($buffer);
1172
-			    if (is_array($data)) {
1170
+				// AVR format
1171
+				$data = $SBS->parse($buffer);
1172
+				if (is_array($data)) {
1173 1173
 				$data['datetime'] = date('Y-m-d H:i:s');
1174 1174
 				$data['format_source'] = 'raw';
1175 1175
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1176 1176
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1177 1177
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1178 1178
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1179
-			    }
1179
+				}
1180 1180
 			} elseif ($format == 'ais') {
1181
-			    $ais_data = $AIS->parse_line(trim($buffer));
1182
-			    $data = array();
1183
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1184
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1185
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1186
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1187
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1188
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1189
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1190
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1191
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1192
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1193
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1194
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1195
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1196
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1197
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1198
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1181
+				$ais_data = $AIS->parse_line(trim($buffer));
1182
+				$data = array();
1183
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1184
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1185
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1186
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1187
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1188
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1189
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1190
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1191
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1192
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1193
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1194
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1195
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1196
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1197
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1198
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1199 1199
 
1200
-			    if (isset($ais_data['timestamp'])) {
1200
+				if (isset($ais_data['timestamp'])) {
1201 1201
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1202
-			    } else {
1202
+				} else {
1203 1203
 				$data['datetime'] = date('Y-m-d H:i:s');
1204
-			    }
1205
-			    $data['format_source'] = 'aisnmea';
1206
-    			    $data['id_source'] = $id_source;
1207
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1208
-			    unset($data);
1209
-                        } elseif ($format == 'flightgearsp') {
1210
-                    	    //echo $buffer."\n";
1211
-                    	    if (strlen($buffer) > 5) {
1204
+				}
1205
+				$data['format_source'] = 'aisnmea';
1206
+					$data['id_source'] = $id_source;
1207
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1208
+				unset($data);
1209
+						} elseif ($format == 'flightgearsp') {
1210
+							//echo $buffer."\n";
1211
+							if (strlen($buffer) > 5) {
1212 1212
 				$line = explode(',',$buffer);
1213 1213
 				$data = array();
1214 1214
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1225,38 +1225,38 @@  discard block
 block discarded – undo
1225 1225
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1226 1226
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1227 1227
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1228
-			    }
1229
-                        } elseif ($format == 'acars') {
1230
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1231
-			    $ACARS->add(trim($buffer));
1232
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1233
-			    $ACARS->deleteLiveAcarsData();
1228
+				}
1229
+						} elseif ($format == 'acars') {
1230
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1231
+				$ACARS->add(trim($buffer));
1232
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1233
+				$ACARS->deleteLiveAcarsData();
1234 1234
 			} elseif ($format == 'flightgearmp') {
1235
-			    if (substr($buffer,0,1) != '#') {
1235
+				if (substr($buffer,0,1) != '#') {
1236 1236
 				$data = array();
1237 1237
 				//echo $buffer."\n";
1238 1238
 				$line = explode(' ',$buffer);
1239 1239
 				if (count($line) == 11) {
1240
-				    $userserver = explode('@',$line[0]);
1241
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1242
-				    $data['ident'] = $userserver[0];
1243
-				    $data['registration'] = $userserver[0];
1244
-				    $data['latitude'] = $line[4];
1245
-				    $data['longitude'] = $line[5];
1246
-				    $data['altitude'] = $line[6];
1247
-				    $data['datetime'] = date('Y-m-d H:i:s');
1248
-				    $aircraft_type = $line[10];
1249
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1250
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1251
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1252
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1240
+					$userserver = explode('@',$line[0]);
1241
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1242
+					$data['ident'] = $userserver[0];
1243
+					$data['registration'] = $userserver[0];
1244
+					$data['latitude'] = $line[4];
1245
+					$data['longitude'] = $line[5];
1246
+					$data['altitude'] = $line[6];
1247
+					$data['datetime'] = date('Y-m-d H:i:s');
1248
+					$aircraft_type = $line[10];
1249
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1250
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1251
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1252
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1253
+				}
1253 1254
 				}
1254
-			    }
1255 1255
 			} elseif ($format == 'beast') {
1256
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1257
-			    die;
1256
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1257
+				die;
1258 1258
 			} elseif ($format == 'vrstcp') {
1259
-			    foreach($buffer as $all_data) {
1259
+				foreach($buffer as $all_data) {
1260 1260
 				$line = json_decode('{'.$all_data.'}',true);
1261 1261
 				$data = array();
1262 1262
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1276,148 +1276,148 @@  discard block
 block discarded – undo
1276 1276
 				*/
1277 1277
 				$data['datetime'] = date('Y-m-d H:i:s');
1278 1278
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1279
-		    		$data['format_source'] = 'vrstcp';
1279
+					$data['format_source'] = 'vrstcp';
1280 1280
 				$data['id_source'] = $id_source;
1281 1281
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1282 1282
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1283 1283
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1284 1284
 				unset($data);
1285
-			    }
1285
+				}
1286 1286
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1287
-			    $line = explode("\t", $buffer);
1288
-			    for($k = 0; $k < count($line); $k=$k+2) {
1287
+				$line = explode("\t", $buffer);
1288
+				for($k = 0; $k < count($line); $k=$k+2) {
1289 1289
 				$key = $line[$k];
1290
-			        $lined[$key] = $line[$k+1];
1291
-			    }
1292
-    			    if (count($lined) > 3) {
1293
-    				$data['hex'] = $lined['hexid'];
1294
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1295
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1296
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1297
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1298
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1299
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1300
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1301
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1302
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1303
-    				$data['id_source'] = $id_source;
1304
-    				$data['format_source'] = 'tsv';
1305
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1306
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1290
+					$lined[$key] = $line[$k+1];
1291
+				}
1292
+					if (count($lined) > 3) {
1293
+					$data['hex'] = $lined['hexid'];
1294
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1295
+					$data['datetime'] = date('Y-m-d H:i:s');;
1296
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1297
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1298
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1299
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1300
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1301
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1302
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1303
+					$data['id_source'] = $id_source;
1304
+					$data['format_source'] = 'tsv';
1305
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1306
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1307 1307
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1308
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1309
-    				unset($lined);
1310
-    				unset($data);
1311
-    			    } else $error = true;
1308
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1309
+					unset($lined);
1310
+					unset($data);
1311
+					} else $error = true;
1312 1312
 			} elseif ($format == 'aprs' && $use_aprs) {
1313
-			    if ($aprs_connect == 0) {
1313
+				if ($aprs_connect == 0) {
1314 1314
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1315 1315
 				$aprs_connect = 1;
1316
-			    }
1316
+				}
1317 1317
 			    
1318
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1318
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1319 1319
 				$aprs_last_tx = time();
1320 1320
 				$data_aprs = "# Keep alive";
1321 1321
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1322
-			    }
1322
+				}
1323 1323
 			    
1324
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1325
-			    //echo 'APRS data : '.$buffer."\n";
1326
-			    $buffer = str_replace('APRS <- ','',$buffer);
1327
-			    $buffer = str_replace('APRS -> ','',$buffer);
1328
-			    //echo $buffer."\n";
1329
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1324
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1325
+				//echo 'APRS data : '.$buffer."\n";
1326
+				$buffer = str_replace('APRS <- ','',$buffer);
1327
+				$buffer = str_replace('APRS -> ','',$buffer);
1328
+				//echo $buffer."\n";
1329
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1330 1330
 				$line = $APRS->parse($buffer);
1331 1331
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1332 1332
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1333
-				    $aprs_last_tx = time();
1334
-				    $data = array();
1335
-				    //print_r($line);
1336
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1337
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1338
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1339
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1340
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1341
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1342
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1343
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1344
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1345
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1346
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1347
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1348
-				    $data['latitude'] = $line['latitude'];
1349
-				    $data['longitude'] = $line['longitude'];
1350
-				    //$data['verticalrate'] = $line[16];
1351
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1352
-				    //else $data['speed'] = 0;
1353
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1354
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1355
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1356
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1357
-				    //else $data['heading'] = 0;
1358
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1359
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1360
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1361
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1362
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1363
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1364
-    				    $data['id_source'] = $id_source;
1365
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1366
-				    else $data['format_source'] = 'aprs';
1367
-				    $data['source_name'] = $line['source'];
1368
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1369
-				    else $data['source_type'] = 'flarm';
1370
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1371
-				    $currentdate = date('Y-m-d H:i:s');
1372
-				    $aprsdate = strtotime($data['datetime']);
1373
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1374
-				    // Accept data if time <= system time + 20s
1375
-				    //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1376
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1333
+					$aprs_last_tx = time();
1334
+					$data = array();
1335
+					//print_r($line);
1336
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1337
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1338
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1339
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1340
+					if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1341
+					if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1342
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1343
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1344
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1345
+					else $data['datetime'] = date('Y-m-d H:i:s');
1346
+					//$data['datetime'] = date('Y-m-d H:i:s');
1347
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1348
+					$data['latitude'] = $line['latitude'];
1349
+					$data['longitude'] = $line['longitude'];
1350
+					//$data['verticalrate'] = $line[16];
1351
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1352
+					//else $data['speed'] = 0;
1353
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1354
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1355
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1356
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
1357
+					//else $data['heading'] = 0;
1358
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1359
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1360
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1361
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1362
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1363
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1364
+						$data['id_source'] = $id_source;
1365
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1366
+					else $data['format_source'] = 'aprs';
1367
+					$data['source_name'] = $line['source'];
1368
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1369
+					else $data['source_type'] = 'flarm';
1370
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1371
+					$currentdate = date('Y-m-d H:i:s');
1372
+					$aprsdate = strtotime($data['datetime']);
1373
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1374
+					// Accept data if time <= system time + 20s
1375
+					//if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1376
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1377 1377
 					$send = $SI->add($data);
1378
-				    } elseif ($data['source_type'] == 'ais') {
1378
+					} elseif ($data['source_type'] == 'ais') {
1379 1379
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1380
-				    } elseif (isset($line['stealth'])) {
1380
+					} elseif (isset($line['stealth'])) {
1381 1381
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1382 1382
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1383
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1384
-					    //$line['symbol'] == 'Balloon' ||
1385
-					    $line['symbol'] == 'Glider' || 
1386
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1387
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1388
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1389
-					    $send = $SI->add($data);
1390
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1391
-					    $line['symbol'] == 'Yacht (Sail)' || 
1392
-					    $line['symbol'] == 'Ship (Power Boat)')) {
1393
-					    $send = $MI->add($data);
1394
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1395
-					    $line['symbol'] == 'Car' || 
1396
-					    $line['symbol'] == 'Ambulance' || 
1397
-					    $line['symbol'] == 'Van' || 
1398
-					    $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1399
-					    $line['symbol'] == 'Motorcycle' || 
1400
-					    $line['symbol'] == 'Tractor' || 
1401
-					    $line['symbol'] == 'Police' || 
1402
-					    $line['symbol'] == 'Bike' || 
1403
-					    $line['symbol'] == 'Jogger' || 
1404
-					    $line['symbol'] == 'Horse' || 
1405
-					    $line['symbol'] == 'Bus' || 
1406
-					    $line['symbol'] == 'Jeep' || 
1407
-					    $line['symbol'] == 'Recreational Vehicle' || 
1408
-					    $line['symbol'] == 'Yacht (Sail)' || 
1409
-					    $line['symbol'] == 'Ship (Power Boat)' || 
1410
-					    $line['symbol'] == 'Firetruck' || 
1411
-					    $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1412
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1413
-					    $line['symbol'] == 'SUV' ||
1414
-					    $line['symbol'] == 'Snowmobile' ||
1415
-					    $line['symbol'] == 'Mobile Satellite Station')) {
1416
-				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1383
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1384
+						//$line['symbol'] == 'Balloon' ||
1385
+						$line['symbol'] == 'Glider' || 
1386
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1387
+						if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1388
+						if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1389
+						$send = $SI->add($data);
1390
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1391
+						$line['symbol'] == 'Yacht (Sail)' || 
1392
+						$line['symbol'] == 'Ship (Power Boat)')) {
1393
+						$send = $MI->add($data);
1394
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1395
+						$line['symbol'] == 'Car' || 
1396
+						$line['symbol'] == 'Ambulance' || 
1397
+						$line['symbol'] == 'Van' || 
1398
+						$line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1399
+						$line['symbol'] == 'Motorcycle' || 
1400
+						$line['symbol'] == 'Tractor' || 
1401
+						$line['symbol'] == 'Police' || 
1402
+						$line['symbol'] == 'Bike' || 
1403
+						$line['symbol'] == 'Jogger' || 
1404
+						$line['symbol'] == 'Horse' || 
1405
+						$line['symbol'] == 'Bus' || 
1406
+						$line['symbol'] == 'Jeep' || 
1407
+						$line['symbol'] == 'Recreational Vehicle' || 
1408
+						$line['symbol'] == 'Yacht (Sail)' || 
1409
+						$line['symbol'] == 'Ship (Power Boat)' || 
1410
+						$line['symbol'] == 'Firetruck' || 
1411
+						$line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1412
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1413
+						$line['symbol'] == 'SUV' ||
1414
+						$line['symbol'] == 'Snowmobile' ||
1415
+						$line['symbol'] == 'Mobile Satellite Station')) {
1416
+					//} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1417 1417
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1418 1418
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1419 1419
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1420
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1420
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1421 1421
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1422 1422
 					$Source->deleteOldLocationByType('gs');
1423 1423
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1425,7 +1425,7 @@  discard block
 block discarded – undo
1425 1425
 					} else {
1426 1426
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1427 1427
 					}
1428
-				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1428
+					} elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1429 1429
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1430 1430
 					//if ($globalDebug) echo '# Weather Station added'."\n";
1431 1431
 					$Source->deleteOldLocationByType('wx');
@@ -1437,10 +1437,10 @@  discard block
 block discarded – undo
1437 1437
 					}
1438 1438
 					unset($data);
1439 1439
 				    
1440
-				    } elseif ($globalDebug) {
1441
-				    	echo '/!\ Not added: '.$buffer."\n";
1442
-				    	print_r($line);
1443
-				    }
1440
+					} elseif ($globalDebug) {
1441
+						echo '/!\ Not added: '.$buffer."\n";
1442
+						print_r($line);
1443
+					}
1444 1444
 				}
1445 1445
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1446 1446
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1452,12 +1452,12 @@  discard block
 block discarded – undo
1452 1452
 				*/
1453 1453
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1454 1454
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1455
-			    }
1455
+				}
1456 1456
 			} else {
1457
-			    $line = explode(',', $buffer);
1458
-    			    if (count($line) > 20) {
1459
-    			    	$data['hex'] = $line[4];
1460
-    				/*
1457
+				$line = explode(',', $buffer);
1458
+					if (count($line) > 20) {
1459
+						$data['hex'] = $line[4];
1460
+					/*
1461 1461
     				$data['datetime'] = $line[6].' '.$line[7];
1462 1462
     					date_default_timezone_set($globalTimezone);
1463 1463
     					$datetime = new DateTime($data['datetime']);
@@ -1465,30 +1465,30 @@  discard block
 block discarded – undo
1465 1465
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1466 1466
     					date_default_timezone_set('UTC');
1467 1467
     				*/
1468
-    				// Force datetime to current UTC datetime
1469
-    				date_default_timezone_set('UTC');
1470
-    				$data['datetime'] = date('Y-m-d H:i:s');
1471
-    				$data['ident'] = trim($line[10]);
1472
-    				$data['latitude'] = $line[14];
1473
-    				$data['longitude'] = $line[15];
1474
-    				$data['verticalrate'] = $line[16];
1475
-    				$data['emergency'] = $line[20];
1476
-    				$data['speed'] = $line[12];
1477
-    				$data['squawk'] = $line[17];
1478
-    				$data['altitude'] = $line[11];
1479
-    				$data['heading'] = $line[13];
1480
-    				$data['ground'] = $line[21];
1481
-    				$data['emergency'] = $line[19];
1482
-    				$data['format_source'] = 'sbs';
1468
+					// Force datetime to current UTC datetime
1469
+					date_default_timezone_set('UTC');
1470
+					$data['datetime'] = date('Y-m-d H:i:s');
1471
+					$data['ident'] = trim($line[10]);
1472
+					$data['latitude'] = $line[14];
1473
+					$data['longitude'] = $line[15];
1474
+					$data['verticalrate'] = $line[16];
1475
+					$data['emergency'] = $line[20];
1476
+					$data['speed'] = $line[12];
1477
+					$data['squawk'] = $line[17];
1478
+					$data['altitude'] = $line[11];
1479
+					$data['heading'] = $line[13];
1480
+					$data['ground'] = $line[21];
1481
+					$data['emergency'] = $line[19];
1482
+					$data['format_source'] = 'sbs';
1483 1483
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1484
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1484
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1485 1485
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1486
-    				$data['id_source'] = $id_source;
1487
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1488
-    				else $error = true;
1489
-    				unset($data);
1490
-    			    } else $error = true;
1491
-			    if ($error) {
1486
+					$data['id_source'] = $id_source;
1487
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1488
+					else $error = true;
1489
+					unset($data);
1490
+					} else $error = true;
1491
+				if ($error) {
1492 1492
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1493 1493
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1494 1494
 				} else {
@@ -1504,13 +1504,13 @@  discard block
 block discarded – undo
1504 1504
 					connect_all($sourceer);
1505 1505
 					$sourceer = array();
1506 1506
 				}
1507
-			    }
1507
+				}
1508 1508
 			}
1509 1509
 			// Sleep for xxx microseconds
1510 1510
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1511
-		    } else {
1511
+			} else {
1512 1512
 			if ($format == 'flightgearmp') {
1513
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1513
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1514 1514
 				//@socket_close($r);
1515 1515
 				sleep($globalMinFetch);
1516 1516
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1519,9 +1519,9 @@  discard block
 block discarded – undo
1519 1519
 				break;
1520 1520
 				
1521 1521
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1522
-			    if (isset($tt[$format])) $tt[$format]++;
1523
-			    else $tt[$format] = 0;
1524
-			    if ($tt[$format] > 30) {
1522
+				if (isset($tt[$format])) $tt[$format]++;
1523
+				else $tt[$format] = 0;
1524
+				if ($tt[$format] > 30) {
1525 1525
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1526 1526
 				//@socket_close($r);
1527 1527
 				sleep(2);
@@ -1532,23 +1532,23 @@  discard block
 block discarded – undo
1532 1532
 				//connect_all($globalSources);
1533 1533
 				$tt[$format]=0;
1534 1534
 				break;
1535
-			    }
1535
+				}
1536
+			}
1536 1537
 			}
1537
-		    }
1538 1538
 		}
1539
-	    } else {
1539
+		} else {
1540 1540
 		$error = socket_strerror(socket_last_error());
1541 1541
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1542 1542
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1543 1543
 			if (isset($globalDebug)) echo "Restarting...\n";
1544 1544
 			// Restart the script if possible
1545 1545
 			if (is_array($sockets)) {
1546
-			    if ($globalDebug) echo "Shutdown all sockets...";
1546
+				if ($globalDebug) echo "Shutdown all sockets...";
1547 1547
 			    
1548
-			    foreach ($sockets as $sock) {
1548
+				foreach ($sockets as $sock) {
1549 1549
 				@socket_shutdown($sock,2);
1550 1550
 				@socket_close($sock);
1551
-			    }
1551
+				}
1552 1552
 			    
1553 1553
 			}
1554 1554
 			if ($globalDebug) echo "Waiting...";
@@ -1563,15 +1563,15 @@  discard block
 block discarded – undo
1563 1563
 			if ($globalDebug) echo "Restart all connections...";
1564 1564
 			connect_all($globalSources);
1565 1565
 		}
1566
-	    }
1566
+		}
1567 1567
 	}
1568 1568
 	if ($globalDaemon === false) {
1569
-	    if ($globalDebug) echo 'Check all...'."\n";
1570
-	    if (isset($SI)) $SI->checkAll();
1571
-	    if (isset($TI)) $TI->checkAll();
1572
-	    if (isset($MI)) $MI->checkAll();
1569
+		if ($globalDebug) echo 'Check all...'."\n";
1570
+		if (isset($SI)) $SI->checkAll();
1571
+		if (isset($TI)) $TI->checkAll();
1572
+		if (isset($MI)) $MI->checkAll();
1573
+	}
1573 1574
 	}
1574
-    }
1575 1575
 }
1576 1576
 
1577 1577
 ?>
Please login to merge, or discard this patch.
Spacing   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -46,20 +46,20 @@  discard block
 block discarded – undo
46 46
 	    die;
47 47
 	}
48 48
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
49
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
49
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
50 50
     }
51 51
 }
52 52
 
53
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
53
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver'));
54 54
 //if (isset($options['s'])) $hosts = array($options['s']);
55 55
 //elseif (isset($options['source'])) $hosts = array($options['source']);
56 56
 if (isset($options['s'])) {
57 57
     $globalSources = array();
58
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
59 59
     else $globalSources[] = array('host' => $options['s']);
60 60
 } elseif (isset($options['source'])) {
61 61
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
63 63
     else $globalSources[] = array('host' => $options['source']);
64 64
 }
65 65
 if (isset($options['aprsserverhost'])) {
@@ -76,28 +76,28 @@  discard block
 block discarded – undo
76 76
 else $id_source = 1;
77 77
 if (isset($globalServer) && $globalServer) {
78 78
     if ($globalDebug) echo "Using Server Mode\n";
79
-    $SI=new SpotterServer();
79
+    $SI = new SpotterServer();
80 80
 /*
81 81
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
82 82
     $SI = new adsb2aprs();
83 83
     $SI->connect();
84 84
 */
85
-} else $SI=new SpotterImport($Connection->db);
85
+} else $SI = new SpotterImport($Connection->db);
86 86
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
87 87
 if (isset($globalMarine) && $globalMarine) {
88 88
     $AIS = new AIS();
89 89
     $MI = new MarineImport($Connection->db);
90 90
 }
91 91
 //$APRS=new APRS($Connection->db);
92
-$SBS=new SBS();
93
-$ACARS=new ACARS($Connection->db);
94
-$Source=new Source($Connection->db);
95
-$Common=new Common();
92
+$SBS = new SBS();
93
+$ACARS = new ACARS($Connection->db);
94
+$Source = new Source($Connection->db);
95
+$Common = new Common();
96 96
 date_default_timezone_set('UTC');
97 97
 //$servertz = system('date +%Z');
98 98
 // signal handler - playing nice with sockets and dump1090
99 99
 if (function_exists('pcntl_fork')) {
100
-    pcntl_signal(SIGINT,  function() {
100
+    pcntl_signal(SIGINT, function() {
101 101
         global $sockets;
102 102
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
103 103
         die("Bye!\n");
@@ -113,30 +113,30 @@  discard block
 block discarded – undo
113 113
 
114 114
 function connect_all($hosts) {
115 115
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
116
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
117 117
     $reset++;
118 118
     if ($globalDebug) echo 'Connect to all...'."\n";
119 119
     foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
123
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
+            if (preg_match('/deltadb.txt$/i', $host)) {
125 125
         	//$formats[$id] = 'deltadbtxt';
126 126
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 127
         	//$last_exec['deltadbtxt'] = 0;
128 128
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
129
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
130 130
         	//$formats[$id] = 'vatsimtxt';
131 131
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 132
         	//$last_exec['vatsimtxt'] = 0;
133 133
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
134
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
135 135
         	//$formats[$id] = 'aircraftlistjson';
136 136
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 137
         	//$last_exec['aircraftlistjson'] = 0;
138 138
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
139
+    	    } else if (preg_match('/opensky/i', $host)) {
140 140
         	//$formats[$id] = 'aircraftlistjson';
141 141
         	$globalSources[$id]['format'] = 'opensky';
142 142
         	//$last_exec['aircraftlistjson'] = 0;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         	    exit(0);
154 154
         	}
155 155
     	    */
156
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
156
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
157 157
         	//$formats[$id] = 'planeupdatefaa';
158 158
         	$globalSources[$id]['format'] = 'planeupdatefaa';
159 159
         	//$last_exec['planeupdatefaa'] = 0;
@@ -162,29 +162,29 @@  discard block
 block discarded – undo
162 162
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163 163
         	    exit(0);
164 164
         	}
165
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
165
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
166 166
         	//$formats[$id] = 'phpvmacars';
167 167
         	$globalSources[$id]['format'] = 'phpvmacars';
168 168
         	//$last_exec['phpvmacars'] = 0;
169 169
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
170
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
170
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
171 171
         	//$formats[$id] = 'phpvmacars';
172 172
         	$globalSources[$id]['format'] = 'vam';
173 173
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
174
-            } else if (preg_match('/whazzup/i',$host)) {
174
+            } else if (preg_match('/whazzup/i', $host)) {
175 175
         	//$formats[$id] = 'whazzup';
176 176
         	$globalSources[$id]['format'] = 'whazzup';
177 177
         	//$last_exec['whazzup'] = 0;
178 178
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
179
-            } else if (preg_match('/airwhere/i',$host)) {
179
+            } else if (preg_match('/airwhere/i', $host)) {
180 180
         	$globalSources[$id]['format'] = 'airwhere';
181 181
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
182
-            } else if (preg_match('/recentpireps/i',$host)) {
182
+            } else if (preg_match('/recentpireps/i', $host)) {
183 183
         	//$formats[$id] = 'pirepsjson';
184 184
         	$globalSources[$id]['format'] = 'pirepsjson';
185 185
         	//$last_exec['pirepsjson'] = 0;
186 186
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
187
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
187
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
188 188
         	//$formats[$id] = 'fr24json';
189 189
         	$globalSources[$id]['format'] = 'fr24json';
190 190
         	//$last_exec['fr24json'] = 0;
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
194 194
         	    exit(0);
195 195
         	}
196
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
196
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
197 197
         	//$formats[$id] = 'fr24json';
198 198
         	$globalSources[$id]['format'] = 'myshiptracking';
199 199
         	//$last_exec['fr24json'] = 0;
@@ -203,22 +203,22 @@  discard block
 block discarded – undo
203 203
         	    exit(0);
204 204
         	}
205 205
             //} else if (preg_match('/10001/',$host)) {
206
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
206
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
207 207
         	//$formats[$id] = 'tsv';
208 208
         	$globalSources[$id]['format'] = 'tsv';
209 209
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
210 210
             }
211
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
211
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
212 212
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
213
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
213
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
214 214
     		    if ($idf !== false) {
215 215
     			$httpfeeds[$id] = $idf;
216 216
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
217 217
     		    }
218 218
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
219 219
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
220
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
221
-	    $hostport = explode(':',$host);
220
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
221
+	    $hostport = explode(':', $host);
222 222
 	    if (isset($hostport[1])) {
223 223
 		$port = $hostport[1];
224 224
 		$hostn = $hostport[0];
@@ -228,19 +228,19 @@  discard block
 block discarded – undo
228 228
 	    }
229 229
 	    $Common = new Common();
230 230
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
231
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
231
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
232 232
     	    } else {
233
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
233
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
234 234
 	    }
235 235
 	    if ($s) {
236 236
     	        $sockets[$id] = $s;
237 237
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
238
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
238
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
239 239
 			//$formats[$id] = 'aprs';
240 240
 			$globalSources[$id]['format'] = 'aprs';
241 241
 			//$aprs_connect = 0;
242 242
 			//$use_aprs = true;
243
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
243
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
244 244
 			$globalSources[$id]['format'] = 'vrstcp';
245 245
     		    } elseif ($port == '10001') {
246 246
         		//$formats[$id] = 'tsv';
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
280 280
 else $timeout = 20;
281 281
 $errno = '';
282
-$errstr='';
282
+$errstr = '';
283 283
 
284 284
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
285 285
 /* Initiate connections to all the hosts simultaneously */
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 //connect_all($globalSources);
288 288
 
289 289
 if (isset($globalProxy) && $globalProxy) {
290
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
290
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
291 291
 } else {
292 292
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
293 293
 }
@@ -317,16 +317,16 @@  discard block
 block discarded – undo
317 317
 
318 318
 if ($use_aprs) {
319 319
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
320
-	$APRS=new APRS();
320
+	$APRS = new APRS();
321 321
 	$aprs_connect = 0;
322 322
 	$aprs_keep = 120;
323 323
 	$aprs_last_tx = time();
324 324
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
325
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
325
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
326 326
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
327
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
327
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
328 328
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
329
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
329
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
330 330
 	if ($aprs_full) $aprs_filter = '';
331 331
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
332 332
 	else $aprs_pass = '-1';
@@ -340,12 +340,12 @@  discard block
 block discarded – undo
340 340
 sleep(1);
341 341
 if ($globalDebug) echo "SCAN MODE \n\n";
342 342
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
343
-$endtime = time()+$globalCronEnd;
343
+$endtime = time() + $globalCronEnd;
344 344
 $i = 1;
345 345
 $tt = array();
346 346
 // Delete all ATC
347 347
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
348
-	$ATC=new ATC($Connection->db);
348
+	$ATC = new ATC($Connection->db);
349 349
 }
350 350
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
351 351
 	$ATC->deleteAll();
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 
354 354
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
355 355
 while ($i > 0) {
356
-    if (!$globalDaemon) $i = $endtime-time();
356
+    if (!$globalDaemon) $i = $endtime - time();
357 357
     // Delete old ATC
358 358
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
359 359
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 	}
368 368
 	if ($max != $globalMinFetch) {
369 369
 	    if ($globalDebug) echo 'Sleeping...'."\n";
370
-	    sleep($globalMinFetch-$max+2);
370
+	    sleep($globalMinFetch - $max + 2);
371 371
 	}
372 372
     }
373 373
 
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
 	    //$buffer = $Common->getData($hosts[$id]);
381 381
 	    $buffer = $Common->getData($value['host']);
382 382
 	    if ($buffer != '') $reset = 0;
383
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
384
-	    $buffer = explode('\n',$buffer);
383
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
384
+	    $buffer = explode('\n', $buffer);
385 385
 	    foreach ($buffer as $line) {
386 386
     		if ($line != '' && count($line) > 7) {
387 387
     		    $line = explode(',', $line);
@@ -409,11 +409,11 @@  discard block
 block discarded – undo
409 409
     	    $last_exec[$id]['last'] = time();
410 410
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
411 411
 	    date_default_timezone_set('CET');
412
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
412
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
413 413
 	    date_default_timezone_set('UTC');
414 414
 	    if ($buffer != '') $reset = 0;
415
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
416
-	    $buffer = explode('\n',$buffer);
415
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
416
+	    $buffer = explode('\n', $buffer);
417 417
 	    foreach ($buffer as $line) {
418 418
 		if ($line != '') {
419 419
 		    //echo "'".$line."'\n";
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
432 432
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
433 433
 		    if (isset($ais_data['timestamp'])) {
434
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
434
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
435 435
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
436 436
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
437 437
 			    $add = true;
@@ -454,12 +454,12 @@  discard block
 block discarded – undo
454 454
 	    $w = $e = null;
455 455
 	    
456 456
 	    if (isset($arr[$id])) {
457
-		$nn = stream_select($arr,$w,$e,$timeout);
457
+		$nn = stream_select($arr, $w, $e, $timeout);
458 458
 		if ($nn > 0) {
459 459
 		    foreach ($httpfeeds as $feed) {
460
-			$buffer = stream_get_line($feed,2000,"\n");
461
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
462
-			$buffer = explode('\n',$buffer);
460
+			$buffer = stream_get_line($feed, 2000, "\n");
461
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
462
+			$buffer = explode('\n', $buffer);
463 463
 			foreach ($buffer as $line) {
464 464
 			    if ($line != '') {
465 465
 				$ais_data = $AIS->parse_line(trim($line));
@@ -477,9 +477,9 @@  discard block
 block discarded – undo
477 477
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
478 478
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
479 479
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
480
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
480
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
481 481
 				if (isset($ais_data['timestamp'])) {
482
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
482
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
483 483
 				} else {
484 484
 				    $data['datetime'] = date('Y-m-d H:i:s');
485 485
 				}
@@ -505,10 +505,10 @@  discard block
 block discarded – undo
505 505
 		}
506 506
 	    }
507 507
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
508
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
508
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
509 509
 	    if ($buffer != '') {
510 510
 		//echo $buffer;
511
-		$all_data = json_decode($buffer,true);
511
+		$all_data = json_decode($buffer, true);
512 512
 		//print_r($all_data);
513 513
 		if (isset($all_data[0]['DATA'])) {
514 514
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
524 524
 			    $data['imo'] = $line['IMO'];
525 525
 			    //$data['arrival_code'] = $ais_data['destination'];
526
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
526
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
527 527
 			    $data['format_source'] = 'myshiptracking';
528 528
 			    $data['id_source'] = $id_source;
529 529
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -535,9 +535,9 @@  discard block
 block discarded – undo
535 535
 	    }
536 536
 	    $last_exec[$id]['last'] = time();
537 537
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
538
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
538
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
539 539
 	    if ($buffer != '') {
540
-		$all_data = json_decode($buffer,true);
540
+		$all_data = json_decode($buffer, true);
541 541
 		if (isset($all_data[0]['mmsi'])) {
542 542
 		    foreach ($all_data as $line) {
543 543
 			if ($line != '') {
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	} elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
567 567
 	    $buffer = $Common->getData($value['host']);
568 568
 	    if ($buffer != '') {
569
-		$all_data = json_decode($buffer,true);
569
+		$all_data = json_decode($buffer, true);
570 570
 		if (isset($all_data['features'][0]['id'])) {
571 571
 		    foreach ($all_data['features'] as $line) {
572 572
 			$data = array();
@@ -594,27 +594,27 @@  discard block
 block discarded – undo
594 594
     	    $last_exec[$id]['last'] = time();
595 595
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
596 596
 	    echo 'download...';
597
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
597
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
598 598
 	    echo 'done !'."\n";
599 599
 	    if ($buffer != '') $reset = 0;
600
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
601
-	    $buffer = explode('\n',$buffer);
600
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
601
+	    $buffer = explode('\n', $buffer);
602 602
 	    foreach ($buffer as $line) {
603 603
 		if ($line != '') {
604 604
 		    $data = array();
605
-		    $data['mmsi'] = (int)substr($line,0,9);
606
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
605
+		    $data['mmsi'] = (int) substr($line, 0, 9);
606
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
607 607
 		    //$data['status'] = substr($line,21,2);
608 608
 		    //$data['type'] = substr($line,24,3);
609
-		    $data['latitude'] = substr($line,29,9);
610
-		    $data['longitude'] = substr($line,41,9);
611
-		    $data['speed'] = round(substr($line,51,5));
609
+		    $data['latitude'] = substr($line, 29, 9);
610
+		    $data['longitude'] = substr($line, 41, 9);
611
+		    $data['speed'] = round(substr($line, 51, 5));
612 612
 		    //$data['course'] = substr($line,57,5);
613
-		    $data['heading'] = round(substr($line,63,3));
613
+		    $data['heading'] = round(substr($line, 63, 3));
614 614
 		    //$data['draft'] = substr($line,67,4);
615 615
 		    //$data['length'] = substr($line,72,3);
616 616
 		    //$data['beam'] = substr($line,76,2);
617
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
617
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
618 618
 		    //$data['callsign'] = trim(substr($line,100,7);
619 619
 		    //$data['dest'] = substr($line,108,20);
620 620
 		    //$data['etaDate'] = substr($line,129,5);
@@ -633,8 +633,8 @@  discard block
 block discarded – undo
633 633
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
634 634
 	    //$buffer = $Common->getData($hosts[$id]);
635 635
 	    $buffer = $Common->getData($value['host']);
636
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
637
-	    $buffer = explode('\n',$buffer);
636
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
637
+	    $buffer = explode('\n', $buffer);
638 638
 	    $reset = 0;
639 639
 	    foreach ($buffer as $line) {
640 640
     		if ($line != '') {
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
646 646
 			$data['pilot_id'] = $line[1];
647 647
 			$data['pilot_name'] = $line[2];
648
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
648
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
649 649
 			$data['ident'] = $line[0]; // ident
650 650
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
651 651
 			$data['speed'] = $line[8]; // speed
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
662 662
 			//if (isset($line[37])) $data['last_update'] = $line[37];
663 663
 		        $data['departure_airport_icao'] = $line[11];
664
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
664
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
665 665
 		        $data['arrival_airport_icao'] = $line[13];
666 666
 			$data['frequency'] = $line[4];
667 667
 			$data['type'] = $line[18];
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
     			$data['id_source'] = $id_source;
671 671
 	    		//$data['arrival_airport_time'] = ;
672 672
 	    		if ($line[9] != '') {
673
-	    		    $aircraft_data = explode('/',$line[9]);
673
+	    		    $aircraft_data = explode('/', $line[9]);
674 674
 	    		    if (isset($aircraft_data[1])) {
675 675
 	    			$data['aircraft_icao'] = $aircraft_data[1];
676 676
 	    		    }
@@ -685,9 +685,9 @@  discard block
 block discarded – undo
685 685
     			if ($line[3] == 'PILOT') $SI->add($data);
686 686
 			elseif ($line[3] == 'ATC') {
687 687
 				//print_r($data);
688
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
689
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
690
-				$typec = substr($data['ident'],-3);
688
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
689
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
690
+				$typec = substr($data['ident'], -3);
691 691
 				if ($typec == 'APP') $data['type'] = 'Approach';
692 692
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
693 693
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -699,8 +699,8 @@  discard block
 block discarded – undo
699 699
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
700 700
 				if (!isset($data['source_name'])) $data['source_name'] = '';
701 701
 				if (isset($ATC)) {
702
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
703
-					else 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'],$data['format_source'],$data['source_name']);
702
+					if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
703
+					else 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'], $data['format_source'], $data['source_name']);
704 704
 				}
705 705
 			}
706 706
     			unset($data);
@@ -711,24 +711,24 @@  discard block
 block discarded – undo
711 711
     	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
712 712
     	    $last_exec[$id]['last'] = time();
713 713
     	} elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
714
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
714
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
715 715
 	    if ($buffer != '') {
716 716
 		$all_data = simplexml_load_string($buffer);
717
-		foreach($all_data->children() as $childdata) {
717
+		foreach ($all_data->children() as $childdata) {
718 718
 			$data = array();
719 719
 			$line = $childdata;
720 720
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
721
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
722
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
723
-			$data['latitude'] = (float)$line['pktLatitude'];
724
-			$data['longitude'] = (float)$line['pktLongitude'];
725
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
726
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
727
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
721
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
722
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
723
+			$data['latitude'] = (float) $line['pktLatitude'];
724
+			$data['longitude'] = (float) $line['pktLongitude'];
725
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
726
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
727
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
728 728
 			$data['altitude_relative'] = 'AMSL';
729
-			$data['pilot_id'] = (int)$line['pktPilotID'];
729
+			$data['pilot_id'] = (int) $line['pktPilotID'];
730 730
 			$data['aircraft_icao'] = 'PARAGLIDER';
731
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
731
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
732 732
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
733 733
 			$data['format_source'] = $value['format'];
734 734
 			$SI->add($data);
@@ -736,31 +736,31 @@  discard block
 block discarded – undo
736 736
 		}
737 737
 	    }
738 738
 	    $Source->deleteOldLocationByType('gs');
739
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
739
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
740 740
 	    if ($buffer != '') {
741 741
 		$all_data = simplexml_load_string($buffer);
742
-		foreach($all_data->children() as $childdata) {
742
+		foreach ($all_data->children() as $childdata) {
743 743
 			$data = array();
744 744
 			$line = $childdata;
745
-			$data['id'] = (int)$line['gsID'];
746
-			$data['latitude'] = (float)$line['gsLatitude'];
747
-			$data['longitude'] = (float)$line['gsLongitude'];
748
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
745
+			$data['id'] = (int) $line['gsID'];
746
+			$data['latitude'] = (float) $line['gsLatitude'];
747
+			$data['longitude'] = (float) $line['gsLongitude'];
748
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
749 749
 			$data['altitude_relative'] = 'AMSL';
750
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
750
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
751 751
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
752
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
752
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
753 753
 			} else {
754
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
754
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
755 755
 			}
756 756
 			unset($data);
757 757
 		}
758 758
 	    }
759 759
 	    $last_exec[$id]['last'] = time();
760 760
 	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
761
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
761
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
762 762
 	    if ($buffer != '') {
763
-	    $all_data = json_decode($buffer,true);
763
+	    $all_data = json_decode($buffer, true);
764 764
 	    if (isset($all_data['acList'])) {
765 765
 		$reset = 0;
766 766
 		foreach ($all_data['acList'] as $line) {
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 		    $data['emergency'] = ''; // emergency
778 778
 		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
779 779
 		    
780
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
780
+		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
781 781
 		    else $data['datetime'] = date('Y-m-d H:i:s');
782 782
 		    
783 783
 		    //$data['datetime'] = date('Y-m-d H:i:s');
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
804 804
 		    $data['squawk'] = $line['squawk']; // squawk
805 805
 		    $data['emergency'] = ''; // emergency
806
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
806
+		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
807 807
 		    else $data['datetime'] = date('Y-m-d H:i:s');
808 808
 	    	    $data['format_source'] = 'aircraftlistjson';
809 809
     		    $data['id_source'] = $id_source;
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
820 820
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
821 821
 	    $buffer = $Common->getData($value['host']);
822
-	    $all_data = json_decode($buffer,true);
822
+	    $all_data = json_decode($buffer, true);
823 823
 	    if (isset($all_data['planes'])) {
824 824
 		$reset = 0;
825 825
 		foreach ($all_data['planes'] as $key => $line) {
@@ -836,12 +836,12 @@  discard block
 block discarded – undo
836 836
 		    $data['emergency'] = ''; // emergency
837 837
 		    $data['registration'] = $line[2];
838 838
 		    $data['aircraft_icao'] = $line[0];
839
-		    $deparr = explode('-',$line[1]);
839
+		    $deparr = explode('-', $line[1]);
840 840
 		    if (count($deparr) == 2) {
841 841
 			$data['departure_airport_icao'] = $deparr[0];
842 842
 			$data['arrival_airport_icao'] = $deparr[1];
843 843
 		    }
844
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
844
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
845 845
 	    	    $data['format_source'] = 'planeupdatefaa';
846 846
     		    $data['id_source'] = $id_source;
847 847
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
     	    $last_exec[$id]['last'] = time();
855 855
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
856 856
 	    $buffer = $Common->getData($value['host']);
857
-	    $all_data = json_decode($buffer,true);
857
+	    $all_data = json_decode($buffer, true);
858 858
 	    if (isset($all_data['states'])) {
859 859
 		$reset = 0;
860 860
 		foreach ($all_data['states'] as $key => $line) {
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 		    //$data['emergency'] = ''; // emergency
872 872
 		    //$data['registration'] = $line[2];
873 873
 		    //$data['aircraft_icao'] = $line[0];
874
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
874
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
875 875
 	    	    $data['format_source'] = 'opensky';
876 876
     		    $data['id_source'] = $id_source;
877 877
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
886 886
 	    //$buffer = $Common->getData($hosts[$id]);
887 887
 	    $buffer = $Common->getData($value['host']);
888
-	    $all_data = json_decode($buffer,true);
888
+	    $all_data = json_decode($buffer, true);
889 889
 	    if (!empty($all_data)) $reset = 0;
890 890
 	    foreach ($all_data as $key => $line) {
891 891
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -918,11 +918,11 @@  discard block
 block discarded – undo
918 918
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
919 919
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
920 920
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
921
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
921
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
922 922
 	    //echo $buffer;
923
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
924
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
925
-	    $all_data = json_decode($buffer,true);
923
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
924
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
925
+	    $all_data = json_decode($buffer, true);
926 926
 	    if (json_last_error() != JSON_ERROR_NONE) {
927 927
 		die(json_last_error_msg());
928 928
 	    }
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
 			//$data['departure_airport_iata'] = $line[11];
946 946
 			//$data['arrival_airport_iata'] = $line[12];
947 947
 	    		//$data['emergency'] = ''; // emergency
948
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
948
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
949 949
 	    		$data['format_source'] = 'radarvirtueljson';
950 950
     			$data['id_source'] = $id_source;
951 951
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -961,14 +961,14 @@  discard block
 block discarded – undo
961 961
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
962 962
 	    //$buffer = $Common->getData($hosts[$id]);
963 963
 	    $buffer = $Common->getData($value['host'].'?'.time());
964
-	    $all_data = json_decode(utf8_encode($buffer),true);
964
+	    $all_data = json_decode(utf8_encode($buffer), true);
965 965
 	    
966 966
 	    if (isset($all_data['pireps'])) {
967 967
 		$reset = 0;
968 968
 	        foreach ($all_data['pireps'] as $line) {
969 969
 		    $data = array();
970 970
 		    $data['id'] = $line['id'];
971
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
971
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
972 972
 		    $data['ident'] = $line['callsign']; // ident
973 973
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
974 974
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -998,9 +998,9 @@  discard block
 block discarded – undo
998 998
 			$SI->add($data);
999 999
 		    //    print_r($data);
1000 1000
     		    } elseif ($line['icon'] == 'ct') {
1001
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1002
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1003
-			$typec = substr($data['ident'],-3);
1001
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1002
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1003
+			$typec = substr($data['ident'], -3);
1004 1004
 			$data['type'] = '';
1005 1005
 			if ($typec == 'APP') $data['type'] = 'Approach';
1006 1006
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1012 1012
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1013 1013
 			else $data['type'] = 'Observer';
1014
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1014
+			if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']);
1015 1015
 		    }
1016 1016
 		    unset($data);
1017 1017
 		}
@@ -1023,14 +1023,14 @@  discard block
 block discarded – undo
1023 1023
 	    //$buffer = $Common->getData($hosts[$id]);
1024 1024
 	    if ($globalDebug) echo 'Get Data...'."\n";
1025 1025
 	    $buffer = $Common->getData($value['host']);
1026
-	    $all_data = json_decode($buffer,true);
1026
+	    $all_data = json_decode($buffer, true);
1027 1027
 	    if ($buffer != '' && is_array($all_data)) {
1028 1028
 		$reset = 0;
1029 1029
 		foreach ($all_data as $line) {
1030 1030
 	    	    $data = array();
1031 1031
 	    	    //$data['id'] = $line['id']; // id not usable
1032 1032
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1033
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1033
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1034 1034
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1035 1035
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1036 1036
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
 	    	    //$data['datetime'] = $line['lastupdate'];
1046 1046
 	    	    //$data['last_update'] = $line['lastupdate'];
1047 1047
 	    	    if (isset($value['timezone'])) {
1048
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1048
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1049 1049
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1050 1050
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1051 1051
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1058,14 +1058,14 @@  discard block
 block discarded – undo
1058 1058
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1059 1059
 		    if (isset($line['aircraftname'])) {
1060 1060
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1061
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1062
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1061
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1062
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1063 1063
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1064 1064
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1065 1065
 	    		else {
1066
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1067
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1068
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1066
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1067
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1068
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1069 1069
 	    		}
1070 1070
 	    	    }
1071 1071
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1085,14 +1085,14 @@  discard block
 block discarded – undo
1085 1085
 	    //$buffer = $Common->getData($hosts[$id]);
1086 1086
 	    if ($globalDebug) echo 'Get Data...'."\n";
1087 1087
 	    $buffer = $Common->getData($value['host']);
1088
-	    $all_data = json_decode($buffer,true);
1088
+	    $all_data = json_decode($buffer, true);
1089 1089
 	    if ($buffer != '' && is_array($all_data)) {
1090 1090
 		$reset = 0;
1091 1091
 		foreach ($all_data as $line) {
1092 1092
 	    	    $data = array();
1093 1093
 	    	    //$data['id'] = $line['id']; // id not usable
1094 1094
 	    	    $data['id'] = trim($line['flight_id']);
1095
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1095
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1096 1096
 	    	    $data['pilot_name'] = $line['pilot_name'];
1097 1097
 	    	    $data['pilot_id'] = $line['pilot_id'];
1098 1098
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1144,11 +1144,11 @@  discard block
 block discarded – undo
1144 1144
 		    //$value = $formats[$nb];
1145 1145
 		    $format = $globalSources[$nb]['format'];
1146 1146
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1147
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1147
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1148 1148
 		    } elseif ($format == 'vrstcp') {
1149 1149
 			$buffer = @socket_read($r, 6000);
1150 1150
 		    } else {
1151
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1151
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1152 1152
 		    }
1153 1153
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1154 1154
 		    //echo $buffer."\n";
@@ -1157,8 +1157,8 @@  discard block
 block discarded – undo
1157 1157
 		    $error = false;
1158 1158
 		    //$SI::del();
1159 1159
 		    if ($format == 'vrstcp') {
1160
-			$buffer = explode('},{',$buffer);
1161
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1160
+			$buffer = explode('},{', $buffer);
1161
+		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1162 1162
 		    // SBS format is CSV format
1163 1163
 		    if ($buffer !== FALSE && $buffer != '') {
1164 1164
 			$tt[$format] = 0;
@@ -1192,13 +1192,13 @@  discard block
 block discarded – undo
1192 1192
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1193 1193
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1194 1194
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1195
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1195
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1196 1196
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1197 1197
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1198 1198
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1199 1199
 
1200 1200
 			    if (isset($ais_data['timestamp'])) {
1201
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1201
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1202 1202
 			    } else {
1203 1203
 				$data['datetime'] = date('Y-m-d H:i:s');
1204 1204
 			    }
@@ -1209,10 +1209,10 @@  discard block
 block discarded – undo
1209 1209
                         } elseif ($format == 'flightgearsp') {
1210 1210
                     	    //echo $buffer."\n";
1211 1211
                     	    if (strlen($buffer) > 5) {
1212
-				$line = explode(',',$buffer);
1212
+				$line = explode(',', $buffer);
1213 1213
 				$data = array();
1214 1214
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1215
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1215
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1216 1216
 				$data['ident'] = $line[6];
1217 1217
 				$data['aircraft_name'] = $line[7];
1218 1218
 				$data['longitude'] = $line[1];
@@ -1229,16 +1229,16 @@  discard block
 block discarded – undo
1229 1229
                         } elseif ($format == 'acars') {
1230 1230
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1231 1231
 			    $ACARS->add(trim($buffer));
1232
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1232
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1233 1233
 			    $ACARS->deleteLiveAcarsData();
1234 1234
 			} elseif ($format == 'flightgearmp') {
1235
-			    if (substr($buffer,0,1) != '#') {
1235
+			    if (substr($buffer, 0, 1) != '#') {
1236 1236
 				$data = array();
1237 1237
 				//echo $buffer."\n";
1238
-				$line = explode(' ',$buffer);
1238
+				$line = explode(' ', $buffer);
1239 1239
 				if (count($line) == 11) {
1240
-				    $userserver = explode('@',$line[0]);
1241
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1240
+				    $userserver = explode('@', $line[0]);
1241
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1242 1242
 				    $data['ident'] = $userserver[0];
1243 1243
 				    $data['registration'] = $userserver[0];
1244 1244
 				    $data['latitude'] = $line[4];
@@ -1246,8 +1246,8 @@  discard block
 block discarded – undo
1246 1246
 				    $data['altitude'] = $line[6];
1247 1247
 				    $data['datetime'] = date('Y-m-d H:i:s');
1248 1248
 				    $aircraft_type = $line[10];
1249
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1250
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1249
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1250
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1251 1251
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1252 1252
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1253 1253
 				}
@@ -1256,8 +1256,8 @@  discard block
 block discarded – undo
1256 1256
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1257 1257
 			    die;
1258 1258
 			} elseif ($format == 'vrstcp') {
1259
-			    foreach($buffer as $all_data) {
1260
-				$line = json_decode('{'.$all_data.'}',true);
1259
+			    foreach ($buffer as $all_data) {
1260
+				$line = json_decode('{'.$all_data.'}', true);
1261 1261
 				$data = array();
1262 1262
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1263 1263
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1283,16 +1283,16 @@  discard block
 block discarded – undo
1283 1283
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1284 1284
 				unset($data);
1285 1285
 			    }
1286
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1286
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1287 1287
 			    $line = explode("\t", $buffer);
1288
-			    for($k = 0; $k < count($line); $k=$k+2) {
1288
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1289 1289
 				$key = $line[$k];
1290
-			        $lined[$key] = $line[$k+1];
1290
+			        $lined[$key] = $line[$k + 1];
1291 1291
 			    }
1292 1292
     			    if (count($lined) > 3) {
1293 1293
     				$data['hex'] = $lined['hexid'];
1294 1294
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1295
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1295
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1296 1296
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1297 1297
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1298 1298
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1311,22 +1311,22 @@  discard block
 block discarded – undo
1311 1311
     			    } else $error = true;
1312 1312
 			} elseif ($format == 'aprs' && $use_aprs) {
1313 1313
 			    if ($aprs_connect == 0) {
1314
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1314
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1315 1315
 				$aprs_connect = 1;
1316 1316
 			    }
1317 1317
 			    
1318
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1318
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1319 1319
 				$aprs_last_tx = time();
1320 1320
 				$data_aprs = "# Keep alive";
1321
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1321
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1322 1322
 			    }
1323 1323
 			    
1324 1324
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1325 1325
 			    //echo 'APRS data : '.$buffer."\n";
1326
-			    $buffer = str_replace('APRS <- ','',$buffer);
1327
-			    $buffer = str_replace('APRS -> ','',$buffer);
1326
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1327
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1328 1328
 			    //echo $buffer."\n";
1329
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1329
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1330 1330
 				$line = $APRS->parse($buffer);
1331 1331
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1332 1332
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1341,7 +1341,7 @@  discard block
 block discarded – undo
1341 1341
 				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1342 1342
 				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1343 1343
 				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1344
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1344
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1345 1345
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1346 1346
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1347 1347
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1420,20 +1420,20 @@  discard block
 block discarded – undo
1420 1420
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1421 1421
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1422 1422
 					$Source->deleteOldLocationByType('gs');
1423
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1424
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1423
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1424
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1425 1425
 					} else {
1426
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1426
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1427 1427
 					}
1428 1428
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1429 1429
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1430 1430
 					//if ($globalDebug) echo '# Weather Station added'."\n";
1431 1431
 					$Source->deleteOldLocationByType('wx');
1432 1432
 					$weather_data = json_encode($line);
1433
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1434
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1433
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1434
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1435 1435
 					} else {
1436
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1436
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1437 1437
 					}
1438 1438
 					unset($data);
1439 1439
 				    
@@ -1443,7 +1443,7 @@  discard block
 block discarded – undo
1443 1443
 				    }
1444 1444
 				}
1445 1445
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1446
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1446
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1447 1447
 				}
1448 1448
 				/*
1449 1449
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
@@ -1530,7 +1530,7 @@  discard block
 block discarded – undo
1530 1530
 				connect_all($sourceee);
1531 1531
 				$sourceee = array();
1532 1532
 				//connect_all($globalSources);
1533
-				$tt[$format]=0;
1533
+				$tt[$format] = 0;
1534 1534
 				break;
1535 1535
 			    }
1536 1536
 			}
@@ -1539,14 +1539,14 @@  discard block
 block discarded – undo
1539 1539
 	    } else {
1540 1540
 		$error = socket_strerror(socket_last_error());
1541 1541
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1542
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1542
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1543 1543
 			if (isset($globalDebug)) echo "Restarting...\n";
1544 1544
 			// Restart the script if possible
1545 1545
 			if (is_array($sockets)) {
1546 1546
 			    if ($globalDebug) echo "Shutdown all sockets...";
1547 1547
 			    
1548 1548
 			    foreach ($sockets as $sock) {
1549
-				@socket_shutdown($sock,2);
1549
+				@socket_shutdown($sock, 2);
1550 1550
 				@socket_close($sock);
1551 1551
 			    }
1552 1552
 			    
Please login to merge, or discard this patch.
Braces   +1007 added lines, -344 removed lines patch added patch discarded remove patch
@@ -14,13 +14,17 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Source.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17
+if (isset($globalTracker) && $globalTracker) {
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19
+}
18 20
 if (isset($globalMarine) && $globalMarine) {
19 21
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
20 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 23
 }
22 24
 
23
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
24 28
 
25 29
 // Check if schema is at latest version
26 30
 $Connection = new Connection();
@@ -55,35 +59,62 @@  discard block
 block discarded – undo
55 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
56 60
 if (isset($options['s'])) {
57 61
     $globalSources = array();
58
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
59
-    else $globalSources[] = array('host' => $options['s']);
60
-} elseif (isset($options['source'])) {
62
+    if (isset($options['format'])) {
63
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
64
+    } else {
65
+    	$globalSources[] = array('host' => $options['s']);
66
+    }
67
+    } elseif (isset($options['source'])) {
61 68
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['source']);
64
-}
69
+    if (isset($options['format'])) {
70
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
71
+    } else {
72
+    	$globalSources[] = array('host' => $options['source']);
73
+    }
74
+    }
65 75
 if (isset($options['aprsserverhost'])) {
66 76
 	$globalServerAPRS = TRUE;
67 77
 	$globalServerAPRShost = $options['aprsserverhost'];
68 78
 }
69
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
70
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
71
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
72
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
73
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
74
-if (isset($options['server'])) $globalServer = TRUE;
75
-if (isset($options['idsource'])) $id_source = $options['idsource'];
76
-else $id_source = 1;
79
+if (isset($options['aprsserverport'])) {
80
+	$globalServerAPRSport = $options['aprsserverport'];
81
+}
82
+if (isset($options['aprsserverssid'])) {
83
+	$globalServerAPRSssid = $options['aprsserverssid'];
84
+}
85
+if (isset($options['aprsserverpass'])) {
86
+	$globalServerAPRSpass = $options['aprsserverpass'];
87
+}
88
+if (isset($options['noaprsserver'])) {
89
+	$globalServerAPRS = FALSE;
90
+}
91
+if (isset($options['nodaemon'])) {
92
+	$globalDaemon = FALSE;
93
+}
94
+if (isset($options['server'])) {
95
+	$globalServer = TRUE;
96
+}
97
+if (isset($options['idsource'])) {
98
+	$id_source = $options['idsource'];
99
+} else {
100
+	$id_source = 1;
101
+}
77 102
 if (isset($globalServer) && $globalServer) {
78
-    if ($globalDebug) echo "Using Server Mode\n";
103
+    if ($globalDebug) {
104
+    	echo "Using Server Mode\n";
105
+    }
79 106
     $SI=new SpotterServer();
80 107
 /*
81 108
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
82 109
     $SI = new adsb2aprs();
83 110
     $SI->connect();
84 111
 */
85
-} else $SI=new SpotterImport($Connection->db);
86
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
112
+} else {
113
+	$SI=new SpotterImport($Connection->db);
114
+}
115
+if (isset($globalTracker) && $globalTracker) {
116
+	$TI = new TrackerImport($Connection->db);
117
+}
87 118
 if (isset($globalMarine) && $globalMarine) {
88 119
     $AIS = new AIS();
89 120
     $MI = new MarineImport($Connection->db);
@@ -106,7 +137,9 @@  discard block
 block discarded – undo
106 137
 }
107 138
 
108 139
 // let's try and connect
109
-if ($globalDebug) echo "Connecting...\n";
140
+if ($globalDebug) {
141
+	echo "Connecting...\n";
142
+}
110 143
 $use_aprs = false;
111 144
 $aprs_full = false;
112 145
 $reset = 0;
@@ -115,7 +148,9 @@  discard block
 block discarded – undo
115 148
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116 149
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
117 150
     $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
151
+    if ($globalDebug) {
152
+    	echo 'Connect to all...'."\n";
153
+    }
119 154
     foreach ($hosts as $id => $value) {
120 155
 	$host = $value['host'];
121 156
 	$globalSources[$id]['last_exec'] = 0;
@@ -125,22 +160,30 @@  discard block
 block discarded – undo
125 160
         	//$formats[$id] = 'deltadbtxt';
126 161
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 162
         	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
163
+        	if ($globalDebug) {
164
+        		echo "Connect to deltadb source (".$host.")...\n";
165
+        	}
129 166
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130 167
         	//$formats[$id] = 'vatsimtxt';
131 168
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 169
         	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
170
+        	if ($globalDebug) {
171
+        		echo "Connect to vatsim source (".$host.")...\n";
172
+        	}
134 173
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135 174
         	//$formats[$id] = 'aircraftlistjson';
136 175
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 176
         	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
177
+        	if ($globalDebug) {
178
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
179
+        	}
139 180
     	    } else if (preg_match('/opensky/i',$host)) {
140 181
         	//$formats[$id] = 'aircraftlistjson';
141 182
         	$globalSources[$id]['format'] = 'opensky';
142 183
         	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
184
+        	if ($globalDebug) {
185
+        		echo "Connect to opensky source (".$host.")...\n";
186
+        	}
144 187
     	    /*
145 188
     	    // Disabled for now, site change source format
146 189
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -157,7 +200,9 @@  discard block
 block discarded – undo
157 200
         	//$formats[$id] = 'planeupdatefaa';
158 201
         	$globalSources[$id]['format'] = 'planeupdatefaa';
159 202
         	//$last_exec['planeupdatefaa'] = 0;
160
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
203
+        	if ($globalDebug) {
204
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
205
+        	}
161 206
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
162 207
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163 208
         	    exit(0);
@@ -166,29 +211,41 @@  discard block
 block discarded – undo
166 211
         	//$formats[$id] = 'phpvmacars';
167 212
         	$globalSources[$id]['format'] = 'phpvmacars';
168 213
         	//$last_exec['phpvmacars'] = 0;
169
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
214
+        	if ($globalDebug) {
215
+        		echo "Connect to phpvmacars source (".$host.")...\n";
216
+        	}
170 217
             } else if (preg_match('/VAM-json.php$/i',$host)) {
171 218
         	//$formats[$id] = 'phpvmacars';
172 219
         	$globalSources[$id]['format'] = 'vam';
173
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
220
+        	if ($globalDebug) {
221
+        		echo "Connect to Vam source (".$host.")...\n";
222
+        	}
174 223
             } else if (preg_match('/whazzup/i',$host)) {
175 224
         	//$formats[$id] = 'whazzup';
176 225
         	$globalSources[$id]['format'] = 'whazzup';
177 226
         	//$last_exec['whazzup'] = 0;
178
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
227
+        	if ($globalDebug) {
228
+        		echo "Connect to whazzup source (".$host.")...\n";
229
+        	}
179 230
             } else if (preg_match('/airwhere/i',$host)) {
180 231
         	$globalSources[$id]['format'] = 'airwhere';
181
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
232
+        	if ($globalDebug) {
233
+        		echo "Connect to airwhere source (".$host.")...\n";
234
+        	}
182 235
             } else if (preg_match('/recentpireps/i',$host)) {
183 236
         	//$formats[$id] = 'pirepsjson';
184 237
         	$globalSources[$id]['format'] = 'pirepsjson';
185 238
         	//$last_exec['pirepsjson'] = 0;
186
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
239
+        	if ($globalDebug) {
240
+        		echo "Connect to pirepsjson source (".$host.")...\n";
241
+        	}
187 242
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
188 243
         	//$formats[$id] = 'fr24json';
189 244
         	$globalSources[$id]['format'] = 'fr24json';
190 245
         	//$last_exec['fr24json'] = 0;
191
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
246
+        	if ($globalDebug) {
247
+        		echo "Connect to fr24 source (".$host.")...\n";
248
+        	}
192 249
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
193 250
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
194 251
         	    exit(0);
@@ -197,7 +254,9 @@  discard block
 block discarded – undo
197 254
         	//$formats[$id] = 'fr24json';
198 255
         	$globalSources[$id]['format'] = 'myshiptracking';
199 256
         	//$last_exec['fr24json'] = 0;
200
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
257
+        	if ($globalDebug) {
258
+        		echo "Connect to myshiptracking source (".$host.")...\n";
259
+        	}
201 260
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
202 261
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
203 262
         	    exit(0);
@@ -206,17 +265,24 @@  discard block
 block discarded – undo
206 265
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
207 266
         	//$formats[$id] = 'tsv';
208 267
         	$globalSources[$id]['format'] = 'tsv';
209
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
268
+        	if ($globalDebug) {
269
+        		echo "Connect to tsv source (".$host.")...\n";
270
+        	}
210 271
             }
211 272
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
212 273
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
213 274
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
214 275
     		    if ($idf !== false) {
215 276
     			$httpfeeds[$id] = $idf;
216
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
277
+        		if ($globalDebug) {
278
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
279
+        		}
280
+    		    } elseif ($globalDebug) {
281
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
217 282
     		    }
218
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
219
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
283
+    		} elseif ($globalDebug) {
284
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
285
+    		}
220 286
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
221 287
 	    $hostport = explode(':',$host);
222 288
 	    if (isset($hostport[1])) {
@@ -256,17 +322,25 @@  discard block
 block discarded – undo
256 322
         		//$formats[$id] = 'beast';
257 323
         		$globalSources[$id]['format'] = 'beast';
258 324
 		    //} else $formats[$id] = 'sbs';
259
-		    } else $globalSources[$id]['format'] = 'sbs';
325
+		    } else {
326
+		    	$globalSources[$id]['format'] = 'sbs';
327
+		    }
260 328
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
261 329
 		}
262
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
330
+		if ($globalDebug) {
331
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
332
+		}
263 333
             } else {
264
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
334
+		if ($globalDebug) {
335
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
336
+		}
265 337
     	    }
266 338
         }
267 339
     }
268 340
 }
269
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
341
+if (!isset($globalMinFetch)) {
342
+	$globalMinFetch = 15;
343
+}
270 344
 
271 345
 // Initialize all
272 346
 $status = array();
@@ -275,13 +349,19 @@  discard block
 block discarded – undo
275 349
 $formats = array();
276 350
 $last_exec = array();
277 351
 $time = time();
278
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
279
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
280
-else $timeout = 20;
352
+if (isset($globalSourcesTimeout)) {
353
+	$timeout = $globalSourcesTimeOut;
354
+} else if (isset($globalSBS1TimeOut)) {
355
+	$timeout = $globalSBS1TimeOut;
356
+} else {
357
+	$timeout = 20;
358
+}
281 359
 $errno = '';
282 360
 $errstr='';
283 361
 
284
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
362
+if (!isset($globalDaemon)) {
363
+	$globalDaemon = TRUE;
364
+}
285 365
 /* Initiate connections to all the hosts simultaneously */
286 366
 //connect_all($hosts);
287 367
 //connect_all($globalSources);
@@ -310,7 +390,9 @@  discard block
 block discarded – undo
310 390
     if (isset($source['format']) && $source['format'] == 'aprs') {
311 391
 	$aprs_connect = 0;
312 392
 	$use_aprs = true;
313
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
393
+	if (isset($source['port']) && $source['port'] == '10152') {
394
+		$aprs_full = true;
395
+	}
314 396
 	break;
315 397
     }
316 398
 }
@@ -321,25 +403,48 @@  discard block
 block discarded – undo
321 403
 	$aprs_connect = 0;
322 404
 	$aprs_keep = 120;
323 405
 	$aprs_last_tx = time();
324
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
325
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
326
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
327
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
328
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
329
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
330
-	if ($aprs_full) $aprs_filter = '';
331
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
332
-	else $aprs_pass = '-1';
406
+	if (isset($globalAPRSversion)) {
407
+		$aprs_version = $globalAPRSversion;
408
+	} else {
409
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
410
+	}
411
+	if (isset($globalAPRSssid)) {
412
+		$aprs_ssid = $globalAPRSssid;
413
+	} else {
414
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
415
+	}
416
+	if (isset($globalAPRSfilter)) {
417
+		$aprs_filter = $globalAPRSfilter;
418
+	} else {
419
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
420
+	}
421
+	if ($aprs_full) {
422
+		$aprs_filter = '';
423
+	}
424
+	if (isset($globalAPRSpass)) {
425
+		$aprs_pass = $globalAPRSpass;
426
+	} else {
427
+		$aprs_pass = '-1';
428
+	}
333 429
 
334
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
335
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
336
-}
430
+	if ($aprs_filter != '') {
431
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
432
+	} else {
433
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
434
+	}
435
+	}
337 436
 
338 437
 // connected - lets do some work
339
-if ($globalDebug) echo "Connected!\n";
438
+if ($globalDebug) {
439
+	echo "Connected!\n";
440
+}
340 441
 sleep(1);
341
-if ($globalDebug) echo "SCAN MODE \n\n";
342
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
442
+if ($globalDebug) {
443
+	echo "SCAN MODE \n\n";
444
+}
445
+if (!isset($globalCronEnd)) {
446
+	$globalCronEnd = 60;
447
+}
343 448
 $endtime = time()+$globalCronEnd;
344 449
 $i = 1;
345 450
 $tt = array();
@@ -353,20 +458,28 @@  discard block
 block discarded – undo
353 458
 
354 459
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
355 460
 while ($i > 0) {
356
-    if (!$globalDaemon) $i = $endtime-time();
461
+    if (!$globalDaemon) {
462
+    	$i = $endtime-time();
463
+    }
357 464
     // Delete old ATC
358 465
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
359
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
466
+	if ($globalDebug) {
467
+		echo 'Delete old ATC...'."\n";
468
+	}
360 469
         $ATC->deleteOldATC();
361 470
     }
362 471
     
363 472
     if (count($last_exec) == count($globalSources)) {
364 473
 	$max = $globalMinFetch;
365 474
 	foreach ($last_exec as $last) {
366
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
475
+	    if ((time() - $last['last']) < $max) {
476
+	    	$max = time() - $last['last'];
477
+	    }
367 478
 	}
368 479
 	if ($max != $globalMinFetch) {
369
-	    if ($globalDebug) echo 'Sleeping...'."\n";
480
+	    if ($globalDebug) {
481
+	    	echo 'Sleeping...'."\n";
482
+	    }
370 483
 	    sleep($globalMinFetch-$max+2);
371 484
 	}
372 485
     }
@@ -375,11 +488,15 @@  discard block
 block discarded – undo
375 488
     //foreach ($formats as $id => $value) {
376 489
     foreach ($globalSources as $id => $value) {
377 490
 	date_default_timezone_set('UTC');
378
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
491
+	if (!isset($last_exec[$id]['last'])) {
492
+		$last_exec[$id]['last'] = 0;
493
+	}
379 494
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
380 495
 	    //$buffer = $Common->getData($hosts[$id]);
381 496
 	    $buffer = $Common->getData($value['host']);
382
-	    if ($buffer != '') $reset = 0;
497
+	    if ($buffer != '') {
498
+	    	$reset = 0;
499
+	    }
383 500
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
384 501
 	    $buffer = explode('\n',$buffer);
385 502
 	    foreach ($buffer as $line) {
@@ -388,20 +505,41 @@  discard block
 block discarded – undo
388 505
 	            $data = array();
389 506
 	            $data['hex'] = $line[1]; // hex
390 507
 	            $data['ident'] = $line[2]; // ident
391
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
392
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
393
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
394
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
395
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
508
+	            if (isset($line[3])) {
509
+	            	$data['altitude'] = $line[3];
510
+	            }
511
+	            // altitude
512
+	            if (isset($line[4])) {
513
+	            	$data['speed'] = $line[4];
514
+	            }
515
+	            // speed
516
+	            if (isset($line[5])) {
517
+	            	$data['heading'] = $line[5];
518
+	            }
519
+	            // heading
520
+	            if (isset($line[6])) {
521
+	            	$data['latitude'] = $line[6];
522
+	            }
523
+	            // lat
524
+	            if (isset($line[7])) {
525
+	            	$data['longitude'] = $line[7];
526
+	            }
527
+	            // long
396 528
 	            $data['verticalrate'] = ''; // vertical rate
397 529
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
398 530
 	            $data['emergency'] = ''; // emergency
399 531
 		    $data['datetime'] = date('Y-m-d H:i:s');
400 532
 		    $data['format_source'] = 'deltadbtxt';
401 533
     		    $data['id_source'] = $id_source;
402
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
403
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
404
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
534
+		    if (isset($value['name']) && $value['name'] != '') {
535
+		    	$data['source_name'] = $value['name'];
536
+		    }
537
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
538
+		    	$data['noarchive'] = true;
539
+		    }
540
+		    if (isset($value['sourcestats'])) {
541
+		    	$data['sourcestats'] = $value['sourcestats'];
542
+		    }
405 543
     		    $SI->add($data);
406 544
 		    unset($data);
407 545
     		}
@@ -411,7 +549,9 @@  discard block
 block discarded – undo
411 549
 	    date_default_timezone_set('CET');
412 550
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
413 551
 	    date_default_timezone_set('UTC');
414
-	    if ($buffer != '') $reset = 0;
552
+	    if ($buffer != '') {
553
+	    	$reset = 0;
554
+	    }
415 555
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
416 556
 	    $buffer = explode('\n',$buffer);
417 557
 	    foreach ($buffer as $line) {
@@ -420,16 +560,36 @@  discard block
 block discarded – undo
420 560
 		    $add = false;
421 561
 		    $ais_data = $AIS->parse_line(trim($line));
422 562
 		    $data = array();
423
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
424
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
425
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
426
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
427
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
428
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
429
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
430
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
431
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
432
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
563
+		    if (isset($ais_data['ident'])) {
564
+		    	$data['ident'] = $ais_data['ident'];
565
+		    }
566
+		    if (isset($ais_data['mmsi'])) {
567
+		    	$data['mmsi'] = $ais_data['mmsi'];
568
+		    }
569
+		    if (isset($ais_data['speed'])) {
570
+		    	$data['speed'] = $ais_data['speed'];
571
+		    }
572
+		    if (isset($ais_data['heading'])) {
573
+		    	$data['heading'] = $ais_data['heading'];
574
+		    }
575
+		    if (isset($ais_data['latitude'])) {
576
+		    	$data['latitude'] = $ais_data['latitude'];
577
+		    }
578
+		    if (isset($ais_data['longitude'])) {
579
+		    	$data['longitude'] = $ais_data['longitude'];
580
+		    }
581
+		    if (isset($ais_data['status'])) {
582
+		    	$data['status'] = $ais_data['status'];
583
+		    }
584
+		    if (isset($ais_data['type'])) {
585
+		    	$data['type'] = $ais_data['type'];
586
+		    }
587
+		    if (isset($ais_data['imo'])) {
588
+		    	$data['imo'] = $ais_data['imo'];
589
+		    }
590
+		    if (isset($ais_data['callsign'])) {
591
+		    	$data['callsign'] = $ais_data['callsign'];
592
+		    }
433 593
 		    if (isset($ais_data['timestamp'])) {
434 594
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
435 595
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -443,8 +603,12 @@  discard block
 block discarded – undo
443 603
 		    $data['format_source'] = 'aisnmeatxt';
444 604
     		    $data['id_source'] = $id_source;
445 605
 		    //print_r($data);
446
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
447
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
606
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
607
+		    	$data['noarchive'] = true;
608
+		    }
609
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
610
+		    	$MI->add($data);
611
+		    }
448 612
 		    unset($data);
449 613
 		}
450 614
     	    }
@@ -464,20 +628,48 @@  discard block
 block discarded – undo
464 628
 			    if ($line != '') {
465 629
 				$ais_data = $AIS->parse_line(trim($line));
466 630
 				$data = array();
467
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
468
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
469
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
470
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
471
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
472
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
473
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
474
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
475
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
476
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
477
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
478
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
479
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
480
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
631
+				if (isset($ais_data['ident'])) {
632
+					$data['ident'] = $ais_data['ident'];
633
+				}
634
+				if (isset($ais_data['mmsi'])) {
635
+					$data['mmsi'] = $ais_data['mmsi'];
636
+				}
637
+				if (isset($ais_data['speed'])) {
638
+					$data['speed'] = $ais_data['speed'];
639
+				}
640
+				if (isset($ais_data['heading'])) {
641
+					$data['heading'] = $ais_data['heading'];
642
+				}
643
+				if (isset($ais_data['latitude'])) {
644
+					$data['latitude'] = $ais_data['latitude'];
645
+				}
646
+				if (isset($ais_data['longitude'])) {
647
+					$data['longitude'] = $ais_data['longitude'];
648
+				}
649
+				if (isset($ais_data['status'])) {
650
+					$data['status'] = $ais_data['status'];
651
+				}
652
+				if (isset($ais_data['statusid'])) {
653
+					$data['status_id'] = $ais_data['statusid'];
654
+				}
655
+				if (isset($ais_data['type'])) {
656
+					$data['type'] = $ais_data['type'];
657
+				}
658
+				if (isset($ais_data['typeid'])) {
659
+					$data['type_id'] = $ais_data['typeid'];
660
+				}
661
+				if (isset($ais_data['imo'])) {
662
+					$data['imo'] = $ais_data['imo'];
663
+				}
664
+				if (isset($ais_data['callsign'])) {
665
+					$data['callsign'] = $ais_data['callsign'];
666
+				}
667
+				if (isset($ais_data['destination'])) {
668
+					$data['arrival_code'] = $ais_data['destination'];
669
+				}
670
+				if (isset($ais_data['eta_ts'])) {
671
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
672
+				}
481 673
 				if (isset($ais_data['timestamp'])) {
482 674
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
483 675
 				} else {
@@ -485,18 +677,27 @@  discard block
 block discarded – undo
485 677
 				}
486 678
 				$data['format_source'] = 'aisnmeahttp';
487 679
 				$data['id_source'] = $id_source;
488
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
489
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
680
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
681
+					$data['noarchive'] = true;
682
+				}
683
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
684
+					$MI->add($data);
685
+				}
490 686
 				unset($data);
491 687
 			    }
492 688
 			}
493 689
 		    }
494 690
 		} else {
495 691
 		    $format = $value['format'];
496
-		    if (isset($tt[$format])) $tt[$format]++;
497
-		    else $tt[$format] = 0;
692
+		    if (isset($tt[$format])) {
693
+		    	$tt[$format]++;
694
+		    } else {
695
+		    	$tt[$format] = 0;
696
+		    }
498 697
 		    if ($tt[$format] > 30) {
499
-			if ($globalDebug) echo 'Reconnect...'."\n";
698
+			if ($globalDebug) {
699
+				echo 'Reconnect...'."\n";
700
+			}
500 701
 			sleep(2);
501 702
 			$sourceeen[] = $value;
502 703
 			connect_all($sourceeen);
@@ -526,7 +727,9 @@  discard block
 block discarded – undo
526 727
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
527 728
 			    $data['format_source'] = 'myshiptracking';
528 729
 			    $data['id_source'] = $id_source;
529
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
730
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
731
+			    	$data['noarchive'] = true;
732
+			    }
530 733
 			    $MI->add($data);
531 734
 			    unset($data);
532 735
 			}
@@ -546,7 +749,9 @@  discard block
 block discarded – undo
546 749
 			    $data['callsign'] = $line['callsign'];
547 750
 			    $data['mmsi'] = $line['mmsi'];
548 751
 			    $data['speed'] = $line['sog'];
549
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
752
+			    if ($line['heading'] != '511') {
753
+			    	$data['heading'] = $line['heading'];
754
+			    }
550 755
 			    $data['latitude'] = $line['latitude'];
551 756
 			    $data['longitude'] = $line['longitude'];
552 757
 			    $data['type_id'] = $line['shiptype'];
@@ -554,7 +759,9 @@  discard block
 block discarded – undo
554 759
 			    $data['datetime'] = $line['time'];
555 760
 			    $data['format_source'] = 'boatbeaconapp';
556 761
 			    $data['id_source'] = $id_source;
557
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
762
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
763
+			    	$data['noarchive'] = true;
764
+			    }
558 765
 			    $MI->add($data);
559 766
 			    unset($data);
560 767
 			}
@@ -570,22 +777,44 @@  discard block
 block discarded – undo
570 777
 		if (isset($all_data['features'][0]['id'])) {
571 778
 		    foreach ($all_data['features'] as $line) {
572 779
 			$data = array();
573
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
574
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
575
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi'];
576
-			if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo'];
577
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
578
-			if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading'];
780
+			if (isset($line['properties']['name'])) {
781
+				$data['ident'] = $line['properties']['name'];
782
+			}
783
+			if (isset($line['properties']['callsign'])) {
784
+				$data['callsign'] = $line['properties']['callsign'];
785
+			}
786
+			if (isset($line['properties']['mmsi'])) {
787
+				$data['mmsi'] = $line['properties']['mmsi'];
788
+			}
789
+			if (isset($line['properties']['imo'])) {
790
+				$data['mmsi'] = $line['properties']['imo'];
791
+			}
792
+			if (isset($line['properties']['speed'])) {
793
+				$data['speed'] = $line['properties']['speed'];
794
+			}
795
+			if (isset($line['properties']['heading'])) {
796
+				$data['heading'] = $line['properties']['heading'];
797
+			}
579 798
 			$data['latitude'] = $line['geometry']['coordinates'][1];
580 799
 			$data['longitude'] = $line['geometry']['coordinates'][0];
581
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
582
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
583
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
800
+			if (isset($line['properties']['vesselType'])) {
801
+				$data['type'] = $line['properties']['vesselType'];
802
+			}
803
+			if (isset($line['properties']['destination'])) {
804
+				$data['arrival_code'] = $line['properties']['destination'];
805
+			}
806
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
807
+				$data['arrival_date'] = $line['properties']['eta'];
808
+			}
584 809
 			$data['format_source'] = 'boatnerd';
585 810
 			$data['id_source'] = $id_source;
586 811
 			$data['datetime'] = date('Y-m-d H:i:s');
587
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
588
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
812
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
813
+				$data['noarchive'] = true;
814
+			}
815
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
816
+				$MI->add($data);
817
+			}
589 818
 			unset($data);
590 819
 		    }
591 820
 		}
@@ -596,7 +825,9 @@  discard block
 block discarded – undo
596 825
 	    echo 'download...';
597 826
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
598 827
 	    echo 'done !'."\n";
599
-	    if ($buffer != '') $reset = 0;
828
+	    if ($buffer != '') {
829
+	    	$reset = 0;
830
+	    }
600 831
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
601 832
 	    $buffer = explode('\n',$buffer);
602 833
 	    foreach ($buffer as $line) {
@@ -621,7 +852,9 @@  discard block
 block discarded – undo
621 852
 		    //$data['etaTime'] = substr($line,135,5);
622 853
 		    $data['format_source'] = 'shipplotter';
623 854
     		    $data['id_source'] = $id_source;
624
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
855
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
856
+		    	$data['noarchive'] = true;
857
+		    }
625 858
 		    //print_r($data);
626 859
 		    echo 'Add...'."\n";
627 860
 		    $MI->add($data);
@@ -641,16 +874,28 @@  discard block
 block discarded – undo
641 874
     		    $line = explode(':', $line);
642 875
     		    if (count($line) > 30 && $line[0] != 'callsign') {
643 876
 			$data = array();
644
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
645
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
877
+			if (isset($line[37]) && $line[37] != '') {
878
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
879
+			} else {
880
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
881
+			}
646 882
 			$data['pilot_id'] = $line[1];
647 883
 			$data['pilot_name'] = $line[2];
648 884
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
649 885
 			$data['ident'] = $line[0]; // ident
650
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
886
+			if ($line[7] != '' && $line[7] != 0) {
887
+				$data['altitude'] = $line[7];
888
+			}
889
+			// altitude
651 890
 			$data['speed'] = $line[8]; // speed
652
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
653
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
891
+			if (isset($line[45])) {
892
+				$data['heading'] = $line[45];
893
+			}
894
+			// heading
895
+			elseif (isset($line[38])) {
896
+				$data['heading'] = $line[38];
897
+			}
898
+			// heading
654 899
 			$data['latitude'] = $line[5]; // lat
655 900
 	        	$data['longitude'] = $line[6]; // long
656 901
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -666,7 +911,9 @@  discard block
 block discarded – undo
666 911
 			$data['frequency'] = $line[4];
667 912
 			$data['type'] = $line[18];
668 913
 			$data['range'] = $line[19];
669
-			if (isset($line[35])) $data['info'] = $line[35];
914
+			if (isset($line[35])) {
915
+				$data['info'] = $line[35];
916
+			}
670 917
     			$data['id_source'] = $id_source;
671 918
 	    		//$data['arrival_airport_time'] = ;
672 919
 	    		if ($line[9] != '') {
@@ -680,27 +927,47 @@  discard block
 block discarded – undo
680 927
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
681 928
 	    		*/
682 929
 	    		$data['format_source'] = $value['format'];
683
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
684
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
685
-    			if ($line[3] == 'PILOT') $SI->add($data);
686
-			elseif ($line[3] == 'ATC') {
930
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
931
+				$data['noarchive'] = true;
932
+			}
933
+			if (isset($value['name']) && $value['name'] != '') {
934
+				$data['source_name'] = $value['name'];
935
+			}
936
+    			if ($line[3] == 'PILOT') {
937
+    				$SI->add($data);
938
+    			} elseif ($line[3] == 'ATC') {
687 939
 				//print_r($data);
688 940
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
689 941
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
690 942
 				$typec = substr($data['ident'],-3);
691
-				if ($typec == 'APP') $data['type'] = 'Approach';
692
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
693
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
694
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
695
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
696
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
697
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
698
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
699
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
700
-				if (!isset($data['source_name'])) $data['source_name'] = '';
943
+				if ($typec == 'APP') {
944
+					$data['type'] = 'Approach';
945
+				} elseif ($typec == 'TWR') {
946
+					$data['type'] = 'Tower';
947
+				} elseif ($typec == 'OBS') {
948
+					$data['type'] = 'Observer';
949
+				} elseif ($typec == 'GND') {
950
+					$data['type'] = 'Ground';
951
+				} elseif ($typec == 'DEL') {
952
+					$data['type'] = 'Delivery';
953
+				} elseif ($typec == 'DEP') {
954
+					$data['type'] = 'Departure';
955
+				} elseif ($typec == 'FSS') {
956
+					$data['type'] = 'Flight Service Station';
957
+				} elseif ($typec == 'CTR') {
958
+					$data['type'] = 'Control Radar or Centre';
959
+				} elseif ($data['type'] == '') {
960
+					$data['type'] = 'Observer';
961
+				}
962
+				if (!isset($data['source_name'])) {
963
+					$data['source_name'] = '';
964
+				}
701 965
 				if (isset($ATC)) {
702
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
703
-					else 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'],$data['format_source'],$data['source_name']);
966
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
967
+						echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
968
+					} else {
969
+						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'],$data['format_source'],$data['source_name']);
970
+					}
704 971
 				}
705 972
 			}
706 973
     			unset($data);
@@ -722,14 +989,20 @@  discard block
 block discarded – undo
722 989
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
723 990
 			$data['latitude'] = (float)$line['pktLatitude'];
724 991
 			$data['longitude'] = (float)$line['pktLongitude'];
725
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
726
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
992
+			if ((float)$line['pktTrack'] != 0) {
993
+				$data['heading'] = (float)$line['pktTrack'];
994
+			}
995
+			if ((int)$line['pktSpeed'] != 0) {
996
+				$data['speed'] = (int)$line['pktSpeed'];
997
+			}
727 998
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
728 999
 			$data['altitude_relative'] = 'AMSL';
729 1000
 			$data['pilot_id'] = (int)$line['pktPilotID'];
730 1001
 			$data['aircraft_icao'] = 'PARAGLIDER';
731 1002
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
732
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1003
+			if (isset($pilot_data[4])) {
1004
+				$data['pilot_name'] = $pilot_data[4];
1005
+			}
733 1006
 			$data['format_source'] = $value['format'];
734 1007
 			$SI->add($data);
735 1008
 			unset($data);
@@ -766,27 +1039,61 @@  discard block
 block discarded – undo
766 1039
 		foreach ($all_data['acList'] as $line) {
767 1040
 		    $data = array();
768 1041
 		    $data['hex'] = $line['Icao']; // hex
769
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
770
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
771
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
772
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
773
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
774
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1042
+		    if (isset($line['Call'])) {
1043
+		    	$data['ident'] = $line['Call'];
1044
+		    }
1045
+		    // ident
1046
+		    if (isset($line['Alt'])) {
1047
+		    	$data['altitude'] = $line['Alt'];
1048
+		    }
1049
+		    // altitude
1050
+		    if (isset($line['Spd'])) {
1051
+		    	$data['speed'] = $line['Spd'];
1052
+		    }
1053
+		    // speed
1054
+		    if (isset($line['Trak'])) {
1055
+		    	$data['heading'] = $line['Trak'];
1056
+		    }
1057
+		    // heading
1058
+		    if (isset($line['Lat'])) {
1059
+		    	$data['latitude'] = $line['Lat'];
1060
+		    }
1061
+		    // lat
1062
+		    if (isset($line['Long'])) {
1063
+		    	$data['longitude'] = $line['Long'];
1064
+		    }
1065
+		    // long
775 1066
 		    //$data['verticalrate'] = $line['']; // verticale rate
776
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1067
+		    if (isset($line['Sqk'])) {
1068
+		    	$data['squawk'] = $line['Sqk'];
1069
+		    }
1070
+		    // squawk
777 1071
 		    $data['emergency'] = ''; // emergency
778
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1072
+		    if (isset($line['Reg'])) {
1073
+		    	$data['registration'] = $line['Reg'];
1074
+		    }
779 1075
 		    
780
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
781
-		    else $data['datetime'] = date('Y-m-d H:i:s');
1076
+		    if (isset($line['PosTime'])) {
1077
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1078
+		    } else {
1079
+		    	$data['datetime'] = date('Y-m-d H:i:s');
1080
+		    }
782 1081
 		    
783 1082
 		    //$data['datetime'] = date('Y-m-d H:i:s');
784
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1083
+		    if (isset($line['Type'])) {
1084
+		    	$data['aircraft_icao'] = $line['Type'];
1085
+		    }
785 1086
 	    	    $data['format_source'] = 'aircraftlistjson';
786 1087
 		    $data['id_source'] = $id_source;
787
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
788
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
789
-		    if (isset($data['latitude'])) $SI->add($data);
1088
+		    if (isset($value['name']) && $value['name'] != '') {
1089
+		    	$data['source_name'] = $value['name'];
1090
+		    }
1091
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1092
+		    	$data['noarchive'] = true;
1093
+		    }
1094
+		    if (isset($data['latitude'])) {
1095
+		    	$SI->add($data);
1096
+		    }
790 1097
 		    unset($data);
791 1098
 		}
792 1099
 	    } elseif (is_array($all_data)) {
@@ -803,12 +1110,19 @@  discard block
 block discarded – undo
803 1110
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
804 1111
 		    $data['squawk'] = $line['squawk']; // squawk
805 1112
 		    $data['emergency'] = ''; // emergency
806
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
807
-		    else $data['datetime'] = date('Y-m-d H:i:s');
1113
+		    if (isset($line['PosTime'])) {
1114
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1115
+		    } else {
1116
+		    	$data['datetime'] = date('Y-m-d H:i:s');
1117
+		    }
808 1118
 	    	    $data['format_source'] = 'aircraftlistjson';
809 1119
     		    $data['id_source'] = $id_source;
810
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
811
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1120
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1121
+		    	$data['noarchive'] = true;
1122
+		    }
1123
+		    if (isset($value['name']) && $value['name'] != '') {
1124
+		    	$data['source_name'] = $value['name'];
1125
+		    }
812 1126
 		    $SI->add($data);
813 1127
 		    unset($data);
814 1128
 		}
@@ -844,8 +1158,12 @@  discard block
 block discarded – undo
844 1158
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
845 1159
 	    	    $data['format_source'] = 'planeupdatefaa';
846 1160
     		    $data['id_source'] = $id_source;
847
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
848
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1161
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1162
+		    	$data['noarchive'] = true;
1163
+		    }
1164
+		    if (isset($value['name']) && $value['name'] != '') {
1165
+		    	$data['source_name'] = $value['name'];
1166
+		    }
849 1167
 		    $SI->add($data);
850 1168
 		    unset($data);
851 1169
 		}
@@ -874,7 +1192,9 @@  discard block
 block discarded – undo
874 1192
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
875 1193
 	    	    $data['format_source'] = 'opensky';
876 1194
     		    $data['id_source'] = $id_source;
877
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1195
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1196
+		    	$data['noarchive'] = true;
1197
+		    }
878 1198
 		    $SI->add($data);
879 1199
 		    unset($data);
880 1200
 		}
@@ -886,7 +1206,9 @@  discard block
 block discarded – undo
886 1206
 	    //$buffer = $Common->getData($hosts[$id]);
887 1207
 	    $buffer = $Common->getData($value['host']);
888 1208
 	    $all_data = json_decode($buffer,true);
889
-	    if (!empty($all_data)) $reset = 0;
1209
+	    if (!empty($all_data)) {
1210
+	    	$reset = 0;
1211
+	    }
890 1212
 	    foreach ($all_data as $key => $line) {
891 1213
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
892 1214
 		    $data = array();
@@ -907,8 +1229,12 @@  discard block
 block discarded – undo
907 1229
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
908 1230
 	    	    $data['format_source'] = 'fr24json';
909 1231
     		    $data['id_source'] = $id_source;
910
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
911
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1232
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1233
+		    	$data['noarchive'] = true;
1234
+		    }
1235
+		    if (isset($value['name']) && $value['name'] != '') {
1236
+		    	$data['source_name'] = $value['name'];
1237
+		    }
912 1238
 		    $SI->add($data);
913 1239
 		    unset($data);
914 1240
 		}
@@ -932,24 +1258,42 @@  discard block
 block discarded – undo
932 1258
 		    if (isset($line['inf'])) {
933 1259
 			$data = array();
934 1260
 			$data['hex'] = $line['inf']['ia'];
935
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1261
+			if (isset($line['inf']['cs'])) {
1262
+				$data['ident'] = $line['inf']['cs'];
1263
+			}
1264
+			//$line[13]
936 1265
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
937
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
938
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1266
+	    		if (isset($line['inf']['gs'])) {
1267
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1268
+	    		}
1269
+	    		// speed
1270
+	    		if (isset($line['inf']['tr'])) {
1271
+	    			$data['heading'] = $line['inf']['tr'];
1272
+	    		}
1273
+	    		// heading
939 1274
 	    		$data['latitude'] = $line['pt'][0]; // lat
940 1275
 	    		$data['longitude'] = $line['pt'][1]; // long
941 1276
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
942
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1277
+	    		if (isset($line['inf']['sq'])) {
1278
+	    			$data['squawk'] = $line['inf']['sq'];
1279
+	    		}
1280
+	    		// squawk
943 1281
 	    		//$data['aircraft_icao'] = $line[8];
944
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1282
+	    		if (isset($line['inf']['rc'])) {
1283
+	    			$data['registration'] = $line['inf']['rc'];
1284
+	    		}
945 1285
 			//$data['departure_airport_iata'] = $line[11];
946 1286
 			//$data['arrival_airport_iata'] = $line[12];
947 1287
 	    		//$data['emergency'] = ''; // emergency
948 1288
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
949 1289
 	    		$data['format_source'] = 'radarvirtueljson';
950 1290
     			$data['id_source'] = $id_source;
951
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
952
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1291
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1292
+				$data['noarchive'] = true;
1293
+			}
1294
+			if (isset($value['name']) && $value['name'] != '') {
1295
+				$data['source_name'] = $value['name'];
1296
+			}
953 1297
 			$SI->add($data);
954 1298
 			unset($data);
955 1299
 		    }
@@ -970,30 +1314,65 @@  discard block
 block discarded – undo
970 1314
 		    $data['id'] = $line['id'];
971 1315
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
972 1316
 		    $data['ident'] = $line['callsign']; // ident
973
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
974
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
975
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
976
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
977
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
978
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1317
+		    if (isset($line['pilotid'])) {
1318
+		    	$data['pilot_id'] = $line['pilotid'];
1319
+		    }
1320
+		    // pilot id
1321
+		    if (isset($line['name'])) {
1322
+		    	$data['pilot_name'] = $line['name'];
1323
+		    }
1324
+		    // pilot name
1325
+		    if (isset($line['alt'])) {
1326
+		    	$data['altitude'] = $line['alt'];
1327
+		    }
1328
+		    // altitude
1329
+		    if (isset($line['gs'])) {
1330
+		    	$data['speed'] = $line['gs'];
1331
+		    }
1332
+		    // speed
1333
+		    if (isset($line['heading'])) {
1334
+		    	$data['heading'] = $line['heading'];
1335
+		    }
1336
+		    // heading
1337
+		    if (isset($line['route'])) {
1338
+		    	$data['waypoints'] = $line['route'];
1339
+		    }
1340
+		    // route
979 1341
 		    $data['latitude'] = $line['lat']; // lat
980 1342
 		    $data['longitude'] = $line['lon']; // long
981 1343
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
982 1344
 		    //$data['squawk'] = $line['squawk']; // squawk
983 1345
 		    //$data['emergency'] = ''; // emergency
984
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
985
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
986
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1346
+		    if (isset($line['depicao'])) {
1347
+		    	$data['departure_airport_icao'] = $line['depicao'];
1348
+		    }
1349
+		    if (isset($line['deptime'])) {
1350
+		    	$data['departure_airport_time'] = $line['deptime'];
1351
+		    }
1352
+		    if (isset($line['arricao'])) {
1353
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1354
+		    }
987 1355
 		    //$data['arrival_airport_time'] = $line['arrtime'];
988
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
989
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
990
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
991
-		    else $data['info'] = '';
1356
+		    if (isset($line['aircraft'])) {
1357
+		    	$data['aircraft_icao'] = $line['aircraft'];
1358
+		    }
1359
+		    if (isset($line['transponder'])) {
1360
+		    	$data['squawk'] = $line['transponder'];
1361
+		    }
1362
+		    if (isset($line['atis'])) {
1363
+		    	$data['info'] = $line['atis'];
1364
+		    } else {
1365
+		    	$data['info'] = '';
1366
+		    }
992 1367
 		    $data['format_source'] = 'pireps';
993 1368
     		    $data['id_source'] = $id_source;
994 1369
 		    $data['datetime'] = date('Y-m-d H:i:s');
995
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
996
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1370
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1371
+		    	$data['noarchive'] = true;
1372
+		    }
1373
+		    if (isset($value['name']) && $value['name'] != '') {
1374
+		    	$data['source_name'] = $value['name'];
1375
+		    }
997 1376
 		    if ($line['icon'] == 'plane') {
998 1377
 			$SI->add($data);
999 1378
 		    //    print_r($data);
@@ -1002,16 +1381,28 @@  discard block
 block discarded – undo
1002 1381
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1003 1382
 			$typec = substr($data['ident'],-3);
1004 1383
 			$data['type'] = '';
1005
-			if ($typec == 'APP') $data['type'] = 'Approach';
1006
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
1007
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
1008
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
1009
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
1010
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
1011
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1012
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1013
-			else $data['type'] = 'Observer';
1014
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1384
+			if ($typec == 'APP') {
1385
+				$data['type'] = 'Approach';
1386
+			} elseif ($typec == 'TWR') {
1387
+				$data['type'] = 'Tower';
1388
+			} elseif ($typec == 'OBS') {
1389
+				$data['type'] = 'Observer';
1390
+			} elseif ($typec == 'GND') {
1391
+				$data['type'] = 'Ground';
1392
+			} elseif ($typec == 'DEL') {
1393
+				$data['type'] = 'Delivery';
1394
+			} elseif ($typec == 'DEP') {
1395
+				$data['type'] = 'Departure';
1396
+			} elseif ($typec == 'FSS') {
1397
+				$data['type'] = 'Flight Service Station';
1398
+			} elseif ($typec == 'CTR') {
1399
+				$data['type'] = 'Control Radar or Centre';
1400
+			} else {
1401
+				$data['type'] = 'Observer';
1402
+			}
1403
+			if (isset($ATC)) {
1404
+				echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1405
+			}
1015 1406
 		    }
1016 1407
 		    unset($data);
1017 1408
 		}
@@ -1021,7 +1412,9 @@  discard block
 block discarded – undo
1021 1412
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1022 1413
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1023 1414
 	    //$buffer = $Common->getData($hosts[$id]);
1024
-	    if ($globalDebug) echo 'Get Data...'."\n";
1415
+	    if ($globalDebug) {
1416
+	    	echo 'Get Data...'."\n";
1417
+	    }
1025 1418
 	    $buffer = $Common->getData($value['host']);
1026 1419
 	    $all_data = json_decode($buffer,true);
1027 1420
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1029,10 +1422,16 @@  discard block
 block discarded – undo
1029 1422
 		foreach ($all_data as $line) {
1030 1423
 	    	    $data = array();
1031 1424
 	    	    //$data['id'] = $line['id']; // id not usable
1032
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1425
+	    	    if (isset($line['pilotid'])) {
1426
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1427
+	    	    }
1033 1428
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1034
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1035
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1429
+	    	    if (isset($line['pilotname'])) {
1430
+	    	    	$data['pilot_name'] = $line['pilotname'];
1431
+	    	    }
1432
+	    	    if (isset($line['pilotid'])) {
1433
+	    	    	$data['pilot_id'] = $line['pilotid'];
1434
+	    	    }
1036 1435
 	    	    $data['ident'] = $line['flightnum']; // ident
1037 1436
 	    	    $data['altitude'] = $line['alt']; // altitude
1038 1437
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1048,34 +1447,52 @@  discard block
 block discarded – undo
1048 1447
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1049 1448
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1050 1449
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1051
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1450
+	    	    } else {
1451
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1452
+	    	    }
1052 1453
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1053 1454
 	    	    $data['departure_airport_time'] = $line['deptime'];
1054 1455
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
1055 1456
     		    $data['arrival_airport_time'] = $line['arrtime'];
1056 1457
     		    $data['registration'] = $line['aircraft'];
1057
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1058
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1458
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1459
+		    	$data['noarchive'] = true;
1460
+		    }
1461
+		    if (isset($line['route'])) {
1462
+		    	$data['waypoints'] = $line['route'];
1463
+		    }
1464
+		    // route
1059 1465
 		    if (isset($line['aircraftname'])) {
1060 1466
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1061 1467
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1062 1468
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1063
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1064
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1065
-	    		else {
1469
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1470
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1471
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1472
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1473
+	    		} else {
1066 1474
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1067
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1068
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1475
+	    		    if (isset($aircraft_data[1])) {
1476
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1477
+	    		    } else {
1478
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1479
+	    		    }
1069 1480
 	    		}
1070 1481
 	    	    }
1071
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1482
+    		    if (isset($line['route'])) {
1483
+    		    	$data['waypoints'] = $line['route'];
1484
+    		    }
1072 1485
     		    $data['id_source'] = $id_source;
1073 1486
 	    	    $data['format_source'] = 'phpvmacars';
1074
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1487
+		    if (isset($value['name']) && $value['name'] != '') {
1488
+		    	$data['source_name'] = $value['name'];
1489
+		    }
1075 1490
 		    $SI->add($data);
1076 1491
 		    unset($data);
1077 1492
 		}
1078
-		if ($globalDebug) echo 'No more data...'."\n";
1493
+		if ($globalDebug) {
1494
+			echo 'No more data...'."\n";
1495
+		}
1079 1496
 		unset($buffer);
1080 1497
 		unset($all_data);
1081 1498
 	    }
@@ -1083,7 +1500,9 @@  discard block
 block discarded – undo
1083 1500
     	    $last_exec[$id]['last'] = time();
1084 1501
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1085 1502
 	    //$buffer = $Common->getData($hosts[$id]);
1086
-	    if ($globalDebug) echo 'Get Data...'."\n";
1503
+	    if ($globalDebug) {
1504
+	    	echo 'Get Data...'."\n";
1505
+	    }
1087 1506
 	    $buffer = $Common->getData($value['host']);
1088 1507
 	    $all_data = json_decode($buffer,true);
1089 1508
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1112,16 +1531,25 @@  discard block
 block discarded – undo
1112 1531
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1113 1532
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1114 1533
     		    //$data['registration'] = $line['aircraft'];
1115
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1534
+		    if (isset($line['route'])) {
1535
+		    	$data['waypoints'] = $line['route'];
1536
+		    }
1537
+		    // route
1116 1538
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1117 1539
     		    $data['id_source'] = $id_source;
1118 1540
 	    	    $data['format_source'] = 'vam';
1119
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1120
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1541
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1542
+		    	$data['noarchive'] = true;
1543
+		    }
1544
+		    if (isset($value['name']) && $value['name'] != '') {
1545
+		    	$data['source_name'] = $value['name'];
1546
+		    }
1121 1547
 		    $SI->add($data);
1122 1548
 		    unset($data);
1123 1549
 		}
1124
-		if ($globalDebug) echo 'No more data...'."\n";
1550
+		if ($globalDebug) {
1551
+			echo 'No more data...'."\n";
1552
+		}
1125 1553
 		unset($buffer);
1126 1554
 		unset($all_data);
1127 1555
 	    }
@@ -1129,7 +1557,9 @@  discard block
 block discarded – undo
1129 1557
     	    $last_exec[$id]['last'] = time();
1130 1558
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1131 1559
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1132
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1560
+	    if (function_exists('pcntl_fork')) {
1561
+	    	pcntl_signal_dispatch();
1562
+	    }
1133 1563
     	    //$last_exec[$id]['last'] = time();
1134 1564
 
1135 1565
 	    //$read = array( $sockets[$id] );
@@ -1137,7 +1567,9 @@  discard block
 block discarded – undo
1137 1567
 	    $write = NULL;
1138 1568
 	    $e = NULL;
1139 1569
 	    $n = socket_select($read, $write, $e, $timeout);
1140
-	    if ($e != NULL) var_dump($e);
1570
+	    if ($e != NULL) {
1571
+	    	var_dump($e);
1572
+	    }
1141 1573
 	    if ($n > 0) {
1142 1574
 		$reset = 0;
1143 1575
 		foreach ($read as $nb => $r) {
@@ -1158,12 +1590,16 @@  discard block
 block discarded – undo
1158 1590
 		    //$SI::del();
1159 1591
 		    if ($format == 'vrstcp') {
1160 1592
 			$buffer = explode('},{',$buffer);
1161
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1593
+		    } else {
1594
+		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1595
+		    }
1162 1596
 		    // SBS format is CSV format
1163 1597
 		    if ($buffer !== FALSE && $buffer != '') {
1164 1598
 			$tt[$format] = 0;
1165 1599
 			if ($format == 'acarssbs3') {
1166
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1600
+			    if ($globalDebug) {
1601
+			    	echo 'ACARS : '.$buffer."\n";
1602
+			    }
1167 1603
 			    $ACARS->add(trim($buffer));
1168 1604
 			    $ACARS->deleteLiveAcarsData();
1169 1605
 			} elseif ($format == 'raw') {
@@ -1172,30 +1608,70 @@  discard block
 block discarded – undo
1172 1608
 			    if (is_array($data)) {
1173 1609
 				$data['datetime'] = date('Y-m-d H:i:s');
1174 1610
 				$data['format_source'] = 'raw';
1175
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1176
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1177
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1178
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1611
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1612
+					$data['source_name'] = $globalSources[$nb]['name'];
1613
+				}
1614
+				if (isset($globalSources[$nb]['sourcestats'])) {
1615
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1616
+				}
1617
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1618
+					$data['noarchive'] = true;
1619
+				}
1620
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1621
+					$SI->add($data);
1622
+				}
1179 1623
 			    }
1180 1624
 			} elseif ($format == 'ais') {
1181 1625
 			    $ais_data = $AIS->parse_line(trim($buffer));
1182 1626
 			    $data = array();
1183
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1184
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1185
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1186
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1187
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1188
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1189
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1190
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1191
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1192
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1193
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1194
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1195
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1196
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1197
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1198
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1627
+			    if (isset($ais_data['ident'])) {
1628
+			    	$data['ident'] = $ais_data['ident'];
1629
+			    }
1630
+			    if (isset($ais_data['mmsi'])) {
1631
+			    	$data['mmsi'] = $ais_data['mmsi'];
1632
+			    }
1633
+			    if (isset($ais_data['speed'])) {
1634
+			    	$data['speed'] = $ais_data['speed'];
1635
+			    }
1636
+			    if (isset($ais_data['heading'])) {
1637
+			    	$data['heading'] = $ais_data['heading'];
1638
+			    }
1639
+			    if (isset($ais_data['latitude'])) {
1640
+			    	$data['latitude'] = $ais_data['latitude'];
1641
+			    }
1642
+			    if (isset($ais_data['longitude'])) {
1643
+			    	$data['longitude'] = $ais_data['longitude'];
1644
+			    }
1645
+			    if (isset($ais_data['status'])) {
1646
+			    	$data['status'] = $ais_data['status'];
1647
+			    }
1648
+			    if (isset($ais_data['statusid'])) {
1649
+			    	$data['status_id'] = $ais_data['statusid'];
1650
+			    }
1651
+			    if (isset($ais_data['type'])) {
1652
+			    	$data['type'] = $ais_data['type'];
1653
+			    }
1654
+			    if (isset($ais_data['imo'])) {
1655
+			    	$data['imo'] = $ais_data['imo'];
1656
+			    }
1657
+			    if (isset($ais_data['callsign'])) {
1658
+			    	$data['callsign'] = $ais_data['callsign'];
1659
+			    }
1660
+			    if (isset($ais_data['destination'])) {
1661
+			    	$data['arrival_code'] = $ais_data['destination'];
1662
+			    }
1663
+			    if (isset($ais_data['eta_ts'])) {
1664
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1665
+			    }
1666
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1667
+			    	$data['noarchive'] = true;
1668
+			    }
1669
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1670
+			    	$data['source_name'] = $globalSources[$nb]['name'];
1671
+			    }
1672
+			    if (isset($globalSources[$nb]['sourcestats'])) {
1673
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1674
+			    }
1199 1675
 
1200 1676
 			    if (isset($ais_data['timestamp'])) {
1201 1677
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1204,7 +1680,9 @@  discard block
 block discarded – undo
1204 1680
 			    }
1205 1681
 			    $data['format_source'] = 'aisnmea';
1206 1682
     			    $data['id_source'] = $id_source;
1207
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1683
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1684
+			    	$MI->add($data);
1685
+			    }
1208 1686
 			    unset($data);
1209 1687
                         } elseif ($format == 'flightgearsp') {
1210 1688
                     	    //echo $buffer."\n";
@@ -1222,12 +1700,18 @@  discard block
 block discarded – undo
1222 1700
 				$data['speed'] = round($line[5]*1.94384);
1223 1701
 				$data['datetime'] = date('Y-m-d H:i:s');
1224 1702
 				$data['format_source'] = 'flightgearsp';
1225
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1226
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1703
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1704
+					$data['noarchive'] = true;
1705
+				}
1706
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1707
+					$SI->add($data);
1708
+				}
1227 1709
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1228 1710
 			    }
1229 1711
                         } elseif ($format == 'acars') {
1230
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1712
+                    	    if ($globalDebug) {
1713
+                    	    	echo 'ACARS : '.$buffer."\n";
1714
+                    	    }
1231 1715
 			    $ACARS->add(trim($buffer));
1232 1716
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1233 1717
 			    $ACARS->deleteLiveAcarsData();
@@ -1248,8 +1732,12 @@  discard block
 block discarded – undo
1248 1732
 				    $aircraft_type = $line[10];
1249 1733
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1250 1734
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1251
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1252
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1735
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1736
+				    	$data['noarchive'] = true;
1737
+				    }
1738
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1739
+				    	$SI->add($data);
1740
+				    }
1253 1741
 				}
1254 1742
 			    }
1255 1743
 			} elseif ($format == 'beast') {
@@ -1259,28 +1747,62 @@  discard block
 block discarded – undo
1259 1747
 			    foreach($buffer as $all_data) {
1260 1748
 				$line = json_decode('{'.$all_data.'}',true);
1261 1749
 				$data = array();
1262
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1263
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1264
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1265
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1266
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1267
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1268
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1750
+				if (isset($line['Icao'])) {
1751
+					$data['hex'] = $line['Icao'];
1752
+				}
1753
+				// hex
1754
+				if (isset($line['Call'])) {
1755
+					$data['ident'] = $line['Call'];
1756
+				}
1757
+				// ident
1758
+				if (isset($line['Alt'])) {
1759
+					$data['altitude'] = $line['Alt'];
1760
+				}
1761
+				// altitude
1762
+				if (isset($line['Spd'])) {
1763
+					$data['speed'] = $line['Spd'];
1764
+				}
1765
+				// speed
1766
+				if (isset($line['Trak'])) {
1767
+					$data['heading'] = $line['Trak'];
1768
+				}
1769
+				// heading
1770
+				if (isset($line['Lat'])) {
1771
+					$data['latitude'] = $line['Lat'];
1772
+				}
1773
+				// lat
1774
+				if (isset($line['Long'])) {
1775
+					$data['longitude'] = $line['Long'];
1776
+				}
1777
+				// long
1269 1778
 				//$data['verticalrate'] = $line['']; // verticale rate
1270
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1779
+				if (isset($line['Sqk'])) {
1780
+					$data['squawk'] = $line['Sqk'];
1781
+				}
1782
+				// squawk
1271 1783
 				$data['emergency'] = ''; // emergency
1272
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1784
+				if (isset($line['Reg'])) {
1785
+					$data['registration'] = $line['Reg'];
1786
+				}
1273 1787
 				/*
1274 1788
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1275 1789
 				else $data['datetime'] = date('Y-m-d H:i:s');
1276 1790
 				*/
1277 1791
 				$data['datetime'] = date('Y-m-d H:i:s');
1278
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1792
+				if (isset($line['Type'])) {
1793
+					$data['aircraft_icao'] = $line['Type'];
1794
+				}
1279 1795
 		    		$data['format_source'] = 'vrstcp';
1280 1796
 				$data['id_source'] = $id_source;
1281
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1282
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1283
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1797
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1798
+					$data['noarchive'] = true;
1799
+				}
1800
+				if (isset($value['name']) && $value['name'] != '') {
1801
+					$data['source_name'] = $value['name'];
1802
+				}
1803
+				if (isset($data['latitude']) && isset($data['hex'])) {
1804
+					$SI->add($data);
1805
+				}
1284 1806
 				unset($data);
1285 1807
 			    }
1286 1808
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1293,22 +1815,46 @@  discard block
 block discarded – undo
1293 1815
     				$data['hex'] = $lined['hexid'];
1294 1816
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1295 1817
     				$data['datetime'] = date('Y-m-d H:i:s');;
1296
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1297
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1298
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1299
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1300
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1301
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1302
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1818
+    				if (isset($lined['ident'])) {
1819
+    					$data['ident'] = $lined['ident'];
1820
+    				}
1821
+    				if (isset($lined['lat'])) {
1822
+    					$data['latitude'] = $lined['lat'];
1823
+    				}
1824
+    				if (isset($lined['lon'])) {
1825
+    					$data['longitude'] = $lined['lon'];
1826
+    				}
1827
+    				if (isset($lined['speed'])) {
1828
+    					$data['speed'] = $lined['speed'];
1829
+    				}
1830
+    				if (isset($lined['squawk'])) {
1831
+    					$data['squawk'] = $lined['squawk'];
1832
+    				}
1833
+    				if (isset($lined['alt'])) {
1834
+    					$data['altitude'] = $lined['alt'];
1835
+    				}
1836
+    				if (isset($lined['heading'])) {
1837
+    					$data['heading'] = $lined['heading'];
1838
+    				}
1303 1839
     				$data['id_source'] = $id_source;
1304 1840
     				$data['format_source'] = 'tsv';
1305
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1306
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1307
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1308
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1841
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1842
+    					$data['source_name'] = $globalSources[$nb]['name'];
1843
+    				}
1844
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1845
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1846
+    				}
1847
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1848
+					$data['noarchive'] = true;
1849
+				}
1850
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1851
+    					$SI->add($data);
1852
+    				}
1309 1853
     				unset($lined);
1310 1854
     				unset($data);
1311
-    			    } else $error = true;
1855
+    			    } else {
1856
+    			    	$error = true;
1857
+    			    }
1312 1858
 			} elseif ($format == 'aprs' && $use_aprs) {
1313 1859
 			    if ($aprs_connect == 0) {
1314 1860
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1333,59 +1879,117 @@  discard block
 block discarded – undo
1333 1879
 				    $aprs_last_tx = time();
1334 1880
 				    $data = array();
1335 1881
 				    //print_r($line);
1336
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1337
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1338
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1339
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1340
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1341
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1342
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1343
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1344
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1345
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1882
+				    if (isset($line['address'])) {
1883
+				    	$data['hex'] = $line['address'];
1884
+				    }
1885
+				    if (isset($line['mmsi'])) {
1886
+				    	$data['mmsi'] = $line['mmsi'];
1887
+				    }
1888
+				    if (isset($line['imo'])) {
1889
+				    	$data['imo'] = $line['imo'];
1890
+				    }
1891
+				    if (isset($line['squawk'])) {
1892
+				    	$data['squawk'] = $line['squawk'];
1893
+				    }
1894
+				    if (isset($line['arrival_code'])) {
1895
+				    	$data['arrical_code'] = $line['arrival_code'];
1896
+				    }
1897
+				    if (isset($line['arrival_date'])) {
1898
+				    	$data['arrical_date'] = $line['arrival_date'];
1899
+				    }
1900
+				    if (isset($line['type_id'])) {
1901
+				    	$data['type_id'] = $line['typeid'];
1902
+				    }
1903
+				    if (isset($line['status_id'])) {
1904
+				    	$data['status_id'] = $line['statusid'];
1905
+				    }
1906
+				    if (isset($line['timestamp'])) {
1907
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1908
+				    } else {
1909
+				    	$data['datetime'] = date('Y-m-d H:i:s');
1910
+				    }
1346 1911
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1347
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1912
+				    if (isset($line['ident'])) {
1913
+				    	$data['ident'] = $line['ident'];
1914
+				    }
1348 1915
 				    $data['latitude'] = $line['latitude'];
1349 1916
 				    $data['longitude'] = $line['longitude'];
1350 1917
 				    //$data['verticalrate'] = $line[16];
1351
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1918
+				    if (isset($line['speed'])) {
1919
+				    	$data['speed'] = $line['speed'];
1920
+				    }
1352 1921
 				    //else $data['speed'] = 0;
1353
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1354
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1355
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1356
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1922
+				    if (isset($line['altitude'])) {
1923
+				    	$data['altitude'] = $line['altitude'];
1924
+				    }
1925
+				    if (isset($line['comment'])) {
1926
+				    	$data['comment'] = $line['comment'];
1927
+				    }
1928
+				    if (isset($line['symbol'])) {
1929
+				    	$data['type'] = $line['symbol'];
1930
+				    }
1931
+				    if (isset($line['heading'])) {
1932
+				    	$data['heading'] = $line['heading'];
1933
+				    }
1357 1934
 				    //else $data['heading'] = 0;
1358
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1935
+				    if (isset($line['stealth'])) {
1936
+				    	$data['aircraft_type'] = $line['stealth'];
1937
+				    }
1359 1938
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1360
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1361
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1362
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1363
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1939
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
1940
+				    	$data['noarchive'] = true;
1941
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
1942
+				    	$data['noarchive'] = false;
1943
+				    }
1944
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1945
+				    	$data['noarchive'] = true;
1946
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
1947
+				    	$data['noarchive'] = false;
1948
+				    }
1364 1949
     				    $data['id_source'] = $id_source;
1365
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1366
-				    else $data['format_source'] = 'aprs';
1950
+    				    if (isset($line['format_source'])) {
1951
+    				    	$data['format_source'] = $line['format_source'];
1952
+    				    } else {
1953
+				    	$data['format_source'] = 'aprs';
1954
+				    }
1367 1955
 				    $data['source_name'] = $line['source'];
1368
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1369
-				    else $data['source_type'] = 'flarm';
1370
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1956
+				    if (isset($line['source_type'])) {
1957
+				    	$data['source_type'] = $line['source_type'];
1958
+				    } else {
1959
+				    	$data['source_type'] = 'flarm';
1960
+				    }
1961
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1962
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1963
+    				    }
1371 1964
 				    $currentdate = date('Y-m-d H:i:s');
1372 1965
 				    $aprsdate = strtotime($data['datetime']);
1373
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1966
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
1967
+				    	$data['altitude_relative'] = 'AMSL';
1968
+				    }
1374 1969
 				    // Accept data if time <= system time + 20s
1375 1970
 				    //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1376 1971
 				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1377 1972
 					$send = $SI->add($data);
1378 1973
 				    } elseif ($data['source_type'] == 'ais') {
1379
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1974
+					if (isset($globalMarine) && $globalMarine) {
1975
+						$send = $MI->add($data);
1976
+					}
1380 1977
 				    } elseif (isset($line['stealth'])) {
1381
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1382
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1978
+					if ($line['stealth'] != 0) {
1979
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1980
+					} else {
1981
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1982
+					}
1383 1983
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1384 1984
 					    //$line['symbol'] == 'Balloon' ||
1385 1985
 					    $line['symbol'] == 'Glider' || 
1386 1986
 					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1387
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1388
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1987
+					    if ($line['symbol'] == 'Ballon') {
1988
+					    	$data['aircraft_icao'] = 'BALL';
1989
+					    }
1990
+					    if ($line['symbol'] == 'Glider') {
1991
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
1992
+					    }
1389 1993
 					    $send = $SI->add($data);
1390 1994
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1391 1995
 					    $line['symbol'] == 'Yacht (Sail)' || 
@@ -1416,9 +2020,13 @@  discard block
 block discarded – undo
1416 2020
 				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1417 2021
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1418 2022
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1419
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2023
+					if (isset($globalTracker) && $globalTracker) {
2024
+						$send = $TI->add($data);
2025
+					}
1420 2026
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1421
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2027
+					if (!isset($data['altitude'])) {
2028
+						$data['altitude'] = 0;
2029
+					}
1422 2030
 					$Source->deleteOldLocationByType('gs');
1423 2031
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1424 2032
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1441,8 +2049,7 @@  discard block
 block discarded – undo
1441 2049
 				    	echo '/!\ Not added: '.$buffer."\n";
1442 2050
 				    	print_r($line);
1443 2051
 				    }
1444
-				}
1445
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2052
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1446 2053
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1447 2054
 				}
1448 2055
 				/*
@@ -1451,7 +2058,9 @@  discard block
 block discarded – undo
1451 2058
 				}
1452 2059
 				*/
1453 2060
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1454
-				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2061
+				elseif ($line == true && $globalDebug) {
2062
+					echo '!! Failed : '.$buffer."!!\n";
2063
+				}
1455 2064
 			    }
1456 2065
 			} else {
1457 2066
 			    $line = explode(',', $buffer);
@@ -1480,26 +2089,45 @@  discard block
 block discarded – undo
1480 2089
     				$data['ground'] = $line[21];
1481 2090
     				$data['emergency'] = $line[19];
1482 2091
     				$data['format_source'] = 'sbs';
1483
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1484
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1485
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2092
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2093
+					$data['source_name'] = $globalSources[$nb]['name'];
2094
+				}
2095
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2096
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2097
+    				}
2098
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2099
+					$data['noarchive'] = true;
2100
+				}
1486 2101
     				$data['id_source'] = $id_source;
1487
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1488
-    				else $error = true;
2102
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2103
+    					$send = $SI->add($data);
2104
+    				} else {
2105
+    					$error = true;
2106
+    				}
1489 2107
     				unset($data);
1490
-    			    } else $error = true;
2108
+    			    } else {
2109
+    			    	$error = true;
2110
+    			    }
1491 2111
 			    if ($error) {
1492 2112
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1493
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2113
+					if ($globalDebug) {
2114
+						echo "Not a message. Ignoring... \n";
2115
+					}
1494 2116
 				} else {
1495
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2117
+					if ($globalDebug) {
2118
+						echo "Wrong line format. Ignoring... \n";
2119
+					}
1496 2120
 					if ($globalDebug) {
1497 2121
 						echo $buffer;
1498 2122
 						//print_r($line);
1499 2123
 					}
1500 2124
 					//socket_close($r);
1501
-					if ($globalDebug) echo "Reconnect after an error...\n";
1502
-					if ($format == 'aprs') $aprs_connect = 0;
2125
+					if ($globalDebug) {
2126
+						echo "Reconnect after an error...\n";
2127
+					}
2128
+					if ($format == 'aprs') {
2129
+						$aprs_connect = 0;
2130
+					}
1503 2131
 					$sourceer[$nb] = $globalSources[$nb];
1504 2132
 					connect_all($sourceer);
1505 2133
 					$sourceer = array();
@@ -1507,10 +2135,14 @@  discard block
 block discarded – undo
1507 2135
 			    }
1508 2136
 			}
1509 2137
 			// Sleep for xxx microseconds
1510
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2138
+			if (isset($globalSBSSleep)) {
2139
+				usleep($globalSBSSleep);
2140
+			}
1511 2141
 		    } else {
1512 2142
 			if ($format == 'flightgearmp') {
1513
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2143
+			    	if ($globalDebug) {
2144
+			    		echo "Reconnect FlightGear MP...";
2145
+			    	}
1514 2146
 				//@socket_close($r);
1515 2147
 				sleep($globalMinFetch);
1516 2148
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1519,10 +2151,15 @@  discard block
 block discarded – undo
1519 2151
 				break;
1520 2152
 				
1521 2153
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1522
-			    if (isset($tt[$format])) $tt[$format]++;
1523
-			    else $tt[$format] = 0;
2154
+			    if (isset($tt[$format])) {
2155
+			    	$tt[$format]++;
2156
+			    } else {
2157
+			    	$tt[$format] = 0;
2158
+			    }
1524 2159
 			    if ($tt[$format] > 30) {
1525
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2160
+				if ($globalDebug) {
2161
+					echo "ERROR : Reconnect ".$format."...";
2162
+				}
1526 2163
 				//@socket_close($r);
1527 2164
 				sleep(2);
1528 2165
 				$aprs_connect = 0;
@@ -1539,11 +2176,17 @@  discard block
 block discarded – undo
1539 2176
 	    } else {
1540 2177
 		$error = socket_strerror(socket_last_error());
1541 2178
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1542
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1543
-			if (isset($globalDebug)) echo "Restarting...\n";
2179
+			if ($globalDebug) {
2180
+				echo "ERROR : socket_select give this error ".$error . "\n";
2181
+			}
2182
+			if (isset($globalDebug)) {
2183
+				echo "Restarting...\n";
2184
+			}
1544 2185
 			// Restart the script if possible
1545 2186
 			if (is_array($sockets)) {
1546
-			    if ($globalDebug) echo "Shutdown all sockets...";
2187
+			    if ($globalDebug) {
2188
+			    	echo "Shutdown all sockets...";
2189
+			    }
1547 2190
 			    
1548 2191
 			    foreach ($sockets as $sock) {
1549 2192
 				@socket_shutdown($sock,2);
@@ -1551,25 +2194,45 @@  discard block
 block discarded – undo
1551 2194
 			    }
1552 2195
 			    
1553 2196
 			}
1554
-			if ($globalDebug) echo "Waiting...";
2197
+			if ($globalDebug) {
2198
+				echo "Waiting...";
2199
+			}
1555 2200
 			sleep(2);
1556 2201
 			$time = time();
1557 2202
 			//connect_all($hosts);
1558 2203
 			$aprs_connect = 0;
1559
-			if ($reset%5 == 0) sleep(20);
1560
-			if ($reset%10 == 0) sleep(100);
1561
-			if ($reset%20 == 0) sleep(200);
1562
-			if ($reset > 100) exit('Too many attempts...');
1563
-			if ($globalDebug) echo "Restart all connections...";
2204
+			if ($reset%5 == 0) {
2205
+				sleep(20);
2206
+			}
2207
+			if ($reset%10 == 0) {
2208
+				sleep(100);
2209
+			}
2210
+			if ($reset%20 == 0) {
2211
+				sleep(200);
2212
+			}
2213
+			if ($reset > 100) {
2214
+				exit('Too many attempts...');
2215
+			}
2216
+			if ($globalDebug) {
2217
+				echo "Restart all connections...";
2218
+			}
1564 2219
 			connect_all($globalSources);
1565 2220
 		}
1566 2221
 	    }
1567 2222
 	}
1568 2223
 	if ($globalDaemon === false) {
1569
-	    if ($globalDebug) echo 'Check all...'."\n";
1570
-	    if (isset($SI)) $SI->checkAll();
1571
-	    if (isset($TI)) $TI->checkAll();
1572
-	    if (isset($MI)) $MI->checkAll();
2224
+	    if ($globalDebug) {
2225
+	    	echo 'Check all...'."\n";
2226
+	    }
2227
+	    if (isset($SI)) {
2228
+	    	$SI->checkAll();
2229
+	    }
2230
+	    if (isset($TI)) {
2231
+	    	$TI->checkAll();
2232
+	    }
2233
+	    if (isset($MI)) {
2234
+	    	$MI->checkAll();
2235
+	    }
1573 2236
 	}
1574 2237
     }
1575 2238
 }
Please login to merge, or discard this patch.
location-geojson.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
 		$coords = explode(',',$_GET['coord']);
16 16
 //		$spotter_array = Source::getAllLocationInfobyCoord($coords);
17 17
 		if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') 
18
-		    || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) {
18
+			|| (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) {
19 19
 			$spotter_array = $Source->getAllLocationInfo();
20 20
 		} else {
21 21
 			$spotter_array = $Source->getLocationInfoByType('');
22 22
 		}
23 23
 	} else {
24 24
 		if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') 
25
-		    || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) {
25
+			|| (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) {
26 26
 			$spotter_array = $Source->getAllLocationInfo();
27 27
 		} else {
28 28
 			$spotter_array = $Source->getLocationInfoByType('');
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		date_default_timezone_set('UTC');
39 39
 		//waypoint plotting
40 40
 		$output .= '{"type": "Feature",';
41
-		    $output .= '"properties": {';
41
+			$output .= '"properties": {';
42 42
 			$output .= '"id": "'.$spotter_item['id'].'",';
43 43
 			$output .= '"location_id": "'.$spotter_item['location_id'].'",';
44 44
 			$output .= '"name": "'.$spotter_item['name'].'",';
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 				if (isset($weather['temp'])) $output.= '"temp": "'.$weather['temp'].'",';
57 57
 			}
58 58
 			$output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"';
59
-		    $output .= '},';
60
-		    $output .= '"geometry": {';
59
+			$output .= '},';
60
+			$output .= '"geometry": {';
61 61
 			$output .= '"type": "Point",';
62 62
 			$output .= '"coordinates": [';
63
-			    $output .= $spotter_item['longitude'].', '.$spotter_item['latitude'];
63
+				$output .= $spotter_item['longitude'].', '.$spotter_item['latitude'];
64 64
 			$output .= ']';
65
-		    $output .= '}';
65
+			$output .= '}';
66 66
 		$output .= '},';
67 67
 	}
68 68
 	$output  = substr($output, 0, -1);
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 if (!isset($globalDemo)) {
13 13
 	if (isset($_GET['coord'])) 
14 14
 	{
15
-		$coords = explode(',',$_GET['coord']);
15
+		$coords = explode(',', $_GET['coord']);
16 16
 //		$spotter_array = Source::getAllLocationInfobyCoord($coords);
17 17
 		if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') 
18 18
 		    || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) {
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 $output = '{"type": "FeatureCollection","features": [';
34 34
 if (!empty($spotter_array) && count($spotter_array) > 0)
35 35
 {
36
-	foreach($spotter_array as $spotter_item)
36
+	foreach ($spotter_array as $spotter_item)
37 37
 	{
38 38
 		date_default_timezone_set('UTC');
39 39
 		//waypoint plotting
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 			$output .= '"icon": "'.$globalURL.'/images/'.$spotter_item['logo'].'",';
53 53
 			$output .= '"type": "'.$spotter_item['type'].'",';
54 54
 			if ($spotter_item['type'] == 'wx') {
55
-				$weather = json_decode($spotter_item['description'],true);
56
-				if (isset($weather['temp'])) $output.= '"temp": "'.$weather['temp'].'",';
55
+				$weather = json_decode($spotter_item['description'], true);
56
+				if (isset($weather['temp'])) $output .= '"temp": "'.$weather['temp'].'",';
57 57
 			}
58 58
 			$output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"';
59 59
 		    $output .= '},';
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 		    $output .= '}';
66 66
 		$output .= '},';
67 67
 	}
68
-	$output  = substr($output, 0, -1);
68
+	$output = substr($output, 0, -1);
69 69
 }
70 70
 $output .= ']}';
71 71
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -5 removed lines patch added patch discarded remove patch
@@ -45,15 +45,18 @@
 block discarded – undo
45 45
 			$output .= '"city": "'.$spotter_item['city'].'",';
46 46
 			$output .= '"country": "'.$spotter_item['country'].'",';
47 47
 			$output .= '"altitude": "'.$spotter_item['altitude'].'",';
48
-			if ($spotter_item['name'] != '' && $spotter_item['city'] != '' && $spotter_item['country'] != '')
49
-				$output .= '"popupContent": "'.$spotter_item['name'].' : '.$spotter_item['city'].', '.$spotter_item['country'].'",';
50
-			elseif ($spotter_item['location_id'] != '')
51
-				$output .= '"popupContent": "'.$spotter_item['location_id'].'",';
48
+			if ($spotter_item['name'] != '' && $spotter_item['city'] != '' && $spotter_item['country'] != '') {
49
+							$output .= '"popupContent": "'.$spotter_item['name'].' : '.$spotter_item['city'].', '.$spotter_item['country'].'",';
50
+			} elseif ($spotter_item['location_id'] != '') {
51
+							$output .= '"popupContent": "'.$spotter_item['location_id'].'",';
52
+			}
52 53
 			$output .= '"icon": "'.$globalURL.'/images/'.$spotter_item['logo'].'",';
53 54
 			$output .= '"type": "'.$spotter_item['type'].'",';
54 55
 			if ($spotter_item['type'] == 'wx') {
55 56
 				$weather = json_decode($spotter_item['description'],true);
56
-				if (isset($weather['temp'])) $output.= '"temp": "'.$weather['temp'].'",';
57
+				if (isset($weather['temp'])) {
58
+					$output.= '"temp": "'.$weather['temp'].'",';
59
+				}
57 60
 			}
58 61
 			$output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"';
59 62
 		    $output .= '},';
Please login to merge, or discard this patch.
index.php 2 patches
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     <?php }; if (isset($globalTracker) && $globalTracker) { ?><td><div id="ibxtracker"><h4><?php echo _("Trackers Detected"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div></td><?php } ?>
46 46
 </tr></table></div>
47 47
 <?php
48
-    if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
48
+	if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
49 49
 
50 50
 ?>
51 51
 <script src="<?php echo $globalURL; ?>/js/map.3d.js.php"></script>
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script>
66 66
 <?php
67 67
 	}
68
-    }
68
+	}
69 69
 ?>
70 70
 
71 71
 <div id="sidebar" class="sidebar collapsed">
@@ -76,34 +76,34 @@  discard block
 block discarded – undo
76 76
 	<li><a href="#" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li>
77 77
 	<li><a href="#" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li>
78 78
 <?php
79
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
79
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
80 80
 	if (isset($globalArchive) && $globalArchive == TRUE) {
81 81
 ?>
82 82
 	<li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li>
83 83
 <?php
84 84
 	}
85
-    }
85
+	}
86 86
 ?>
87 87
 	<li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li>
88 88
 	<li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li>
89 89
 	<li><a href="#settings" role="tab" title="<?php echo _("Settings"); ?>"><i class="fa fa-gears"></i></a></li>
90 90
 <?php
91
-    if (isset($globalMap3D) && $globalMap3D) {
91
+	if (isset($globalMap3D) && $globalMap3D) {
92 92
 	if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
93 93
 ?>
94 94
 	<li><a href="#" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li>
95 95
 <?php
96
-        } else {
97
-    	    if (isset($globalMapSatellites) && $globalMapSatellites) {
96
+		} else {
97
+			if (isset($globalMapSatellites) && $globalMapSatellites) {
98 98
 ?>
99 99
 	<li><a href="#satellites" role="tab" title="<?php echo _("Satellites"); ?>"><i class="satellite"></i></a></li>
100 100
 <?php
101
-	    }
101
+		}
102 102
 ?>
103 103
 	<li><a href="#" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li>
104 104
 <?php
105 105
 	}
106
-    }
106
+	}
107 107
 ?>
108 108
     </ul>
109 109
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 ?>
179 179
         </div>
180 180
 <?php
181
-    if (isset($globalArchive) && $globalArchive == TRUE) {
181
+	if (isset($globalArchive) && $globalArchive == TRUE) {
182 182
 ?>
183 183
         <div class="sidebar-pane" id="archive">
184 184
 	    <h1 class="sidebar-header"><?php echo _("Playback"); ?> <i>Bêta</i><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	    </form>
239 239
 	</div>
240 240
 <?php
241
-    }
241
+	}
242 242
 ?>
243 243
         <div class="sidebar-pane" id="settings">
244 244
 	    <h1 class="sidebar-header"><?php echo _("Settings"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -249,56 +249,56 @@  discard block
 block discarded – undo
249 249
 			    <?php
250 250
 				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
251 251
 				else $MapType = $_COOKIE['MapType'];
252
-			    ?>
252
+				?>
253 253
 			    <?php
254 254
 				if (isset($globalBingMapKey) && $globalBingMapKey != '') {
255
-			    ?>
255
+				?>
256 256
 			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
257 257
 			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
258 258
 			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
259 259
 			    <?php
260 260
 				}
261
-			    ?>
261
+				?>
262 262
 			    <?php
263
-			        if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
264
-			    ?>
263
+					if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
264
+				?>
265 265
 			    <?php
266
-				    if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
267
-			    ?>
266
+					if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
267
+				?>
268 268
 			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
269 269
 			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
270 270
 			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
271 271
 			    <?php
272
-				    }
273
-			    ?>
272
+					}
273
+				?>
274 274
 			    <?php
275
-				    if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
276
-			    ?>
275
+					if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
276
+				?>
277 277
 			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
278 278
 			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
279 279
 			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
280 280
 			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
281 281
 			    <?php
282
-				    }
283
-			    ?>
282
+					}
283
+				?>
284 284
 			    <?php
285
-				    if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
286
-			    ?>
285
+					if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
286
+				?>
287 287
 			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
288 288
 			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
289 289
 			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
290 290
 			    <?php
291
-				    }
292
-			    ?>
291
+					}
292
+				?>
293 293
 			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
294 294
 			    <?php
295 295
 				}
296
-			    ?>
296
+				?>
297 297
 			    <?php
298
-				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
298
+					if (isset($globalMapboxToken) && $globalMapboxToken != '') {
299 299
 					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
300 300
 					else $MapBoxId = $_COOKIE['MapTypeId'];
301
-			    ?>
301
+				?>
302 302
 			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
303 303
 			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
304 304
 			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
@@ -312,13 +312,13 @@  discard block
 block discarded – undo
312 312
 			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
313 313
 			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
314 314
 			    <?php
315
-				    }
316
-			    ?>
315
+					}
316
+				?>
317 317
 			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
318 318
 			</select>
319 319
 		    </li>
320 320
 <?php
321
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
321
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
322 322
 ?>
323 323
 		    <li><?php echo _("Type of Terrain:"); ?>
324 324
 			<select  class="selectpicker" onchange="terrainType(this);">
@@ -329,10 +329,10 @@  discard block
 block discarded – undo
329 329
 			</select>
330 330
 		    </li>
331 331
 <?php
332
-    }
332
+	}
333 333
 ?>
334 334
 <?php
335
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
335
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
336 336
 ?>
337 337
 		    
338 338
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
@@ -341,76 +341,76 @@  discard block
 block discarded – undo
341 341
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightremainingroute" value="1" onclick="clickFlightRemainingRoute(this)" <?php if ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == 'true') || !isset($_COOKIE['MapRemainingRoute']) || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)) print 'checked'; ?> ><?php echo _("Display flight remaining route on click"); ?></label></div></li>
342 342
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
343 343
 <?php
344
-    }
344
+	}
345 345
 ?>
346 346
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true' || !isset($_COOKIE['displayairports'])) print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
347 347
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) print 'checked'; ?> ><?php echo _("Display ground station on map"); ?></label></div></li>
348 348
 <?php
349
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
349
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
350 350
 ?>
351 351
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
352 352
 <?php
353
-    }
354
-    if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
353
+	}
354
+	if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
355 355
 ?>
356 356
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li>
357 357
 <?php
358
-    }
358
+	}
359 359
 ?>
360 360
 
361 361
 		    <?php
362 362
 			if (function_exists('array_column')) {
363
-			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
364
-		    ?>
363
+				if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
364
+			?>
365 365
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
366 366
 		    <?php
367
-			    }
367
+				}
368 368
 			} elseif (isset($globalSources)) {
369
-			    $dispolar = false;
370
-			    foreach ($globalSources as $testsource) {
371
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
372
-			    }
373
-			    if ($dispolar) {
374
-		    ?>
369
+				$dispolar = false;
370
+				foreach ($globalSources as $testsource) {
371
+					if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
372
+				}
373
+				if ($dispolar) {
374
+			?>
375 375
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
376 376
 		    <?php
377
-			    }
378
-		        }
379
-		    ?>
377
+				}
378
+				}
379
+			?>
380 380
 <?php
381
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
381
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
382 382
 ?>
383 383
 
384 384
 		    <?php
385 385
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
386
-		    	    if (extension_loaded('gd') && function_exists('gd_info')) {
387
-		    ?>
386
+					if (extension_loaded('gd') && function_exists('gd_info')) {
387
+			?>
388 388
 		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
389 389
 		    <?php 
390 390
 				if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
391
-		    ?>
391
+			?>
392 392
 		    <li><?php echo _("Aircraft icon color:"); ?>
393 393
 			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>">
394 394
 		    </li>
395 395
 		    <?php
396 396
 				}
397
-			    }
398
-		        }
399
-		    ?>
397
+				}
398
+				}
399
+			?>
400 400
 		    <?php
401 401
 			if (isset($globalMarine) && $globalMarine === TRUE) {
402
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
403
-		    ?>
402
+				if (extension_loaded('gd') && function_exists('gd_info')) {
403
+			?>
404 404
 		    <li><?php echo _("Marine icon color:"); ?>
405 405
 			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>">
406 406
 		    </li>
407 407
 		    <?php
408
-			    }
409
-		        }
410
-		    ?>
408
+				}
409
+				}
410
+			?>
411 411
 		    <?php
412 412
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
413
-		    ?>
413
+			?>
414 414
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
415 415
 			<div class="range">
416 416
 			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
@@ -419,9 +419,9 @@  discard block
 block discarded – undo
419 419
 		    </li>
420 420
 		    <?php
421 421
 			}
422
-		    ?>
422
+			?>
423 423
 <?php
424
-    } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
424
+	} elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
425 425
 ?>
426 426
 <?php
427 427
 	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 		    </li>
443 443
 <?php
444 444
 	}
445
-    }
445
+	}
446 446
 ?>
447 447
 		    <li><?php echo _("Distance unit:"); ?>
448 448
 			<select class="selectpicker" onchange="unitdistance(this);">
@@ -475,19 +475,19 @@  discard block
 block discarded – undo
475 475
 		    <ul>
476 476
 		    <?php
477 477
 			if (!isset($globalAircraft) || $globalAircraft) {
478
-		    ?>
478
+			?>
479 479
 		    <?php
480 480
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
481
-		    ?>
481
+			?>
482 482
 			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
483 483
 			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
484 484
 			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
485 485
 		    <?php
486 486
 			}
487
-		    ?>
487
+			?>
488 488
 		    <?php
489 489
 			if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
490
-		    ?>
490
+			?>
491 491
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
492 492
 			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
493 493
 			<?php } ?>
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 			<?php } ?>
497 497
 		    <?php
498 498
 			}
499
-		    ?>
499
+			?>
500 500
 		    <li><?php echo _("Display airlines:"); ?>
501 501
 		    <br/>
502 502
 			<select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines">
@@ -516,14 +516,14 @@  discard block
 block discarded – undo
516 516
 						echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>';
517 517
 					}
518 518
 				}
519
-			    ?>
519
+				?>
520 520
 			</select>
521 521
 		    </li>
522 522
 		    <?php
523 523
 			$Spotter = new Spotter();
524 524
 			$allalliancenames = $Spotter->getAllAllianceNames();
525 525
 			if (!empty($allalliancenames)) {
526
-		    ?>
526
+			?>
527 527
 		    <li><?php echo _("Display alliance:"); ?>
528 528
 		    <br/>
529 529
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
@@ -537,18 +537,18 @@  discard block
 block discarded – undo
537 537
 						echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>';
538 538
 					}
539 539
 				}
540
-			    ?>
540
+				?>
541 541
 			</select>
542 542
 		    </li>
543 543
 		    <?php
544 544
 			}
545
-		    ?>
545
+			?>
546 546
 		    <?php
547 547
 			}
548
-		    ?>
548
+			?>
549 549
 		    <?php
550 550
 			if (isset($globalAPRS) && $globalAPRS) {
551
-		    ?>
551
+			?>
552 552
 		    <li><?php echo _("Display APRS sources name:"); ?>
553 553
 			<select class="selectpicker" multiple onchange="sources(this);">
554 554
 			    <?php
@@ -560,18 +560,18 @@  discard block
 block discarded – undo
560 560
 						echo '<option value="'.$source['source_name'].'">'.$source['source_name'].'</option>';
561 561
 					}
562 562
 				}
563
-			    ?>
563
+				?>
564 564
 			</select>
565 565
 		    </li>
566 566
 		    <?php
567 567
 			}
568
-		    ?>
568
+			?>
569 569
 		    <?php
570 570
 			if (!isset($globalAircraft) && $globalAircraft) {
571
-		    ?>
571
+			?>
572 572
 		    <?php
573 573
 			if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) {
574
-		    ?>
574
+			?>
575 575
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
576 576
 			<select class="selectpicker" onchange="airlinestype(this);">
577 577
 			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
@@ -582,14 +582,14 @@  discard block
 block discarded – undo
582 582
 		    </li>
583 583
 		    <?php
584 584
 			}
585
-		    ?>
585
+			?>
586 586
 		    <li>
587 587
 			<?php echo _("Display flight with ident:"); ?>
588 588
 			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
589 589
 		    </li>
590 590
 		    <?php
591 591
 			}
592
-		    ?>
592
+			?>
593 593
 		</ul>
594 594
 	    </form>
595 595
 	    <form method="post">
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 	    </form>
599 599
     	</div>
600 600
 <?php
601
-    if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
601
+	if (isset($globalMapSatellites) && $globalMapSatellites && isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
602 602
 ?>
603 603
         <div class="sidebar-pane" id="satellites">
604 604
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -638,14 +638,14 @@  discard block
 block discarded – undo
638 638
 						print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>';
639 639
 					}
640 640
 				}
641
-			    ?>
641
+				?>
642 642
 			</select>
643 643
 		    </li>
644 644
 		</ul>
645 645
 	    </form>
646 646
 	</div>
647 647
 <?php
648
-    }
648
+	}
649 649
 ?>
650 650
     </div>
651 651
 </div>
Please login to merge, or discard this patch.
Braces   +405 added lines, -104 removed lines patch added patch discarded remove patch
@@ -157,11 +157,26 @@  discard block
 block discarded – undo
157 157
 				<li><div class="checkbox"><label><input type="checkbox" name="notamcb" value="1" onclick="showNotam();" /><?php echo _("Display NOTAM"); ?></label></div></li>
158 158
 				<li><?php echo _("NOTAM scope:"); ?>
159 159
 					<select class="selectpicker" onchange="notamscope(this);">
160
-						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') print ' selected'; ?>>All</option>
161
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') print ' selected'; ?>>Airport/Enroute warning</option>
162
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') print ' selected'; ?>>Airport warning</option>
163
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') print ' selected'; ?>>Navigation warning</option>
164
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') print ' selected'; ?>>Enroute warning</option>
160
+						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') {
161
+	print ' selected';
162
+}
163
+?>>All</option>
164
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') {
165
+	print ' selected';
166
+}
167
+?>>Airport/Enroute warning</option>
168
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') {
169
+	print ' selected';
170
+}
171
+?>>Airport warning</option>
172
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') {
173
+	print ' selected';
174
+}
175
+?>>Navigation warning</option>
176
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') {
177
+	print ' selected';
178
+}
179
+?>>Enroute warning</option>
165 180
 					</select
166 181
 				</li>
167 182
 			</ul>
@@ -189,7 +204,12 @@  discard block
 block discarded – undo
189 204
 		        <div class="form-group">
190 205
 			    <label>From (UTC):</label>
191 206
 		            <div class='input-group date' id='datetimepicker1'>
192
-            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) print $_POST['start_date']; elseif (isset($_COOKIE['archive_begin'])) print date("m/d/Y h:i a",$_COOKIE['archive_begin']); ?>" required />
207
+            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) {
208
+	print $_POST['start_date'];
209
+} elseif (isset($_COOKIE['archive_begin'])) {
210
+	print date("m/d/Y h:i a",$_COOKIE['archive_begin']);
211
+}
212
+?>" required />
193 213
 		                <span class="input-group-addon">
194 214
             			    <span class="glyphicon glyphicon-calendar"></span>
195 215
 		                </span>
@@ -198,7 +218,12 @@  discard block
 block discarded – undo
198 218
 		        <div class="form-group">
199 219
 			    <label>To (UTC):</label>
200 220
 		            <div class='input-group date' id='datetimepicker2'>
201
-		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) print $_POST['end_date']; elseif (isset($_COOKIE['archive_end'])) print date("m/d/Y h:i a",$_COOKIE['archive_end']); ?>" />
221
+		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) {
222
+	print $_POST['end_date'];
223
+} elseif (isset($_COOKIE['archive_end'])) {
224
+	print date("m/d/Y h:i a",$_COOKIE['archive_end']);
225
+}
226
+?>" />
202 227
             			<span class="input-group-addon">
203 228
 		                    <span class="glyphicon glyphicon-calendar"></span>
204 229
             			</span>
@@ -224,8 +249,20 @@  discard block
 block discarded – undo
224 249
 
225 250
 		    <li><?php echo _("Playback speed:"); ?>
226 251
 			<div class="range">
227
-			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) print $_POST['archivespeed']; elseif (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?>">
228
-			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?></output>
252
+			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) {
253
+	print $_POST['archivespeed'];
254
+} elseif (isset($_COOKIE['archive_speed'])) {
255
+	print $_COOKIE['archive_speed'];
256
+} else {
257
+	print '1';
258
+}
259
+?>">
260
+			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) {
261
+	print $_COOKIE['archive_speed'];
262
+} else {
263
+	print '1';
264
+}
265
+?></output>
229 266
 			</div>
230 267
 		    </li>
231 268
 		    <li><input type="submit" name="archive" value="Show archive" class="btn btn-primary" /></li>
@@ -247,15 +284,27 @@  discard block
 block discarded – undo
247 284
 		    <li><?php echo _("Type of Map:"); ?>
248 285
 			<select  class="selectpicker" onchange="mapType(this);">
249 286
 			    <?php
250
-				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
251
-				else $MapType = $_COOKIE['MapType'];
287
+				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') {
288
+					$MapType = $globalMapProvider;
289
+				} else {
290
+					$MapType = $_COOKIE['MapType'];
291
+				}
252 292
 			    ?>
253 293
 			    <?php
254 294
 				if (isset($globalBingMapKey) && $globalBingMapKey != '') {
255 295
 			    ?>
256
-			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
257
-			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
258
-			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
296
+			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') {
297
+	print ' selected';
298
+}
299
+?>>Bing-Aerial</option>
300
+			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') {
301
+	print ' selected';
302
+}
303
+?>>Bing-Hybrid</option>
304
+			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') {
305
+	print ' selected';
306
+}
307
+?>>Bing-Road</option>
259 308
 			    <?php
260 309
 				}
261 310
 			    ?>
@@ -265,56 +314,131 @@  discard block
 block discarded – undo
265 314
 			    <?php
266 315
 				    if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
267 316
 			    ?>
268
-			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
269
-			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
270
-			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
317
+			    <option value="Here-Aerial"<?php if ($MapType == 'Here') {
318
+	print ' selected';
319
+}
320
+?>>Here-Aerial</option>
321
+			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') {
322
+	print ' selected';
323
+}
324
+?>>Here-Hybrid</option>
325
+			    <option value="Here-Road"<?php if ($MapType == 'Here') {
326
+	print ' selected';
327
+}
328
+?>>Here-Road</option>
271 329
 			    <?php
272 330
 				    }
273 331
 			    ?>
274 332
 			    <?php
275 333
 				    if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
276 334
 			    ?>
277
-			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
278
-			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
279
-			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
280
-			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
335
+			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') {
336
+	print ' selected';
337
+}
338
+?>>Google Roadmap</option>
339
+			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') {
340
+	print ' selected';
341
+}
342
+?>>Google Satellite</option>
343
+			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') {
344
+	print ' selected';
345
+}
346
+?>>Google Hybrid</option>
347
+			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') {
348
+	print ' selected';
349
+}
350
+?>>Google Terrain</option>
281 351
 			    <?php
282 352
 				    }
283 353
 			    ?>
284 354
 			    <?php
285 355
 				    if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
286 356
 			    ?>
287
-			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
288
-			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
289
-			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
357
+			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') {
358
+	print ' selected';
359
+}
360
+?>>MapQuest-OSM</option>
361
+			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') {
362
+	print ' selected';
363
+}
364
+?>>MapQuest-Aerial</option>
365
+			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') {
366
+	print ' selected';
367
+}
368
+?>>MapQuest-Hybrid</option>
290 369
 			    <?php
291 370
 				    }
292 371
 			    ?>
293
-			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
372
+			    <option value="Yandex"<?php if ($MapType == 'Yandex') {
373
+	print ' selected';
374
+}
375
+?>>Yandex</option>
294 376
 			    <?php
295 377
 				}
296 378
 			    ?>
297 379
 			    <?php
298 380
 				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
299
-					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
300
-					else $MapBoxId = $_COOKIE['MapTypeId'];
381
+					if (!isset($_COOKIE['MapTypeId'])) {
382
+						$MapBoxId = 'default';
383
+					} else {
384
+						$MapBoxId = $_COOKIE['MapTypeId'];
385
+					}
301 386
 			    ?>
302
-			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
303
-			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
304
-			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
305
-			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') print ' selected'; ?>>Mapbox dark</option>
306
-			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') print ' selected'; ?>>Mapbox satellite</option>
307
-			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') print ' selected'; ?>>Mapbox streets-satellite</option>
308
-			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') print ' selected'; ?>>Mapbox streets-basic</option>
309
-			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') print ' selected'; ?>>Mapbox comic</option>
310
-			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') print ' selected'; ?>>Mapbox outdoors</option>
311
-			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') print ' selected'; ?>>Mapbox pencil</option>
312
-			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
313
-			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
387
+			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') {
388
+	print ' selected';
389
+}
390
+?>>Mapbox default</option>
391
+			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') {
392
+	print ' selected';
393
+}
394
+?>>Mapbox streets</option>
395
+			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') {
396
+	print ' selected';
397
+}
398
+?>>Mapbox light</option>
399
+			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') {
400
+	print ' selected';
401
+}
402
+?>>Mapbox dark</option>
403
+			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') {
404
+	print ' selected';
405
+}
406
+?>>Mapbox satellite</option>
407
+			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') {
408
+	print ' selected';
409
+}
410
+?>>Mapbox streets-satellite</option>
411
+			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') {
412
+	print ' selected';
413
+}
414
+?>>Mapbox streets-basic</option>
415
+			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') {
416
+	print ' selected';
417
+}
418
+?>>Mapbox comic</option>
419
+			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') {
420
+	print ' selected';
421
+}
422
+?>>Mapbox outdoors</option>
423
+			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') {
424
+	print ' selected';
425
+}
426
+?>>Mapbox pencil</option>
427
+			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') {
428
+	print ' selected';
429
+}
430
+?>>Mapbox pirates</option>
431
+			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') {
432
+	print ' selected';
433
+}
434
+?>>Mapbox emerald</option>
314 435
 			    <?php
315 436
 				    }
316 437
 			    ?>
317
-			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
438
+			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') {
439
+	print ' selected';
440
+}
441
+?>>OpenStreetMap</option>
318 442
 			</select>
319 443
 		    </li>
320 444
 <?php
@@ -322,10 +446,22 @@  discard block
 block discarded – undo
322 446
 ?>
323 447
 		    <li><?php echo _("Type of Terrain:"); ?>
324 448
 			<select  class="selectpicker" onchange="terrainType(this);">
325
-			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option>
326
-			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option>
327
-			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option>
328
-			    <option value="articdem"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'articdem') print ' selected';?>>ArticDEM</option>
449
+			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') {
450
+	print ' selected';
451
+}
452
+?>>stk terrain</option>
453
+			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') {
454
+	print ' selected';
455
+}
456
+?>>ellipsoid</option>
457
+			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') {
458
+	print ' selected';
459
+}
460
+?>>vr terrain</option>
461
+			    <option value="articdem"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'articdem') {
462
+	print ' selected';
463
+}
464
+?>>ArticDEM</option>
329 465
 			</select>
330 466
 		    </li>
331 467
 <?php
@@ -335,20 +471,44 @@  discard block
 block discarded – undo
335 471
     if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
336 472
 ?>
337 473
 		    
338
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
339
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) print 'checked'; ?> ><?php echo _("Display flight path"); ?></label></div></li>
340
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || (isset($globalMapRoute) && $globalMapRoute)) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li>
341
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightremainingroute" value="1" onclick="clickFlightRemainingRoute(this)" <?php if ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == 'true') || !isset($_COOKIE['MapRemainingRoute']) || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)) print 'checked'; ?> ><?php echo _("Display flight remaining route on click"); ?></label></div></li>
342
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
474
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') {
475
+	print 'checked';
476
+}
477
+?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
478
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) {
479
+	print 'checked';
480
+}
481
+?> ><?php echo _("Display flight path"); ?></label></div></li>
482
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || (isset($globalMapRoute) && $globalMapRoute)) {
483
+	print 'checked';
484
+}
485
+?> ><?php echo _("Display flight route on click"); ?></label></div></li>
486
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightremainingroute" value="1" onclick="clickFlightRemainingRoute(this)" <?php if ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == 'true') || !isset($_COOKIE['MapRemainingRoute']) || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)) {
487
+	print 'checked';
488
+}
489
+?> ><?php echo _("Display flight remaining route on click"); ?></label></div></li>
490
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) {
491
+	print 'checked';
492
+}
493
+?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
343 494
 <?php
344 495
     }
345 496
 ?>
346
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true' || !isset($_COOKIE['displayairports'])) print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
347
-		    <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) print 'checked'; ?> ><?php echo _("Display ground station on map"); ?></label></div></li>
497
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true' || !isset($_COOKIE['displayairports'])) {
498
+	print 'checked';
499
+}
500
+?> ><?php echo _("Display airports on map"); ?></label></div></li>
501
+		    <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) {
502
+	print 'checked';
503
+}
504
+?> ><?php echo _("Display ground station on map"); ?></label></div></li>
348 505
 <?php
349 506
     if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
350 507
 ?>
351
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
508
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) {
509
+	print 'checked';
510
+}
511
+?> ><?php echo _("Show mini-map"); ?></label></div></li>
352 512
 <?php
353 513
     }
354 514
     if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
@@ -362,17 +522,25 @@  discard block
 block discarded – undo
362 522
 			if (function_exists('array_column')) {
363 523
 			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
364 524
 		    ?>
365
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
525
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
526
+	print 'checked';
527
+}
528
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
366 529
 		    <?php
367 530
 			    }
368 531
 			} elseif (isset($globalSources)) {
369 532
 			    $dispolar = false;
370 533
 			    foreach ($globalSources as $testsource) {
371
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
534
+			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) {
535
+			        	$dispolar = true;
536
+			        }
372 537
 			    }
373 538
 			    if ($dispolar) {
374 539
 		    ?>
375
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
540
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
541
+	print 'checked';
542
+}
543
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
376 544
 		    <?php
377 545
 			    }
378 546
 		        }
@@ -385,12 +553,22 @@  discard block
 block discarded – undo
385 553
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
386 554
 		    	    if (extension_loaded('gd') && function_exists('gd_info')) {
387 555
 		    ?>
388
-		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
556
+		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') {
557
+	print 'checked';
558
+}
559
+?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
389 560
 		    <?php 
390 561
 				if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
391 562
 		    ?>
392 563
 		    <li><?php echo _("Aircraft icon color:"); ?>
393
-			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>">
564
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
565
+	print $_COOKIE['IconColor'];
566
+} elseif (isset($globalAircraftIconColor)) {
567
+	print $globalAircraftIconColor;
568
+} else {
569
+	print '1a3151';
570
+}
571
+?>">
394 572
 		    </li>
395 573
 		    <?php
396 574
 				}
@@ -402,7 +580,14 @@  discard block
 block discarded – undo
402 580
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
403 581
 		    ?>
404 582
 		    <li><?php echo _("Marine icon color:"); ?>
405
-			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>">
583
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
584
+	print $_COOKIE['MarineIconColor'];
585
+} elseif (isset($globalMarineIconColor)) {
586
+	print $globalMarineIconColor;
587
+} else {
588
+	print '1a3151';
589
+}
590
+?>">
406 591
 		    </li>
407 592
 		    <?php
408 593
 			    }
@@ -413,8 +598,22 @@  discard block
 block discarded – undo
413 598
 		    ?>
414 599
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
415 600
 			<div class="range">
416
-			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
417
-			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?></output>
601
+			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) {
602
+	print $_COOKIE['AirportZoom'];
603
+} elseif (isset($globalAirportZoom)) {
604
+	print $globalAirportZoom;
605
+} else {
606
+	print '7';
607
+}
608
+?>">
609
+			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) {
610
+	print $_COOKIE['AirportZoom'];
611
+} elseif (isset($globalAirportZoom)) {
612
+	print $globalAirportZoom;
613
+} else {
614
+	print '7';
615
+}
616
+?></output>
418 617
 			</div>
419 618
 		    </li>
420 619
 		    <?php
@@ -426,9 +625,19 @@  discard block
 block discarded – undo
426 625
 <?php
427 626
 	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
428 627
 ?>
429
-		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Aircraft color"); ?></li>
628
+		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') {
629
+	print 'checked';
630
+}
631
+?> ><?php echo _("Force Aircraft color"); ?></li>
430 632
 		    <li><?php echo _("Aircraft icon color:"); ?>
431
-			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print 'ff0000'; ?>">
633
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
634
+	print $_COOKIE['IconColor'];
635
+} elseif (isset($globalAircraftIconColor)) {
636
+	print $globalAircraftIconColor;
637
+} else {
638
+	print 'ff0000';
639
+}
640
+?>">
432 641
 		    </li>
433 642
 <?php
434 643
 	}
@@ -436,9 +645,19 @@  discard block
 block discarded – undo
436 645
 <?php
437 646
 	if (isset($globalMarine) && $globalMarine === TRUE) {
438 647
 ?>
439
-		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Marine color"); ?></li>
648
+		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') {
649
+	print 'checked';
650
+}
651
+?> ><?php echo _("Force Marine color"); ?></li>
440 652
 		    <li><?php echo _("Marine icon color:"); ?>
441
-			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print 'ff0000'; ?>">
653
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
654
+	print $_COOKIE['MarineIconColor'];
655
+} elseif (isset($globalMarineIconColor)) {
656
+	print $globalMarineIconColor;
657
+} else {
658
+	print 'ff0000';
659
+}
660
+?>">
442 661
 		    </li>
443 662
 <?php
444 663
 	}
@@ -446,22 +665,46 @@  discard block
 block discarded – undo
446 665
 ?>
447 666
 		    <li><?php echo _("Distance unit:"); ?>
448 667
 			<select class="selectpicker" onchange="unitdistance(this);">
449
-			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) echo ' selected'; ?>>km</option>
450
-			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) echo ' selected'; ?>>nm</option>
451
-			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) echo ' selected'; ?>>mi</option>
668
+			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
669
+	echo ' selected';
670
+}
671
+?>>km</option>
672
+			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
673
+	echo ' selected';
674
+}
675
+?>>nm</option>
676
+			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
677
+	echo ' selected';
678
+}
679
+?>>mi</option>
452 680
 		        </select>
453 681
 		    </li>
454 682
 		    <li><?php echo _("Altitude unit:"); ?>
455 683
 			<select class="selectpicker" onchange="unitaltitude(this);">
456
-			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) echo ' selected'; ?>>m</option>
457
-			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) echo ' selected'; ?>>feet</option>
684
+			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) {
685
+	echo ' selected';
686
+}
687
+?>>m</option>
688
+			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
689
+	echo ' selected';
690
+}
691
+?>>feet</option>
458 692
 		        </select>
459 693
 		    </li>
460 694
 		    <li><?php echo _("Speed unit:"); ?>
461 695
 			<select class="selectpicker" onchange="unitspeed(this);">
462
-			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) echo ' selected'; ?>>km/h</option>
463
-			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) echo ' selected'; ?>>mph</option>
464
-			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) echo ' selected'; ?>>knots</option>
696
+			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) {
697
+	echo ' selected';
698
+}
699
+?>>km/h</option>
700
+			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
701
+	echo ' selected';
702
+}
703
+?>>mph</option>
704
+			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
705
+	echo ' selected';
706
+}
707
+?>>knots</option>
465 708
 		        </select>
466 709
 		    </li>
467 710
 
@@ -479,9 +722,18 @@  discard block
 block discarded – undo
479 722
 		    <?php
480 723
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
481 724
 		    ?>
482
-			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
483
-			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
484
-			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
725
+			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) {
726
+	print 'checked';
727
+}
728
+?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
729
+			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) {
730
+	print 'checked';
731
+}
732
+?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
733
+			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) {
734
+	print 'checked';
735
+}
736
+?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
485 737
 		    <?php
486 738
 			}
487 739
 		    ?>
@@ -489,10 +741,16 @@  discard block
 block discarded – undo
489 741
 			if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
490 742
 		    ?>
491 743
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
492
-			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
744
+			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) {
745
+	print 'checked';
746
+}
747
+?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
493 748
 			<?php } ?>
494 749
 			<?php if (isset($globalAPRS) && $globalAPRS) { ?>
495
-			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) print 'checked'; ?> ><?php echo _("Display APRS data"); ?></label></div></li>
750
+			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) {
751
+	print 'checked';
752
+}
753
+?> ><?php echo _("Display APRS data"); ?></label></div></li>
496 754
 			<?php } ?>
497 755
 		    <?php
498 756
 			}
@@ -509,7 +767,9 @@  discard block
 block discarded – undo
509 767
 				}
510 768
 				foreach($allairlinenames as $airline) {
511 769
 					$airline_name = $airline['airline_name'];
512
-					if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...';
770
+					if (strlen($airline_name) > 30) {
771
+						$airline_name = substr($airline_name,0,30).'...';
772
+					}
513 773
 					if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['filter_Airlines']))) {
514 774
 						echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>';
515 775
 					} else {
@@ -527,7 +787,10 @@  discard block
 block discarded – undo
527 787
 		    <li><?php echo _("Display alliance:"); ?>
528 788
 		    <br/>
529 789
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
530
-			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
790
+			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') {
791
+	echo ' selected';
792
+}
793
+?>><?php echo _("All"); ?></option>
531 794
 			    <?php
532 795
 				foreach($allalliancenames as $alliance) {
533 796
 					$alliance_name = $alliance['alliance'];
@@ -574,10 +837,22 @@  discard block
 block discarded – undo
574 837
 		    ?>
575 838
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
576 839
 			<select class="selectpicker" onchange="airlinestype(this);">
577
-			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
578
-			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') echo ' selected'; ?>><?php echo _("Passenger"); ?></option>
579
-			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') echo ' selected'; ?>><?php echo _("Cargo"); ?></option>
580
-			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') echo ' selected'; ?>><?php echo _("Military"); ?></option>
840
+			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') {
841
+	echo ' selected';
842
+}
843
+?>><?php echo _("All"); ?></option>
844
+			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') {
845
+	echo ' selected';
846
+}
847
+?>><?php echo _("Passenger"); ?></option>
848
+			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') {
849
+	echo ' selected';
850
+}
851
+?>><?php echo _("Cargo"); ?></option>
852
+			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') {
853
+	echo ' selected';
854
+}
855
+?>><?php echo _("Military"); ?></option>
581 856
 			</select>
582 857
 		    </li>
583 858
 		    <?php
@@ -585,7 +860,10 @@  discard block
 block discarded – undo
585 860
 		    ?>
586 861
 		    <li>
587 862
 			<?php echo _("Display flight with ident:"); ?>
588
-			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
863
+			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) {
864
+	print $_COOKIE['filter_ident'];
865
+}
866
+?>" />
589 867
 		    </li>
590 868
 		    <?php
591 869
 			}
@@ -604,7 +882,10 @@  discard block
 block discarded – undo
604 882
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
605 883
 	    <form>
606 884
 		<ul>
607
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') print 'checked'; ?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
885
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') {
886
+	print 'checked';
887
+}
888
+?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
608 889
 		    <li><?php echo _("Type:"); ?>
609 890
 			<select class="selectpicker" multiple onchange="sattypes(this);">
610 891
 			    <?php
@@ -612,25 +893,45 @@  discard block
 block discarded – undo
612 893
 				$types = $Satellite->get_tle_types();
613 894
 				foreach ($types as $type) {
614 895
 					$type_name = $type['tle_type'];
615
-					if ($type_name == 'musson') $type_name = 'Russian LEO Navigation';
616
-					else if ($type_name == 'nnss') $type_name = 'Navi Navigation Satellite System';
617
-					else if ($type_name == 'sbas') $type_name = 'Satellite-Based Augmentation System';
618
-					else if ($type_name == 'glo-ops') $type_name = 'Glonass Operational';
619
-					else if ($type_name == 'gps-ops') $type_name = 'GPS Operational';
620
-					else if ($type_name == 'argos') $type_name = 'ARGOS Data Collection System';
621
-					else if ($type_name == 'tdrss') $type_name = 'Tracking and Data Relay Satellite System';
622
-					else if ($type_name == 'sarsat') $type_name = 'Search & Rescue';
623
-					else if ($type_name == 'dmc') $type_name = 'Disaster Monitoring';
624
-					else if ($type_name == 'resource') $type_name = 'Earth Resources';
625
-					else if ($type_name == 'stations') $type_name = 'Space Stations';
626
-					else if ($type_name == 'geo') $type_name = 'Geostationary';
627
-					else if ($type_name == 'amateur') $type_name = 'Amateur Radio';
628
-					else if ($type_name == 'x-comm') $type_name = 'Experimental';
629
-					else if ($type_name == 'other-comm') $type_name = 'Other Comm';
630
-					else if ($type_name == 'science') $type_name = 'Space & Earth Science';
631
-					else if ($type_name == 'military') $type_name = 'Miscellaneous Military';
632
-					else if ($type_name == 'radar') $type_name = 'Radar Calibration';
633
-					else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches';
896
+					if ($type_name == 'musson') {
897
+						$type_name = 'Russian LEO Navigation';
898
+					} else if ($type_name == 'nnss') {
899
+						$type_name = 'Navi Navigation Satellite System';
900
+					} else if ($type_name == 'sbas') {
901
+						$type_name = 'Satellite-Based Augmentation System';
902
+					} else if ($type_name == 'glo-ops') {
903
+						$type_name = 'Glonass Operational';
904
+					} else if ($type_name == 'gps-ops') {
905
+						$type_name = 'GPS Operational';
906
+					} else if ($type_name == 'argos') {
907
+						$type_name = 'ARGOS Data Collection System';
908
+					} else if ($type_name == 'tdrss') {
909
+						$type_name = 'Tracking and Data Relay Satellite System';
910
+					} else if ($type_name == 'sarsat') {
911
+						$type_name = 'Search & Rescue';
912
+					} else if ($type_name == 'dmc') {
913
+						$type_name = 'Disaster Monitoring';
914
+					} else if ($type_name == 'resource') {
915
+						$type_name = 'Earth Resources';
916
+					} else if ($type_name == 'stations') {
917
+						$type_name = 'Space Stations';
918
+					} else if ($type_name == 'geo') {
919
+						$type_name = 'Geostationary';
920
+					} else if ($type_name == 'amateur') {
921
+						$type_name = 'Amateur Radio';
922
+					} else if ($type_name == 'x-comm') {
923
+						$type_name = 'Experimental';
924
+					} else if ($type_name == 'other-comm') {
925
+						$type_name = 'Other Comm';
926
+					} else if ($type_name == 'science') {
927
+						$type_name = 'Space & Earth Science';
928
+					} else if ($type_name == 'military') {
929
+						$type_name = 'Miscellaneous Military';
930
+					} else if ($type_name == 'radar') {
931
+						$type_name = 'Radar Calibration';
932
+					} else if ($type_name == 'tle-new') {
933
+						$type_name = 'Last 30 days launches';
934
+					}
634 935
 					
635 936
 					if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) {
636 937
 						print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>';
Please login to merge, or discard this patch.
require/class.Source.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 		try {
16 16
 			$sth = $this->db->prepare($query);
17 17
 			$sth->execute($query_values);
18
-		} catch(PDOException $e) {
18
+		} catch (PDOException $e) {
19 19
 			return "error : ".$e->getMessage();
20 20
 		}
21 21
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -28,20 +28,20 @@  discard block
 block discarded – undo
28 28
 		try {
29 29
 			$sth = $this->db->prepare($query);
30 30
 			$sth->execute($query_values);
31
-		} catch(PDOException $e) {
31
+		} catch (PDOException $e) {
32 32
 			return "error : ".$e->getMessage();
33 33
 		}
34 34
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
35 35
 		return $all;
36 36
 	}
37 37
 
38
-	public function getLocationInfobyNameType($name,$type) {
38
+	public function getLocationInfobyNameType($name, $type) {
39 39
 		$query = "SELECT * FROM source_location WHERE name = :name AND type = :type";
40
-		$query_values = array(':name' => $name,':type' => $type);
40
+		$query_values = array(':name' => $name, ':type' => $type);
41 41
 		try {
42 42
 			$sth = $this->db->prepare($query);
43 43
 			$sth->execute($query_values);
44
-		} catch(PDOException $e) {
44
+		} catch (PDOException $e) {
45 45
 			return "error : ".$e->getMessage();
46 46
 		}
47 47
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		try {
55 55
 			$sth = $this->db->prepare($query);
56 56
 			$sth->execute($query_values);
57
-		} catch(PDOException $e) {
57
+		} catch (PDOException $e) {
58 58
 			return "error : ".$e->getMessage();
59 59
 		}
60 60
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		try {
68 68
 			$sth = $this->db->prepare($query);
69 69
 			$sth->execute($query_values);
70
-		} catch(PDOException $e) {
70
+		} catch (PDOException $e) {
71 71
 			return "error : ".$e->getMessage();
72 72
 		}
73 73
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		try {
81 81
 			$sth = $this->db->prepare($query);
82 82
 			$sth->execute($query_values);
83
-		} catch(PDOException $e) {
83
+		} catch (PDOException $e) {
84 84
 			return "error : ".$e->getMessage();
85 85
 		}
86 86
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -93,56 +93,56 @@  discard block
 block discarded – undo
93 93
 		try {
94 94
 			$sth = $this->db->prepare($query);
95 95
 			$sth->execute($query_values);
96
-		} catch(PDOException $e) {
96
+		} catch (PDOException $e) {
97 97
 			return "error : ".$e->getMessage();
98 98
 		}
99 99
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
100 100
 		return $all;
101 101
 	}
102 102
 
103
-	public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') {
103
+	public function addLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') {
104 104
 		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s');
105 105
 		$query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)";
106
-		$query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description);
106
+		$query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description);
107 107
 		try {
108 108
 			$sth = $this->db->prepare($query);
109 109
 			$sth->execute($query_values);
110
-		} catch(PDOException $e) {
110
+		} catch (PDOException $e) {
111 111
 			echo "error : ".$e->getMessage();
112 112
 		}
113 113
 	}
114 114
 
115
-	public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') {
115
+	public function updateLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') {
116 116
 		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s');
117 117
 		$query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source";
118
-		$query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description);
118
+		$query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description);
119 119
 		try {
120 120
 			$sth = $this->db->prepare($query);
121 121
 			$sth->execute($query_values);
122
-		} catch(PDOException $e) {
122
+		} catch (PDOException $e) {
123 123
 			return "error : ".$e->getMessage();
124 124
 		}
125 125
 	}
126 126
 
127
-	public function updateLocationDescByName($name,$source,$source_id = 0,$description = '') {
127
+	public function updateLocationDescByName($name, $source, $source_id = 0, $description = '') {
128 128
 		$query = "UPDATE source_location SET description = :description WHERE source_id = :source_id AND name = :name AND source = :source";
129
-		$query_values = array(':name' => $name,':source' => $source,':source_id' => $source_id,':description' => $description);
129
+		$query_values = array(':name' => $name, ':source' => $source, ':source_id' => $source_id, ':description' => $description);
130 130
 		try {
131 131
 			$sth = $this->db->prepare($query);
132 132
 			$sth->execute($query_values);
133
-		} catch(PDOException $e) {
133
+		} catch (PDOException $e) {
134 134
 			return "error : ".$e->getMessage();
135 135
 		}
136 136
 	}
137 137
 
138
-	public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') {
138
+	public function updateLocationByLocationID($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id, $last_seen = '', $description = '') {
139 139
 		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s');
140 140
 		$query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id";
141
-		$query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description);
141
+		$query_values = array(':source_id' => $source_id, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description);
142 142
 		try {
143 143
 			$sth = $this->db->prepare($query);
144 144
 			$sth->execute($query_values);
145
-		} catch(PDOException $e) {
145
+		} catch (PDOException $e) {
146 146
 			echo "error : ".$e->getMessage();
147 147
 		}
148 148
 	}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		try {
154 154
 			$sth = $this->db->prepare($query);
155 155
 			$sth->execute($query_values);
156
-		} catch(PDOException $e) {
156
+		} catch (PDOException $e) {
157 157
 			return "error : ".$e->getMessage();
158 158
 		}
159 159
 	}
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 		try {
165 165
 			$sth = $this->db->prepare($query);
166 166
 			$sth->execute($query_values);
167
-		} catch(PDOException $e) {
167
+		} catch (PDOException $e) {
168 168
 			return "error : ".$e->getMessage();
169 169
 		}
170 170
 	}
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 		try {
175 175
 			$sth = $this->db->prepare($query);
176 176
 			$sth->execute();
177
-		} catch(PDOException $e) {
177
+		} catch (PDOException $e) {
178 178
 			return "error : ".$e->getMessage();
179 179
 		}
180 180
 	}
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 		try {
198 198
 			$sth = $this->db->prepare($query);
199 199
 			$sth->execute(array(':type' => $type));
200
-		} catch(PDOException $e) {
200
+		} catch (PDOException $e) {
201 201
 			return "error";
202 202
 		}
203 203
 		return "success";
Please login to merge, or discard this patch.
require/class.APRS.php 3 patches
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -2,10 +2,10 @@  discard block
 block discarded – undo
2 2
 require_once(dirname(__FILE__).'/settings.php');
3 3
 require_once(dirname(__FILE__).'/class.Common.php');
4 4
 class aprs {
5
-    private $socket;
6
-    private $connected = false;
5
+	private $socket;
6
+	private $connected = false;
7 7
 
8
-    protected $symbols = array('/!' => 'Police',
8
+	protected $symbols = array('/!' => 'Police',
9 9
 	'/#' => 'DIGI',
10 10
 	'/$' => 'Phone',
11 11
 	'/%' => 'DX Cluster',
@@ -165,13 +165,13 @@  discard block
 block discarded – undo
165 165
 	'\~' => 'TNC Stream SW');
166 166
 	
167 167
 
168
-    private function urshift($n, $s) {
168
+	private function urshift($n, $s) {
169 169
 	return ($n >= 0) ? ($n >> $s) :
170
-	    (($n & 0x7fffffff) >> $s) | 
170
+		(($n & 0x7fffffff) >> $s) | 
171 171
 		(0x40000000 >> ($s - 1));
172
-    }
172
+	}
173 173
 
174
-    public function parse($input) {
174
+	public function parse($input) {
175 175
 	global $globalDebug;
176 176
 	$debug = false;
177 177
 	$result = array();
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
 	
184 184
 	/* Check that end was found and body has at least one byte. */
185 185
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
186
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
187
-	    return false;
186
+		if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
187
+		return false;
188 188
 	}
189 189
 	
190 190
 	if ($debug) echo 'input : '.$input."\n";
@@ -198,34 +198,34 @@  discard block
 block discarded – undo
198 198
 	/* Parse source, target and path. */
199 199
 	//FLRDF0A52>APRS,qAS,LSTB
200 200
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
201
-	    $ident = $matches[1];
202
-	    $all_elements = $matches[2];
203
-	    if ($ident == 'AIRCRAFT') {
201
+		$ident = $matches[1];
202
+		$all_elements = $matches[2];
203
+		if ($ident == 'AIRCRAFT') {
204 204
 		$result['format_source'] = 'famaprs';
205 205
 		$result['source_type'] = 'modes';
206
-	    } elseif ($ident == 'MARINE') {
206
+		} elseif ($ident == 'MARINE') {
207 207
 		$result['format_source'] = 'famaprs';
208 208
 		$result['source_type'] = 'ais';
209
-	    } else {
209
+		} else {
210 210
 		if ($debug) echo 'ident : '.$ident."\n";
211 211
 		$result['ident'] = $ident;
212
-	    }
212
+		}
213 213
 	} else {
214
-	    if ($debug) 'No ident'."\n";
215
-	    return false;
214
+		if ($debug) 'No ident'."\n";
215
+		return false;
216 216
 	}
217 217
 	$elements = explode(',',$all_elements);
218 218
 	$source = end($elements);
219 219
 	$result['source'] = $source;
220 220
 	foreach ($elements as $element) {
221
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
222
-	        //echo "ok";
223
-	        //if ($element == 'TCPIP*') return false;
224
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
221
+		if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
222
+			//echo "ok";
223
+			//if ($element == 'TCPIP*') return false;
224
+		} elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
225 225
 		if ($debug) echo 'element : '.$element."\n";
226 226
 		return false;
227
-	    }
228
-	    /*
227
+		}
228
+		/*
229 229
 	    } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) {
230 230
 		//echo "ok";
231 231
 	    } else {
@@ -252,48 +252,48 @@  discard block
 block discarded – undo
252 252
 	$body_parse = substr($body,1);
253 253
 	//echo 'Body : '.$body."\n";
254 254
 	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
255
-	    $body_parse = substr($body_parse,10);
256
-	    $find = true;
257
-	    //echo $body_parse."\n";
255
+		$body_parse = substr($body_parse,10);
256
+		$find = true;
257
+		//echo $body_parse."\n";
258 258
 	}
259 259
 	if (preg_match('/^`(.*)\//',$body,$matches)) {
260
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
261
-	    $find = true;
262
-	    //echo $body_parse."\n";
260
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
261
+		$find = true;
262
+		//echo $body_parse."\n";
263 263
 	}
264 264
 	if (preg_match("/^'(.*)\//",$body,$matches)) {
265
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
266
-	    $find = true;
267
-	    //echo $body_parse."\n";
265
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
266
+		$find = true;
267
+		//echo $body_parse."\n";
268 268
 	}
269 269
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
270
-	    $find = true;
271
-	    //print_r($matches);
272
-	    $timestamp = $matches[0];
273
-	    if ($matches[4] == 'h') {
270
+		$find = true;
271
+		//print_r($matches);
272
+		$timestamp = $matches[0];
273
+		if ($matches[4] == 'h') {
274 274
 		$timestamp = strtotime(date('Ymd').' '.$matches[1].':'.$matches[2].':'.$matches[3]);
275 275
 		//echo 'timestamp : '.$timestamp.' - now : '.time()."\n";
276 276
 		/*
277 277
 		if (time() + 3900 < $timestamp) $timestamp -= 86400;
278 278
 		elseif (time() - 82500 > $timestamp) $timestamp += 86400;
279 279
 		*/
280
-	    } elseif ($matches[4] == 'z' || $matches[4] == '/') {
280
+		} elseif ($matches[4] == 'z' || $matches[4] == '/') {
281 281
 		// This work or not ?
282 282
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
283
-	    }
284
-	    $body_parse = substr($body_parse,7);
285
-	    $result['timestamp'] = $timestamp;
286
-	    //echo date('Ymd H:i:s',$timestamp);
283
+		}
284
+		$body_parse = substr($body_parse,7);
285
+		$result['timestamp'] = $timestamp;
286
+		//echo date('Ymd H:i:s',$timestamp);
287 287
 	}
288 288
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
289
-	    $find = true;
290
-	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
291
-	    $body_parse = substr($body_parse,8);
292
-	    $result['timestamp'] = $timestamp;
293
-	    //echo date('Ymd H:i:s',$timestamp);
289
+		$find = true;
290
+		$timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
291
+		$body_parse = substr($body_parse,8);
292
+		$result['timestamp'] = $timestamp;
293
+		//echo date('Ymd H:i:s',$timestamp);
294 294
 	}
295 295
 	//if (strlen($body_parse) > 19) {
296
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
296
+		if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
297 297
 		$find = true;
298 298
 		// 4658.70N/00707.78Ez
299 299
 		//print_r(str_split($body_parse));
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 		$lon = intval($lon_deg);
313 313
 		if ($lat > 89 || $lon > 179) return false;
314 314
 	    
315
-	    /*
315
+		/*
316 316
 	    $tmp_5b = str_replace('.','',$lat_min);
317 317
 	    if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) {
318 318
 	        print_r($matches);
@@ -326,9 +326,9 @@  discard block
 block discarded – undo
326 326
 		$result['longitude'] = $longitude;
327 327
 		$body_parse = substr($body_parse,18);
328 328
 		$body_parse_len = strlen($body_parse);
329
-	    }
330
-	    $body_parse_len = strlen($body_parse);
331
-	    if ($body_parse_len > 0) {
329
+		}
330
+		$body_parse_len = strlen($body_parse);
331
+		if ($body_parse_len > 0) {
332 332
 		/*
333 333
 		if (!isset($result['timestamp']) && !isset($result['latitude'])) {
334 334
 			$body_split = str_split($body);
@@ -362,95 +362,95 @@  discard block
 block discarded – undo
362 362
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
363 363
 			if ($symbol_code != '_') {
364 364
 			}
365
-		    //$body_parse = substr($body_parse,1);
366
-		    //$body_parse = trim($body_parse);
367
-		    //$body_parse_len = strlen($body_parse);
368
-		    if ($body_parse_len >= 7) {
365
+			//$body_parse = substr($body_parse,1);
366
+			//$body_parse = trim($body_parse);
367
+			//$body_parse_len = strlen($body_parse);
368
+			if ($body_parse_len >= 7) {
369 369
 			
370
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
371
-		    	    $course = substr($body_parse,0,3);
372
-		    	    $tmp_s = intval($course);
373
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
374
-		    	    $speed = substr($body_parse,4,3);
375
-		    	    if ($speed != '...') {
376
-		    		//$result['speed'] = round($speed*1.852);
377
-		    		$result['speed'] = intval($speed);
378
-		    	    }
379
-		    	    $body_parse = substr($body_parse,7);
380
-		        }
381
-		        // Check PHGR, PHG, RNG
382
-		    } 
383
-		    /*
370
+				if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
371
+					$course = substr($body_parse,0,3);
372
+					$tmp_s = intval($course);
373
+					if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
374
+					$speed = substr($body_parse,4,3);
375
+					if ($speed != '...') {
376
+					//$result['speed'] = round($speed*1.852);
377
+					$result['speed'] = intval($speed);
378
+					}
379
+					$body_parse = substr($body_parse,7);
380
+				}
381
+				// Check PHGR, PHG, RNG
382
+			} 
383
+			/*
384 384
 		    else if ($body_parse_len > 0) {
385 385
 			$rest = $body_parse;
386 386
 		    }
387 387
 		    */
388
-		    if (strlen($body_parse) > 0) {
389
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
390
-		            $altitude = intval($matches[1]);
391
-		            //$result['altitude'] = round($altitude*0.3048);
392
-		            $result['altitude'] = $altitude;
393
-		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
394
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
395
-		        }
396
-		    }
388
+			if (strlen($body_parse) > 0) {
389
+				if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
390
+					$altitude = intval($matches[1]);
391
+					//$result['altitude'] = round($altitude*0.3048);
392
+					$result['altitude'] = $altitude;
393
+					//$body_parse = trim(substr($body_parse,strlen($matches[0])));
394
+					$body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
395
+				}
396
+			}
397 397
 		    
398
-		    // Telemetry
399
-		    /*
398
+			// Telemetry
399
+			/*
400 400
 		    if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) {
401 401
 		        // Nothing yet...
402 402
 		    }
403 403
 		    */
404
-		    // DAO
404
+			// DAO
405 405
 		    
406
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
406
+			if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
407 407
 			    
408
-			    $dao = $matches[1];
409
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
408
+				$dao = $matches[1];
409
+				if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
410 410
 				$dao_split = str_split($dao);
411
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
412
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
411
+					$lat_off = (($dao_split[1])-48.0)*0.001/60.0;
412
+					$lon_off = (($dao_split[2])-48.0)*0.001/60.0;
413 413
 			    
414 414
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
415 415
 				else $result['latitude'] += $lat_off;
416 416
 				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
417 417
 				else $result['longitude'] += $lon_off;
418
-			    }
418
+				}
419 419
 			    
420
-		            $body_parse = substr($body_parse,6);
421
-		    }
420
+					$body_parse = substr($body_parse,6);
421
+			}
422 422
 		    
423
-		    if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
423
+			if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
424 424
 			$result['ident'] = str_replace('_',' ',$matches[1]);
425
-		    }
426
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
425
+			}
426
+			if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
427 427
 			$result['squawk'] = $matches[1];
428
-		    }
429
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
428
+			}
429
+			if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
430 430
 			$result['aircraft_icao'] = $matches[1];
431
-		    }
432
-		    if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
431
+			}
432
+			if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
433 433
 			$result['verticalrate'] = $matches[1];
434
-		    }
435
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
434
+			}
435
+			if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
436 436
 			$result['typeid'] = $matches[1];
437
-		    }
438
-		    if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
437
+			}
438
+			if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
439 439
 			$result['statusid'] = $matches[1];
440
-		    }
441
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
440
+			}
441
+			if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
442 442
 			$result['imo'] = $matches[1];
443
-		    }
444
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
443
+			}
444
+			if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
445 445
 			$result['arrival_date'] = $matches[1];
446
-		    }
447
-		    if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
446
+			}
447
+			if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
448 448
 			$result['arrival_code'] = str_replace('_',' ',$matches[1]);
449
-		    }
450
-		    // OGN comment
449
+			}
450
+			// OGN comment
451 451
 		   // echo "Before OGN : ".$body_parse."\n";
452
-		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
453
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
452
+			//if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
453
+			if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
454 454
 			$id = $matches[1];
455 455
 			//$mode = substr($id,0,2);
456 456
 			$address = substr($id,2);
@@ -480,42 +480,42 @@  discard block
 block discarded – undo
480 480
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
481 481
 			$result['stealth'] = $stealth;
482 482
 			$result['address'] = $address;
483
-		    }
483
+			}
484 484
 		    
485
-		    //Comment
486
-		    $result['comment'] = trim($body_parse);
485
+			//Comment
486
+			$result['comment'] = trim($body_parse);
487 487
 		//} else {
488
-		    // parse weather
489
-		    //$body_parse = substr($body_parse,1);
490
-		    //$body_parse_len = strlen($body_parse);
491
-		    //echo 'weather'."\n";
492
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
493
-			    $result['wind_dir'] = intval($matches[1]);
494
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
495
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
496
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
497
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
498
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
488
+			// parse weather
489
+			//$body_parse = substr($body_parse,1);
490
+			//$body_parse_len = strlen($body_parse);
491
+			//echo 'weather'."\n";
492
+			if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
493
+				$result['wind_dir'] = intval($matches[1]);
494
+				$result['wind_speed'] = round(intval($matches[2])*1.60934,1);
495
+				$result['wind_gust'] = round(intval($matches[3])*1.60934,1);
496
+				$result['temp'] = round(5/9*((intval($matches[4]))-32),1);
497
+					$body_parse = substr($body_parse,strlen($matches[0])+1);
498
+			} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
499 499
 			$result['wind_dir'] = intval($matches[1]);
500 500
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
501 501
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
502 502
 			$result['temp'] = round(5/9*(($matches[4])-32),1);
503
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
504
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
503
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
504
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
505 505
 			$result['wind_dir'] = intval($matches[1]);
506 506
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
507 507
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
508
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
509
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
508
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
509
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
510 510
 			$result['wind_dir'] = intval($matches[1]);
511 511
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
512 512
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
513
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
514
-		    }
515
-		    //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
516
-		    //g012t088r000p000P000h38b10110
517
-		    //g011t086r000p000P000h29b10198
518
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
513
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
514
+			}
515
+			//if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
516
+			//g012t088r000p000P000h38b10110
517
+			//g011t086r000p000P000h29b10198
518
+			if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
519 519
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
520 520
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
521 521
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
@@ -523,8 +523,8 @@  discard block
 block discarded – undo
523 523
 			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
524 524
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
525 525
 			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
526
-		        $body_parse = substr($body_parse,strlen($matches[0]));
527
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
526
+				$body_parse = substr($body_parse,strlen($matches[0]));
527
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
528 528
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
529 529
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
530 530
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
@@ -532,8 +532,8 @@  discard block
 block discarded – undo
532 532
 			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
533 533
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
534 534
 			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
535
-		        $body_parse = substr($body_parse,strlen($matches[0]));
536
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
535
+				$body_parse = substr($body_parse,strlen($matches[0]));
536
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
537 537
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
538 538
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
539 539
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
@@ -541,58 +541,58 @@  discard block
 block discarded – undo
541 541
 			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
542 542
 			if ($matches[7] != '...') $result['humidity'] = intval($matches[7]);
543 543
 			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
544
-		        $body_parse = substr($body_parse,strlen($matches[0]));
545
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
544
+				$body_parse = substr($body_parse,strlen($matches[0]));
545
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
546 546
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
547 547
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
548 548
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
549 549
 			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
550 550
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
551 551
 			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
552
-		        $body_parse = substr($body_parse,strlen($matches[0]));
553
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
552
+				$body_parse = substr($body_parse,strlen($matches[0]));
553
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
554 554
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
555 555
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
556 556
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
557 557
 			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
558 558
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
559 559
 			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
560
-		        $body_parse = substr($body_parse,strlen($matches[0]));
561
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
560
+				$body_parse = substr($body_parse,strlen($matches[0]));
561
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
562 562
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
563 563
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
564 564
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
565 565
 			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
566 566
 			if ($matches[5] != '...') $result['humidity'] = intval($matches[5]);
567 567
 			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
568
-		        $body_parse = substr($body_parse,strlen($matches[0]));
569
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
568
+				$body_parse = substr($body_parse,strlen($matches[0]));
569
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
570 570
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
571 571
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
572 572
 			if ($matches[2] != '...') $result['humidity'] = intval($matches[3]);
573 573
 			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1);
574
-		        $body_parse = substr($body_parse,strlen($matches[0]));
575
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
574
+				$body_parse = substr($body_parse,strlen($matches[0]));
575
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
576 576
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
577 577
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
578 578
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
579 579
 			if ($matches[4] != '...') $result['humidity'] = intval($matches[4]);
580 580
 			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
581
-		        $body_parse = substr($body_parse,strlen($matches[0]));
582
-		    }
583
-		    $result['comment'] = trim($body_parse);
581
+				$body_parse = substr($body_parse,strlen($matches[0]));
582
+			}
583
+			$result['comment'] = trim($body_parse);
584 584
 		}
585 585
 		} else $result['comment'] = trim($body_parse);
586 586
 
587
-	    }
587
+		}
588 588
 	//}
589 589
 	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
590 590
 	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
591 591
 	if ($debug) print_r($result);
592 592
 	return $result;
593
-    }
593
+	}
594 594
     
595
-    public function connect() {
595
+	public function connect() {
596 596
 	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
597 597
 	$aprs_connect = 0;
598 598
 	$aprs_keep = 120;
@@ -616,24 +616,24 @@  discard block
 block discarded – undo
616 616
 		socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1);
617 617
 		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
618 618
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
619
-			    echo 'APRS user verified !'."\n";
620
-			    $this->connected = true;
621
-			    return true;
622
-			    break;
619
+				echo 'APRS user verified !'."\n";
620
+				$this->connected = true;
621
+				return true;
622
+				break;
623 623
 			}
624 624
 			if (time()-$authstart > 5) {
625
-			    echo 'APRS timeout'."\n";
626
-			    break;
625
+				echo 'APRS timeout'."\n";
626
+				break;
627 627
 			}
628 628
 		}
629 629
 	}
630
-    }
630
+	}
631 631
 
632
-    public function disconnect() {
632
+	public function disconnect() {
633 633
 	socket_close($this->socket);
634
-    }
634
+	}
635 635
     
636
-    public function send($data) {
636
+	public function send($data) {
637 637
 	global $globalDebug;
638 638
 	if ($this->connected === false) $this->connect();
639 639
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 		socket_close($this->socket);
643 643
 		$this->connect();
644 644
 	}
645
-    }
645
+	}
646 646
 }
647 647
 
648 648
 class APRSSpotter extends APRS {
Please login to merge, or discard this patch.
Spacing   +157 added lines, -158 removed lines patch added patch discarded remove patch
@@ -166,8 +166,7 @@  discard block
 block discarded – undo
166 166
 	
167 167
 
168 168
     private function urshift($n, $s) {
169
-	return ($n >= 0) ? ($n >> $s) :
170
-	    (($n & 0x7fffffff) >> $s) | 
169
+	return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| 
171 170
 		(0x40000000 >> ($s - 1));
172 171
     }
173 172
 
@@ -179,7 +178,7 @@  discard block
 block discarded – undo
179 178
 	//$split_input = str_split($input);
180 179
 
181 180
 	/* Find the end of header checking for NULL bytes while doing it. */
182
-	$splitpos = strpos($input,':');
181
+	$splitpos = strpos($input, ':');
183 182
 	
184 183
 	/* Check that end was found and body has at least one byte. */
185 184
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
@@ -189,15 +188,15 @@  discard block
 block discarded – undo
189 188
 	
190 189
 	if ($debug) echo 'input : '.$input."\n";
191 190
 	/* Save header and body. */
192
-	$body = substr($input,$splitpos+1,$input_len);
191
+	$body = substr($input, $splitpos + 1, $input_len);
193 192
 	$body_len = strlen($body);
194
-	$header = substr($input,0,$splitpos);
193
+	$header = substr($input, 0, $splitpos);
195 194
 	//$header_len = strlen($header);
196 195
 	if ($debug) echo 'header : '.$header."\n";
197 196
 	
198 197
 	/* Parse source, target and path. */
199 198
 	//FLRDF0A52>APRS,qAS,LSTB
200
-	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
199
+	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) {
201 200
 	    $ident = $matches[1];
202 201
 	    $all_elements = $matches[2];
203 202
 	    if ($ident == 'AIRCRAFT') {
@@ -214,14 +213,14 @@  discard block
 block discarded – undo
214 213
 	    if ($debug) 'No ident'."\n";
215 214
 	    return false;
216 215
 	}
217
-	$elements = explode(',',$all_elements);
216
+	$elements = explode(',', $all_elements);
218 217
 	$source = end($elements);
219 218
 	$result['source'] = $source;
220 219
 	foreach ($elements as $element) {
221
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
220
+	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) {
222 221
 	        //echo "ok";
223 222
 	        //if ($element == 'TCPIP*') return false;
224
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
223
+	    } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) {
225 224
 		if ($debug) echo 'element : '.$element."\n";
226 225
 		return false;
227 226
 	    }
@@ -234,14 +233,14 @@  discard block
 block discarded – undo
234 233
 	    */
235 234
 	}
236 235
 	
237
-	$type = substr($body,0,1);
236
+	$type = substr($body, 0, 1);
238 237
 	if ($debug) echo 'type : '.$type."\n";
239 238
 	if ($type == ';') {
240 239
 		if (isset($result['source_type']) && $result['source_type'] == 'modes') {
241
-			$result['address'] = trim(substr($body,1,9));
240
+			$result['address'] = trim(substr($body, 1, 9));
242 241
 		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
243
-			$result['mmsi'] = trim(substr($body,1,9));
244
-		} else $result['ident'] = trim(substr($body,1,9));
242
+			$result['mmsi'] = trim(substr($body, 1, 9));
243
+		} else $result['ident'] = trim(substr($body, 1, 9));
245 244
 	} elseif ($type == ',') {
246 245
 		// Invalid data or test data
247 246
 		return false;
@@ -249,24 +248,24 @@  discard block
 block discarded – undo
249 248
 	
250 249
 	// Check for Timestamp
251 250
 	$find = false;
252
-	$body_parse = substr($body,1);
251
+	$body_parse = substr($body, 1);
253 252
 	//echo 'Body : '.$body."\n";
254
-	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
255
-	    $body_parse = substr($body_parse,10);
253
+	if (preg_match('/^;(.){9}\*/', $body, $matches)) {
254
+	    $body_parse = substr($body_parse, 10);
256 255
 	    $find = true;
257 256
 	    //echo $body_parse."\n";
258 257
 	}
259
-	if (preg_match('/^`(.*)\//',$body,$matches)) {
260
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
258
+	if (preg_match('/^`(.*)\//', $body, $matches)) {
259
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
261 260
 	    $find = true;
262 261
 	    //echo $body_parse."\n";
263 262
 	}
264
-	if (preg_match("/^'(.*)\//",$body,$matches)) {
265
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
263
+	if (preg_match("/^'(.*)\//", $body, $matches)) {
264
+	    $body_parse = substr($body_parse, strlen($matches[1]) - 1);
266 265
 	    $find = true;
267 266
 	    //echo $body_parse."\n";
268 267
 	}
269
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
268
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) {
270 269
 	    $find = true;
271 270
 	    //print_r($matches);
272 271
 	    $timestamp = $matches[0];
@@ -281,19 +280,19 @@  discard block
 block discarded – undo
281 280
 		// This work or not ?
282 281
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
283 282
 	    }
284
-	    $body_parse = substr($body_parse,7);
283
+	    $body_parse = substr($body_parse, 7);
285 284
 	    $result['timestamp'] = $timestamp;
286 285
 	    //echo date('Ymd H:i:s',$timestamp);
287 286
 	}
288
-	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
287
+	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) {
289 288
 	    $find = true;
290 289
 	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
291
-	    $body_parse = substr($body_parse,8);
290
+	    $body_parse = substr($body_parse, 8);
292 291
 	    $result['timestamp'] = $timestamp;
293 292
 	    //echo date('Ymd H:i:s',$timestamp);
294 293
 	}
295 294
 	//if (strlen($body_parse) > 19) {
296
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
295
+	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) {
297 296
 		$find = true;
298 297
 		// 4658.70N/00707.78Ez
299 298
 		//print_r(str_split($body_parse));
@@ -320,11 +319,11 @@  discard block
 block discarded – undo
320 319
 	    */
321 320
 		$latitude = $lat + floatval($lat_min)/60;
322 321
 		$longitude = $lon + floatval($lon_min)/60;
323
-		if ($sind == 'S') $latitude = 0-$latitude;
324
-		if ($wind == 'W') $longitude = 0-$longitude;
322
+		if ($sind == 'S') $latitude = 0 - $latitude;
323
+		if ($wind == 'W') $longitude = 0 - $longitude;
325 324
 		$result['latitude'] = $latitude;
326 325
 		$result['longitude'] = $longitude;
327
-		$body_parse = substr($body_parse,18);
326
+		$body_parse = substr($body_parse, 18);
328 327
 		$body_parse_len = strlen($body_parse);
329 328
 	    }
330 329
 	    $body_parse_len = strlen($body_parse);
@@ -356,7 +355,7 @@  discard block
 block discarded – undo
356 355
 		//echo $body_parse;
357 356
 			//if ($type != ';' && $type != '>') {
358 357
 			if ($type != '') {
359
-			$body_parse = substr($body_parse,1);
358
+			$body_parse = substr($body_parse, 1);
360 359
 			$body_parse_len = strlen($body_parse);
361 360
 			$result['symbol_code'] = $symbol_code;
362 361
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
@@ -367,16 +366,16 @@  discard block
 block discarded – undo
367 366
 		    //$body_parse_len = strlen($body_parse);
368 367
 		    if ($body_parse_len >= 7) {
369 368
 			
370
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
371
-		    	    $course = substr($body_parse,0,3);
369
+		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) {
370
+		    	    $course = substr($body_parse, 0, 3);
372 371
 		    	    $tmp_s = intval($course);
373 372
 		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
374
-		    	    $speed = substr($body_parse,4,3);
373
+		    	    $speed = substr($body_parse, 4, 3);
375 374
 		    	    if ($speed != '...') {
376 375
 		    		//$result['speed'] = round($speed*1.852);
377 376
 		    		$result['speed'] = intval($speed);
378 377
 		    	    }
379
-		    	    $body_parse = substr($body_parse,7);
378
+		    	    $body_parse = substr($body_parse, 7);
380 379
 		        }
381 380
 		        // Check PHGR, PHG, RNG
382 381
 		    } 
@@ -386,12 +385,12 @@  discard block
 block discarded – undo
386 385
 		    }
387 386
 		    */
388 387
 		    if (strlen($body_parse) > 0) {
389
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
388
+		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) {
390 389
 		            $altitude = intval($matches[1]);
391 390
 		            //$result['altitude'] = round($altitude*0.3048);
392 391
 		            $result['altitude'] = $altitude;
393 392
 		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
394
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
393
+		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse));
395 394
 		        }
396 395
 		    }
397 396
 		    
@@ -403,13 +402,13 @@  discard block
 block discarded – undo
403 402
 		    */
404 403
 		    // DAO
405 404
 		    
406
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
405
+		    if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) {
407 406
 			    
408 407
 			    $dao = $matches[1];
409
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
408
+			    if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) {
410 409
 				$dao_split = str_split($dao);
411
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
412
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
410
+			        $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0;
411
+			        $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0;
413 412
 			    
414 413
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
415 414
 				else $result['latitude'] += $lat_off;
@@ -417,50 +416,50 @@  discard block
 block discarded – undo
417 416
 				else $result['longitude'] += $lon_off;
418 417
 			    }
419 418
 			    
420
-		            $body_parse = substr($body_parse,6);
419
+		            $body_parse = substr($body_parse, 6);
421 420
 		    }
422 421
 		    
423
-		    if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
424
-			$result['ident'] = str_replace('_',' ',$matches[1]);
422
+		    if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) {
423
+			$result['ident'] = str_replace('_', ' ', $matches[1]);
425 424
 		    }
426
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
425
+		    if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) {
427 426
 			$result['squawk'] = $matches[1];
428 427
 		    }
429
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
428
+		    if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) {
430 429
 			$result['aircraft_icao'] = $matches[1];
431 430
 		    }
432
-		    if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
431
+		    if (preg_match('/VR=([0-9]*)/', $body_parse, $matches)) {
433 432
 			$result['verticalrate'] = $matches[1];
434 433
 		    }
435
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
434
+		    if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) {
436 435
 			$result['typeid'] = $matches[1];
437 436
 		    }
438
-		    if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
437
+		    if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) {
439 438
 			$result['statusid'] = $matches[1];
440 439
 		    }
441
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
440
+		    if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) {
442 441
 			$result['imo'] = $matches[1];
443 442
 		    }
444
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
443
+		    if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) {
445 444
 			$result['arrival_date'] = $matches[1];
446 445
 		    }
447
-		    if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
448
-			$result['arrival_code'] = str_replace('_',' ',$matches[1]);
446
+		    if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) {
447
+			$result['arrival_code'] = str_replace('_', ' ', $matches[1]);
449 448
 		    }
450 449
 		    // OGN comment
451 450
 		   // echo "Before OGN : ".$body_parse."\n";
452 451
 		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
453
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
452
+		    if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) {
454 453
 			$id = $matches[1];
455 454
 			//$mode = substr($id,0,2);
456
-			$address = substr($id,2);
455
+			$address = substr($id, 2);
457 456
 			//print_r($matches);
458
-			$addressType = (intval(substr($id,0,2),16))&3;
457
+			$addressType = (intval(substr($id, 0, 2), 16))&3;
459 458
 			if ($addressType == 0) $result['addresstype'] = "RANDOM";
460 459
 			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
461 460
 			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
462 461
 			elseif ($addressType == 3) $result['addresstype'] = "OGN";
463
-			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
462
+			$aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2);
464 463
 			$result['aircrafttype_code'] = $aircraftType;
465 464
 			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
466 465
 			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
@@ -477,7 +476,7 @@  discard block
 block discarded – undo
477 476
 			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
478 477
 			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
479 478
 			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
480
-			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
479
+			$stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0;
481 480
 			$result['stealth'] = $stealth;
482 481
 			$result['address'] = $address;
483 482
 		    }
@@ -489,96 +488,96 @@  discard block
 block discarded – undo
489 488
 		    //$body_parse = substr($body_parse,1);
490 489
 		    //$body_parse_len = strlen($body_parse);
491 490
 		    //echo 'weather'."\n";
492
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
491
+		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
493 492
 			    $result['wind_dir'] = intval($matches[1]);
494
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
495
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
496
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
497
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
498
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
493
+			    $result['wind_speed'] = round(intval($matches[2])*1.60934, 1);
494
+			    $result['wind_gust'] = round(intval($matches[3])*1.60934, 1);
495
+			    $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1);
496
+		    	    $body_parse = substr($body_parse, strlen($matches[0]) + 1);
497
+		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
499 498
 			$result['wind_dir'] = intval($matches[1]);
500
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
501
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
502
-			$result['temp'] = round(5/9*(($matches[4])-32),1);
503
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
504
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
499
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
500
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
501
+			$result['temp'] = round(5/9*(($matches[4]) - 32), 1);
502
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
503
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) {
505 504
 			$result['wind_dir'] = intval($matches[1]);
506
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
507
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
508
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
509
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
505
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
506
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
507
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
508
+		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) {
510 509
 			$result['wind_dir'] = intval($matches[1]);
511
-			$result['wind_speed'] = round($matches[2]*1.60934,1);
512
-			$result['wind_gust'] = round($matches[3]*1.60934,1);
513
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
510
+			$result['wind_speed'] = round($matches[2]*1.60934, 1);
511
+			$result['wind_gust'] = round($matches[3]*1.60934, 1);
512
+		        $body_parse = substr($body_parse, strlen($matches[0]) + 1);
514 513
 		    }
515 514
 		    //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
516 515
 		    //g012t088r000p000P000h38b10110
517 516
 		    //g011t086r000p000P000h29b10198
518
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
519
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
520
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
521
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
522
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
523
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
517
+		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) {
518
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
519
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
520
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
521
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
522
+			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1);
524 523
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
525
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
526
-		        $body_parse = substr($body_parse,strlen($matches[0]));
527
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
528
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
529
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
530
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
531
-			if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1);
532
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
524
+			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1);
525
+		        $body_parse = substr($body_parse, strlen($matches[0]));
526
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/', $body_parse, $matches)) {
527
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
528
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
529
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
530
+			if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1, 1);
531
+			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1);
533 532
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
534
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
535
-		        $body_parse = substr($body_parse,strlen($matches[0]));
536
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
537
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
538
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
539
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
540
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
541
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
533
+			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10), 1);
534
+		        $body_parse = substr($body_parse, strlen($matches[0]));
535
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
536
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
537
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
538
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
539
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
540
+			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1, 1);
542 541
 			if ($matches[7] != '...') $result['humidity'] = intval($matches[7]);
543
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
544
-		        $body_parse = substr($body_parse,strlen($matches[0]));
545
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
546
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
547
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
548
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
549
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
542
+			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1);
543
+		        $body_parse = substr($body_parse, strlen($matches[0]));
544
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
545
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
546
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
547
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
548
+			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1, 1);
550 549
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
551
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
552
-		        $body_parse = substr($body_parse,strlen($matches[0]));
553
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
554
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
555
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
556
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
557
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
550
+			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
551
+		        $body_parse = substr($body_parse, strlen($matches[0]));
552
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/', $body_parse, $matches)) {
553
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
554
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
555
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
556
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
558 557
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
559
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
560
-		        $body_parse = substr($body_parse,strlen($matches[0]));
561
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
562
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
563
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
564
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
565
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
558
+			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
559
+		        $body_parse = substr($body_parse, strlen($matches[0]));
560
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
561
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
562
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
563
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
564
+			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1, 1);
566 565
 			if ($matches[5] != '...') $result['humidity'] = intval($matches[5]);
567
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
568
-		        $body_parse = substr($body_parse,strlen($matches[0]));
569
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
570
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
571
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
566
+			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10), 1);
567
+		        $body_parse = substr($body_parse, strlen($matches[0]));
568
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
569
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
570
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
572 571
 			if ($matches[2] != '...') $result['humidity'] = intval($matches[3]);
573
-			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1);
574
-		        $body_parse = substr($body_parse,strlen($matches[0]));
575
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
576
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
577
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
578
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
572
+			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10), 1);
573
+		        $body_parse = substr($body_parse, strlen($matches[0]));
574
+		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/', $body_parse, $matches)) {
575
+			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934, 1);
576
+			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2])) - 32), 1);
577
+			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1, 1);
579 578
 			if ($matches[4] != '...') $result['humidity'] = intval($matches[4]);
580
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
581
-		        $body_parse = substr($body_parse,strlen($matches[0]));
579
+			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10), 1);
580
+		        $body_parse = substr($body_parse, strlen($matches[0]));
582 581
 		    }
583 582
 		    $result['comment'] = trim($body_parse);
584 583
 		}
@@ -586,42 +585,42 @@  discard block
 block discarded – undo
586 585
 
587 586
 	    }
588 587
 	//}
589
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
590
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
588
+	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4);
589
+	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4);
591 590
 	if ($debug) print_r($result);
592 591
 	return $result;
593 592
     }
594 593
     
595 594
     public function connect() {
596
-	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
595
+	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport;
597 596
 	$aprs_connect = 0;
598 597
 	$aprs_keep = 120;
599 598
 	$aprs_last_tx = time();
600 599
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
601
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
600
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
602 601
 	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
603
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
602
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
604 603
 	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
605 604
 	else $aprs_pass = '-1';
606 605
 	
607
-	$aprs_filter  = '';
606
+	$aprs_filter = '';
608 607
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
609 608
 	$Common = new Common();
610
-	$s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr);
609
+	$s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr);
611 610
 	if ($s !== false) {
612 611
 		echo 'Connected to APRS server! '."\n";
613 612
 		$authstart = time();
614 613
 		$this->socket = $s;
615
-		$send = socket_send( $this->socket  , $aprs_login , strlen($aprs_login) , 0 );
616
-		socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1);
617
-		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
614
+		$send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0);
615
+		socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE, 1);
616
+		while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) {
618 617
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
619 618
 			    echo 'APRS user verified !'."\n";
620 619
 			    $this->connected = true;
621 620
 			    return true;
622 621
 			    break;
623 622
 			}
624
-			if (time()-$authstart > 5) {
623
+			if (time() - $authstart > 5) {
625 624
 			    echo 'APRS timeout'."\n";
626 625
 			    break;
627 626
 			}
@@ -636,7 +635,7 @@  discard block
 block discarded – undo
636 635
     public function send($data) {
637 636
 	global $globalDebug;
638 637
 	if ($this->connected === false) $this->connect();
639
-	$send = socket_send( $this->socket  , $data , strlen($data),0);
638
+	$send = socket_send($this->socket, $data, strlen($data), 0);
640 639
 	if ($send === FALSE) {
641 640
 		if ($globalDebug) echo 'Reconnect...';
642 641
 		socket_close($this->socket);
@@ -646,14 +645,14 @@  discard block
 block discarded – undo
646 645
 }
647 646
 
648 647
 class APRSSpotter extends APRS {
649
-	public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) {
648
+	public function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) {
650 649
 		$Common = new Common();
651 650
 		if ($latitude != '' && $longitude != '') {
652
-			$latitude = $Common->convertDM($latitude,'latitude');
653
-			$longitude = $Common->convertDM($longitude,'longitude');
654
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
655
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
656
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
651
+			$latitude = $Common->convertDM($latitude, 'latitude');
652
+			$longitude = $Common->convertDM($longitude, 'longitude');
653
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
654
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
655
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
657 656
 			$w = $w1.$w2;
658 657
 			//$w = '00';
659 658
 			$custom = '';
@@ -674,25 +673,25 @@  discard block
 block discarded – undo
674 673
 				$custom .= 'AI='.$aircraft_icao;
675 674
 			}
676 675
 			if ($custom != '') $custom = ' '.$custom;
677
-			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
676
+			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His', strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
678 677
 		}
679 678
 	}
680 679
 }
681 680
 class APRSMarine extends APRS {
682
-	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source,$source_name,$over_country) {
681
+	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country) {
683 682
 		$Common = new Common();
684 683
 		if ($latitude != '' && $longitude != '') {
685
-			$latitude = $Common->convertDM($latitude,'latitude');
686
-			$longitude = $Common->convertDM($longitude,'longitude');
687
-			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW'];
688
-			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000));
689
-			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000));
684
+			$latitude = $Common->convertDM($latitude, 'latitude');
685
+			$longitude = $Common->convertDM($longitude, 'longitude');
686
+			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW'];
687
+			$w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000));
688
+			$w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000));
690 689
 			$w = $w1.$w2;
691 690
 			//$w = '00';
692 691
 			$custom = '';
693 692
 			if ($ident != '') {
694 693
 				if ($custom != '') $custom .= '/';
695
-				$custom .= 'CS='.str_replace(' ','_',$ident);
694
+				$custom .= 'CS='.str_replace(' ', '_', $ident);
696 695
 			}
697 696
 			if ($typeid != '') {
698 697
 				if ($custom != '') $custom .= '/';
@@ -712,11 +711,11 @@  discard block
 block discarded – undo
712 711
 			}
713 712
 			if ($arrival_code != '') {
714 713
 				if ($custom != '') $custom .= '/';
715
-				$custom .= 'AC='.str_replace(' ','_',$arrival_code);
714
+				$custom .= 'AC='.str_replace(' ', '_', $arrival_code);
716 715
 			}
717 716
 			if ($custom != '') $custom = ' '.$custom;
718 717
 			$altitude = 0;
719
-			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
718
+			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
720 719
 		}
721 720
 	}
722 721
 }
Please login to merge, or discard this patch.
Braces   +307 added lines, -110 removed lines patch added patch discarded remove patch
@@ -183,17 +183,23 @@  discard block
 block discarded – undo
183 183
 	
184 184
 	/* Check that end was found and body has at least one byte. */
185 185
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
186
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
186
+	    if ($globalDebug) {
187
+	    	echo '!!! APRS invalid : '.$input."\n";
188
+	    }
187 189
 	    return false;
188 190
 	}
189 191
 	
190
-	if ($debug) echo 'input : '.$input."\n";
192
+	if ($debug) {
193
+		echo 'input : '.$input."\n";
194
+	}
191 195
 	/* Save header and body. */
192 196
 	$body = substr($input,$splitpos+1,$input_len);
193 197
 	$body_len = strlen($body);
194 198
 	$header = substr($input,0,$splitpos);
195 199
 	//$header_len = strlen($header);
196
-	if ($debug) echo 'header : '.$header."\n";
200
+	if ($debug) {
201
+		echo 'header : '.$header."\n";
202
+	}
197 203
 	
198 204
 	/* Parse source, target and path. */
199 205
 	//FLRDF0A52>APRS,qAS,LSTB
@@ -207,11 +213,15 @@  discard block
 block discarded – undo
207 213
 		$result['format_source'] = 'famaprs';
208 214
 		$result['source_type'] = 'ais';
209 215
 	    } else {
210
-		if ($debug) echo 'ident : '.$ident."\n";
216
+		if ($debug) {
217
+			echo 'ident : '.$ident."\n";
218
+		}
211 219
 		$result['ident'] = $ident;
212 220
 	    }
213 221
 	} else {
214
-	    if ($debug) 'No ident'."\n";
222
+	    if ($debug) {
223
+	    	'No ident'."\n";
224
+	    }
215 225
 	    return false;
216 226
 	}
217 227
 	$elements = explode(',',$all_elements);
@@ -222,7 +232,9 @@  discard block
 block discarded – undo
222 232
 	        //echo "ok";
223 233
 	        //if ($element == 'TCPIP*') return false;
224 234
 	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
225
-		if ($debug) echo 'element : '.$element."\n";
235
+		if ($debug) {
236
+			echo 'element : '.$element."\n";
237
+		}
226 238
 		return false;
227 239
 	    }
228 240
 	    /*
@@ -235,13 +247,17 @@  discard block
 block discarded – undo
235 247
 	}
236 248
 	
237 249
 	$type = substr($body,0,1);
238
-	if ($debug) echo 'type : '.$type."\n";
250
+	if ($debug) {
251
+		echo 'type : '.$type."\n";
252
+	}
239 253
 	if ($type == ';') {
240 254
 		if (isset($result['source_type']) && $result['source_type'] == 'modes') {
241 255
 			$result['address'] = trim(substr($body,1,9));
242 256
 		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
243 257
 			$result['mmsi'] = trim(substr($body,1,9));
244
-		} else $result['ident'] = trim(substr($body,1,9));
258
+		} else {
259
+			$result['ident'] = trim(substr($body,1,9));
260
+		}
245 261
 	} elseif ($type == ',') {
246 262
 		// Invalid data or test data
247 263
 		return false;
@@ -310,7 +326,9 @@  discard block
 block discarded – undo
310 326
 		//$symbol_table = $matches[4];
311 327
 		$lat = intval($lat_deg);
312 328
 		$lon = intval($lon_deg);
313
-		if ($lat > 89 || $lon > 179) return false;
329
+		if ($lat > 89 || $lon > 179) {
330
+			return false;
331
+		}
314 332
 	    
315 333
 	    /*
316 334
 	    $tmp_5b = str_replace('.','',$lat_min);
@@ -320,8 +338,12 @@  discard block
 block discarded – undo
320 338
 	    */
321 339
 		$latitude = $lat + floatval($lat_min)/60;
322 340
 		$longitude = $lon + floatval($lon_min)/60;
323
-		if ($sind == 'S') $latitude = 0-$latitude;
324
-		if ($wind == 'W') $longitude = 0-$longitude;
341
+		if ($sind == 'S') {
342
+			$latitude = 0-$latitude;
343
+		}
344
+		if ($wind == 'W') {
345
+			$longitude = 0-$longitude;
346
+		}
325 347
 		$result['latitude'] = $latitude;
326 348
 		$result['longitude'] = $longitude;
327 349
 		$body_parse = substr($body_parse,18);
@@ -349,8 +371,11 @@  discard block
 block discarded – undo
349 371
 			//echo 'find'."\n";
350 372
 			$body_split = str_split($body_parse);
351 373
 			$symbol_code = $body_split[0];
352
-			if (!isset($symbolll) || $symbolll == '/') $symbol_code = '/'.$symbol_code;
353
-			else $symbol_code = '\\'.$symbol_code;
374
+			if (!isset($symbolll) || $symbolll == '/') {
375
+				$symbol_code = '/'.$symbol_code;
376
+			} else {
377
+				$symbol_code = '\\'.$symbol_code;
378
+			}
354 379
 		//'
355 380
 		//}
356 381
 		//echo $body_parse;
@@ -359,7 +384,9 @@  discard block
 block discarded – undo
359 384
 			$body_parse = substr($body_parse,1);
360 385
 			$body_parse_len = strlen($body_parse);
361 386
 			$result['symbol_code'] = $symbol_code;
362
-			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
387
+			if (isset($this->symbols[$symbol_code])) {
388
+				$result['symbol'] = $this->symbols[$symbol_code];
389
+			}
363 390
 			if ($symbol_code != '_') {
364 391
 			}
365 392
 		    //$body_parse = substr($body_parse,1);
@@ -370,7 +397,9 @@  discard block
 block discarded – undo
370 397
 		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
371 398
 		    	    $course = substr($body_parse,0,3);
372 399
 		    	    $tmp_s = intval($course);
373
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
400
+		    	    if ($tmp_s >= 1 && $tmp_s <= 360) {
401
+		    	    	$result['heading'] = intval($course);
402
+		    	    }
374 403
 		    	    $speed = substr($body_parse,4,3);
375 404
 		    	    if ($speed != '...') {
376 405
 		    		//$result['speed'] = round($speed*1.852);
@@ -411,10 +440,16 @@  discard block
 block discarded – undo
411 440
 			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
412 441
 			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
413 442
 			    
414
-				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
415
-				else $result['latitude'] += $lat_off;
416
-				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
417
-				else $result['longitude'] += $lon_off;
443
+				if ($result['latitude'] < 0) {
444
+					$result['latitude'] -= $lat_off;
445
+				} else {
446
+					$result['latitude'] += $lat_off;
447
+				}
448
+				if ($result['longitude'] < 0) {
449
+					$result['longitude'] -= $lon_off;
450
+				} else {
451
+					$result['longitude'] += $lon_off;
452
+				}
418 453
 			    }
419 454
 			    
420 455
 		            $body_parse = substr($body_parse,6);
@@ -456,27 +491,48 @@  discard block
 block discarded – undo
456 491
 			$address = substr($id,2);
457 492
 			//print_r($matches);
458 493
 			$addressType = (intval(substr($id,0,2),16))&3;
459
-			if ($addressType == 0) $result['addresstype'] = "RANDOM";
460
-			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
461
-			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
462
-			elseif ($addressType == 3) $result['addresstype'] = "OGN";
494
+			if ($addressType == 0) {
495
+				$result['addresstype'] = "RANDOM";
496
+			} elseif ($addressType == 1) {
497
+				$result['addresstype'] = "ICAO";
498
+			} elseif ($addressType == 2) {
499
+				$result['addresstype'] = "FLARM";
500
+			} elseif ($addressType == 3) {
501
+				$result['addresstype'] = "OGN";
502
+			}
463 503
 			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
464 504
 			$result['aircrafttype_code'] = $aircraftType;
465
-			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
466
-			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
467
-			elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE";
468
-			elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
469
-			elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE";
470
-			elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE";
471
-			elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER";
472
-			elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER";
473
-			elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT";
474
-			elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT";
475
-			elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO";
476
-			elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON";
477
-			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
478
-			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
479
-			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
505
+			if ($aircraftType == 0) {
506
+				$result['aircrafttype'] = "UNKNOWN";
507
+			} elseif ($aircraftType == 1) {
508
+				$result['aircrafttype'] = "GLIDER";
509
+			} elseif ($aircraftType == 2) {
510
+				$result['aircrafttype'] = "TOW_PLANE";
511
+			} elseif ($aircraftType == 3) {
512
+				$result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
513
+			} elseif ($aircraftType == 4) {
514
+				$result['aircrafttype'] = "PARACHUTE";
515
+			} elseif ($aircraftType == 5) {
516
+				$result['aircrafttype'] = "DROP_PLANE";
517
+			} elseif ($aircraftType == 6) {
518
+				$result['aircrafttype'] = "HANG_GLIDER";
519
+			} elseif ($aircraftType == 7) {
520
+				$result['aircrafttype'] = "PARA_GLIDER";
521
+			} elseif ($aircraftType == 8) {
522
+				$result['aircrafttype'] = "POWERED_AIRCRAFT";
523
+			} elseif ($aircraftType == 9) {
524
+				$result['aircrafttype'] = "JET_AIRCRAFT";
525
+			} elseif ($aircraftType == 10) {
526
+				$result['aircrafttype'] = "UFO";
527
+			} elseif ($aircraftType == 11) {
528
+				$result['aircrafttype'] = "BALLOON";
529
+			} elseif ($aircraftType == 12) {
530
+				$result['aircrafttype'] = "AIRSHIP";
531
+			} elseif ($aircraftType == 13) {
532
+				$result['aircrafttype'] = "UAV";
533
+			} elseif ($aircraftType == 15) {
534
+				$result['aircrafttype'] = "STATIC_OBJECT";
535
+			}
480 536
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
481 537
 			$result['stealth'] = $stealth;
482 538
 			$result['address'] = $address;
@@ -516,79 +572,183 @@  discard block
 block discarded – undo
516 572
 		    //g012t088r000p000P000h38b10110
517 573
 		    //g011t086r000p000P000h29b10198
518 574
 		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
519
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
520
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
521
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
522
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
523
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
524
-			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
525
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
575
+			if ($matches[1] != '...') {
576
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
577
+			}
578
+			if ($matches[2] != '...') {
579
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
580
+			}
581
+			if ($matches[3] != '...') {
582
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
583
+			}
584
+			if ($matches[4] != '...') {
585
+				$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
586
+			}
587
+			if ($matches[5] != '...') {
588
+				$result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
589
+			}
590
+			if ($matches[6] != '...') {
591
+				$result['humidity'] = intval($matches[6]);
592
+			}
593
+			if ($matches[7] != '...') {
594
+				$result['pressure'] = round((intval($matches[7])/10),1);
595
+			}
526 596
 		        $body_parse = substr($body_parse,strlen($matches[0]));
527 597
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
528
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
529
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
530
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
531
-			if ($matches[5] != '...') $result['precipitation'] = round((intval($matches[5])/100)*25.1,1);
532
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
533
-			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
534
-			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
598
+			if ($matches[1] != '...') {
599
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
600
+			}
601
+			if ($matches[2] != '...') {
602
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
603
+			}
604
+			if ($matches[3] != '...') {
605
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
606
+			}
607
+			if ($matches[5] != '...') {
608
+				$result['precipitation'] = round((intval($matches[5])/100)*25.1,1);
609
+			}
610
+			if ($matches[4] != '...') {
611
+				$result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
612
+			}
613
+			if ($matches[6] != '...') {
614
+				$result['humidity'] = intval($matches[6]);
615
+			}
616
+			if ($matches[7] != '...') {
617
+				$result['pressure'] = round((intval($matches[7])/10),1);
618
+			}
535 619
 		        $body_parse = substr($body_parse,strlen($matches[0]));
536 620
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
537
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
538
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
539
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
540
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
541
-			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
542
-			if ($matches[7] != '...') $result['humidity'] = intval($matches[7]);
543
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
621
+			if ($matches[1] != '...') {
622
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
623
+			}
624
+			if ($matches[2] != '...') {
625
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
626
+			}
627
+			if ($matches[3] != '...') {
628
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
629
+			}
630
+			if ($matches[4] != '...') {
631
+				$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
632
+			}
633
+			if ($matches[5] != '...') {
634
+				$result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
635
+			}
636
+			if ($matches[7] != '...') {
637
+				$result['humidity'] = intval($matches[7]);
638
+			}
639
+			if ($matches[6] != '...') {
640
+				$result['pressure'] = round((intval($matches[6])/10),1);
641
+			}
544 642
 		        $body_parse = substr($body_parse,strlen($matches[0]));
545 643
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
546
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
547
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
548
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
549
-			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
550
-			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
551
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
644
+			if ($matches[1] != '...') {
645
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
646
+			}
647
+			if ($matches[2] != '...') {
648
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
649
+			}
650
+			if ($matches[3] != '...') {
651
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
652
+			}
653
+			if ($matches[4] != '...') {
654
+				$result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
655
+			}
656
+			if ($matches[6] != '...') {
657
+				$result['humidity'] = intval($matches[6]);
658
+			}
659
+			if ($matches[5] != '...') {
660
+				$result['pressure'] = round((intval($matches[5])/10),1);
661
+			}
552 662
 		        $body_parse = substr($body_parse,strlen($matches[0]));
553 663
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
554
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
555
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
556
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
557
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
558
-			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
559
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
664
+			if ($matches[1] != '...') {
665
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
666
+			}
667
+			if ($matches[2] != '...') {
668
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
669
+			}
670
+			if ($matches[3] != '...') {
671
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
672
+			}
673
+			if ($matches[4] != '...') {
674
+				$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
675
+			}
676
+			if ($matches[6] != '...') {
677
+				$result['humidity'] = intval($matches[6]);
678
+			}
679
+			if ($matches[5] != '...') {
680
+				$result['pressure'] = round((intval($matches[5])/10),1);
681
+			}
560 682
 		        $body_parse = substr($body_parse,strlen($matches[0]));
561 683
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
562
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
563
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
564
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
565
-			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
566
-			if ($matches[5] != '...') $result['humidity'] = intval($matches[5]);
567
-			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
684
+			if ($matches[1] != '...') {
685
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
686
+			}
687
+			if ($matches[2] != '...') {
688
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
689
+			}
690
+			if ($matches[3] != '...') {
691
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
692
+			}
693
+			if ($matches[4] != '...') {
694
+				$result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
695
+			}
696
+			if ($matches[5] != '...') {
697
+				$result['humidity'] = intval($matches[5]);
698
+			}
699
+			if ($matches[6] != '...') {
700
+				$result['pressure'] = round((intval($matches[6])/10),1);
701
+			}
568 702
 		        $body_parse = substr($body_parse,strlen($matches[0]));
569 703
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
570
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
571
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
572
-			if ($matches[2] != '...') $result['humidity'] = intval($matches[3]);
573
-			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1);
704
+			if ($matches[1] != '...') {
705
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
706
+			}
707
+			if ($matches[2] != '...') {
708
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
709
+			}
710
+			if ($matches[2] != '...') {
711
+				$result['humidity'] = intval($matches[3]);
712
+			}
713
+			if ($matches[4] != '...') {
714
+				$result['pressure'] = round((intval($matches[4])/10),1);
715
+			}
574 716
 		        $body_parse = substr($body_parse,strlen($matches[0]));
575 717
 		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
576
-			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
577
-			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
578
-			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
579
-			if ($matches[4] != '...') $result['humidity'] = intval($matches[4]);
580
-			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
718
+			if ($matches[1] != '...') {
719
+				$result['wind_gust'] = round($matches[1]*1.60934,1);
720
+			}
721
+			if ($matches[2] != '...') {
722
+				$result['temp'] = round(5/9*((intval($matches[2]))-32),1);
723
+			}
724
+			if ($matches[3] != '...') {
725
+				$result['rain'] = round((intval($matches[3])/100)*25.1,1);
726
+			}
727
+			if ($matches[4] != '...') {
728
+				$result['humidity'] = intval($matches[4]);
729
+			}
730
+			if ($matches[5] != '...') {
731
+				$result['pressure'] = round((intval($matches[5])/10),1);
732
+			}
581 733
 		        $body_parse = substr($body_parse,strlen($matches[0]));
582 734
 		    }
583 735
 		    $result['comment'] = trim($body_parse);
584 736
 		}
585
-		} else $result['comment'] = trim($body_parse);
737
+		} else {
738
+			$result['comment'] = trim($body_parse);
739
+		}
586 740
 
587 741
 	    }
588 742
 	//}
589
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
590
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
591
-	if ($debug) print_r($result);
743
+	if (isset($result['latitude'])) {
744
+		$result['latitude'] = round($result['latitude'],4);
745
+	}
746
+	if (isset($result['longitude'])) {
747
+		$result['longitude'] = round($result['longitude'],4);
748
+	}
749
+	if ($debug) {
750
+		print_r($result);
751
+	}
592 752
 	return $result;
593 753
     }
594 754
     
@@ -597,12 +757,21 @@  discard block
 block discarded – undo
597 757
 	$aprs_connect = 0;
598 758
 	$aprs_keep = 120;
599 759
 	$aprs_last_tx = time();
600
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
601
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
602
-	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
603
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
604
-	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
605
-	else $aprs_pass = '-1';
760
+	if (isset($globalAPRSversion)) {
761
+		$aprs_version = $globalAPRSversion;
762
+	} else {
763
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
764
+	}
765
+	if (isset($globalServerAPRSssid)) {
766
+		$aprs_ssid = $globalServerAPRSssid;
767
+	} else {
768
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
769
+	}
770
+	if (isset($globalServerAPRSpass)) {
771
+		$aprs_pass = $globalServerAPRSpass;
772
+	} else {
773
+		$aprs_pass = '-1';
774
+	}
606 775
 	
607 776
 	$aprs_filter  = '';
608 777
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
@@ -635,10 +804,14 @@  discard block
 block discarded – undo
635 804
     
636 805
     public function send($data) {
637 806
 	global $globalDebug;
638
-	if ($this->connected === false) $this->connect();
807
+	if ($this->connected === false) {
808
+		$this->connect();
809
+	}
639 810
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
640 811
 	if ($send === FALSE) {
641
-		if ($globalDebug) echo 'Reconnect...';
812
+		if ($globalDebug) {
813
+			echo 'Reconnect...';
814
+		}
642 815
 		socket_close($this->socket);
643 816
 		$this->connect();
644 817
 	}
@@ -658,22 +831,32 @@  discard block
 block discarded – undo
658 831
 			//$w = '00';
659 832
 			$custom = '';
660 833
 			if ($ident != '') {
661
-				if ($custom != '') $custom .= '/';
834
+				if ($custom != '') {
835
+					$custom .= '/';
836
+				}
662 837
 				$custom .= 'CS='.$ident;
663 838
 			}
664 839
 			if ($squawk != '') {
665
-				if ($custom != '') $custom .= '/';
840
+				if ($custom != '') {
841
+					$custom .= '/';
842
+				}
666 843
 				$custom .= 'SQ='.$squawk;
667 844
 			}
668 845
 			if ($verticalrate != '') {
669
-				if ($custom != '') $custom .= '/';
846
+				if ($custom != '') {
847
+					$custom .= '/';
848
+				}
670 849
 				$custom .= 'VR='.$verticalrate;
671 850
 			}
672 851
 			if ($aircraft_icao != '' && $aircraft_icao != 'NA') {
673
-				if ($custom != '') $custom .= '/';
852
+				if ($custom != '') {
853
+					$custom .= '/';
854
+				}
674 855
 				$custom .= 'AI='.$aircraft_icao;
675 856
 			}
676
-			if ($custom != '') $custom = ' '.$custom;
857
+			if ($custom != '') {
858
+				$custom = ' '.$custom;
859
+			}
677 860
 			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
678 861
 		}
679 862
 	}
@@ -691,30 +874,44 @@  discard block
 block discarded – undo
691 874
 			//$w = '00';
692 875
 			$custom = '';
693 876
 			if ($ident != '') {
694
-				if ($custom != '') $custom .= '/';
877
+				if ($custom != '') {
878
+					$custom .= '/';
879
+				}
695 880
 				$custom .= 'CS='.str_replace(' ','_',$ident);
696 881
 			}
697 882
 			if ($typeid != '') {
698
-				if ($custom != '') $custom .= '/';
883
+				if ($custom != '') {
884
+					$custom .= '/';
885
+				}
699 886
 				$custom .= 'TI='.$typeid;
700 887
 			}
701 888
 			if ($statusid != '') {
702
-				if ($custom != '') $custom .= '/';
889
+				if ($custom != '') {
890
+					$custom .= '/';
891
+				}
703 892
 				$custom .= 'SI='.$statusid;
704 893
 			}
705 894
 			if ($imo != '') {
706
-				if ($custom != '') $custom .= '/';
895
+				if ($custom != '') {
896
+					$custom .= '/';
897
+				}
707 898
 				$custom .= 'IMO='.$imo;
708 899
 			}
709 900
 			if ($arrival_date != '') {
710
-				if ($custom != '') $custom .= '/';
901
+				if ($custom != '') {
902
+					$custom .= '/';
903
+				}
711 904
 				$custom .= 'AD='.strtotime($arrival_date);
712 905
 			}
713 906
 			if ($arrival_code != '') {
714
-				if ($custom != '') $custom .= '/';
907
+				if ($custom != '') {
908
+					$custom .= '/';
909
+				}
715 910
 				$custom .= 'AC='.str_replace(' ','_',$arrival_code);
716 911
 			}
717
-			if ($custom != '') $custom = ' '.$custom;
912
+			if ($custom != '') {
913
+				$custom = ' '.$custom;
914
+			}
718 915
 			$altitude = 0;
719 916
 			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
720 917
 		}
Please login to merge, or discard this patch.