Completed
Push — master ( 090b05...8fa80b )
by Yannick
07:04
created
scripts/daemon-spotter.php 1 patch
Indentation   +902 added lines, -902 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,18 +298,18 @@  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
-    }
301
+	if (!isset($source['format'])) {
302
+		$globalSources[$key]['format'] = 'auto';
303
+	}
304 304
 }
305 305
 connect_all($globalSources);
306 306
 foreach ($globalSources as $key => $source) {
307
-    if (isset($source['format']) && $source['format'] == 'aprs') {
307
+	if (isset($source['format']) && $source['format'] == 'aprs') {
308 308
 	$aprs_connect = 0;
309 309
 	$use_aprs = true;
310 310
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
311 311
 	break;
312
-    }
312
+	}
313 313
 }
314 314
 
315 315
 if ($use_aprs) {
@@ -350,115 +350,115 @@  discard block
 block discarded – undo
350 350
 
351 351
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
352 352
 while ($i > 0) {
353
-    if (!$globalDaemon) $i = $endtime-time();
354
-    // Delete old ATC
355
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
353
+	if (!$globalDaemon) $i = $endtime-time();
354
+	// Delete old ATC
355
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
356 356
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
357
-        $ATC->deleteOldATC();
358
-    }
357
+		$ATC->deleteOldATC();
358
+	}
359 359
     
360
-    if (count($last_exec) == count($globalSources)) {
360
+	if (count($last_exec) == count($globalSources)) {
361 361
 	$max = $globalMinFetch;
362 362
 	foreach ($last_exec as $last) {
363
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
363
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
364 364
 	}
365 365
 	if ($max != $globalMinFetch) {
366
-	    if ($globalDebug) echo 'Sleeping...'."\n";
367
-	    sleep($globalMinFetch-$max+2);
366
+		if ($globalDebug) echo 'Sleeping...'."\n";
367
+		sleep($globalMinFetch-$max+2);
368
+	}
368 369
 	}
369
-    }
370 370
 
371 371
     
372
-    //foreach ($formats as $id => $value) {
373
-    foreach ($globalSources as $id => $value) {
372
+	//foreach ($formats as $id => $value) {
373
+	foreach ($globalSources as $id => $value) {
374 374
 	date_default_timezone_set('UTC');
375 375
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
376 376
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
377
-	    //$buffer = $Common->getData($hosts[$id]);
378
-	    $buffer = $Common->getData($value['host']);
379
-	    if ($buffer != '') $reset = 0;
380
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
381
-	    $buffer = explode('\n',$buffer);
382
-	    foreach ($buffer as $line) {
383
-    		if ($line != '' && count($line) > 7) {
384
-    		    $line = explode(',', $line);
385
-	            $data = array();
386
-	            $data['hex'] = $line[1]; // hex
387
-	            $data['ident'] = $line[2]; // ident
388
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
389
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
390
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
391
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
392
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
393
-	            $data['verticalrate'] = ''; // vertical rate
394
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
395
-	            $data['emergency'] = ''; // emergency
396
-		    $data['datetime'] = date('Y-m-d H:i:s');
397
-		    $data['format_source'] = 'deltadbtxt';
398
-    		    $data['id_source'] = $id_source;
399
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
400
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
401
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
402
-    		    $SI->add($data);
403
-		    unset($data);
404
-    		}
405
-    	    }
406
-    	    $last_exec[$id]['last'] = time();
377
+		//$buffer = $Common->getData($hosts[$id]);
378
+		$buffer = $Common->getData($value['host']);
379
+		if ($buffer != '') $reset = 0;
380
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
381
+		$buffer = explode('\n',$buffer);
382
+		foreach ($buffer as $line) {
383
+			if ($line != '' && count($line) > 7) {
384
+				$line = explode(',', $line);
385
+				$data = array();
386
+				$data['hex'] = $line[1]; // hex
387
+				$data['ident'] = $line[2]; // ident
388
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
389
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
390
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
391
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
392
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
393
+				$data['verticalrate'] = ''; // vertical rate
394
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
395
+				$data['emergency'] = ''; // emergency
396
+			$data['datetime'] = date('Y-m-d H:i:s');
397
+			$data['format_source'] = 'deltadbtxt';
398
+				$data['id_source'] = $id_source;
399
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
400
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
401
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
402
+				$SI->add($data);
403
+			unset($data);
404
+			}
405
+			}
406
+			$last_exec[$id]['last'] = time();
407 407
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
408
-	    date_default_timezone_set('CET');
409
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
410
-	    date_default_timezone_set('UTC');
411
-	    if ($buffer != '') $reset = 0;
412
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
413
-	    $buffer = explode('\n',$buffer);
414
-	    foreach ($buffer as $line) {
408
+		date_default_timezone_set('CET');
409
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
410
+		date_default_timezone_set('UTC');
411
+		if ($buffer != '') $reset = 0;
412
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
413
+		$buffer = explode('\n',$buffer);
414
+		foreach ($buffer as $line) {
415 415
 		if ($line != '') {
416
-		    echo "'".$line."'\n";
417
-		    $add = false;
418
-		    $ais_data = $AIS->parse_line(trim($line));
419
-		    $data = array();
420
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
421
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
422
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
423
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
424
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
425
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
426
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
427
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
428
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
429
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
430
-		    if (isset($ais_data['timestamp'])) {
416
+			echo "'".$line."'\n";
417
+			$add = false;
418
+			$ais_data = $AIS->parse_line(trim($line));
419
+			$data = array();
420
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
421
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
422
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
423
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
424
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
425
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
426
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
427
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
428
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
429
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
430
+			if (isset($ais_data['timestamp'])) {
431 431
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
432 432
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
433
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
434
-			    $add = true;
433
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
434
+				$add = true;
435 435
 			}
436
-		    } else {
436
+			} else {
437 437
 			$data['datetime'] = date('Y-m-d H:i:s');
438 438
 			$add = true;
439
-		    }
440
-		    $data['format_source'] = 'aisnmeatxt';
441
-    		    $data['id_source'] = $id_source;
442
-		    //print_r($data);
443
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
444
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
445
-		    unset($data);
439
+			}
440
+			$data['format_source'] = 'aisnmeatxt';
441
+				$data['id_source'] = $id_source;
442
+			//print_r($data);
443
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
444
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
445
+			unset($data);
446 446
 		}
447
-    	    }
448
-    	    $last_exec[$id]['last'] = time();
447
+			}
448
+			$last_exec[$id]['last'] = time();
449 449
 	} elseif ($value['format'] == 'aisnmeahttp') {
450
-	    $arr = $httpfeeds;
451
-	    $w = $e = null;
450
+		$arr = $httpfeeds;
451
+		$w = $e = null;
452 452
 	    
453
-	    if (isset($arr[$id])) {
453
+		if (isset($arr[$id])) {
454 454
 		$nn = stream_select($arr,$w,$e,$timeout);
455 455
 		if ($nn > 0) {
456
-		    foreach ($httpfeeds as $feed) {
456
+			foreach ($httpfeeds as $feed) {
457 457
 			$buffer = stream_get_line($feed,2000,"\n");
458 458
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
459 459
 			$buffer = explode('\n',$buffer);
460 460
 			foreach ($buffer as $line) {
461
-			    if ($line != '') {
461
+				if ($line != '') {
462 462
 				$ais_data = $AIS->parse_line(trim($line));
463 463
 				$data = array();
464 464
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -476,96 +476,96 @@  discard block
 block discarded – undo
476 476
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
477 477
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
478 478
 				if (isset($ais_data['timestamp'])) {
479
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
479
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
480 480
 				} else {
481
-				    $data['datetime'] = date('Y-m-d H:i:s');
481
+					$data['datetime'] = date('Y-m-d H:i:s');
482 482
 				}
483 483
 				$data['format_source'] = 'aisnmeahttp';
484 484
 				$data['id_source'] = $id_source;
485 485
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
486 486
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
487 487
 				unset($data);
488
-			    }
488
+				}
489
+			}
489 490
 			}
490
-		    }
491 491
 		} else {
492
-		    $format = $value['format'];
493
-		    if (isset($tt[$format])) $tt[$format]++;
494
-		    else $tt[$format] = 0;
495
-		    if ($tt[$format] > 30) {
492
+			$format = $value['format'];
493
+			if (isset($tt[$format])) $tt[$format]++;
494
+			else $tt[$format] = 0;
495
+			if ($tt[$format] > 30) {
496 496
 			if ($globalDebug) echo 'Reconnect...'."\n";
497 497
 			sleep(2);
498 498
 			$sourceeen[] = $value;
499 499
 			connect_all($sourceeen);
500 500
 			$sourceeen = array();
501
-		    }
501
+			}
502
+		}
502 503
 		}
503
-	    }
504 504
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
505
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
506
-	    if ($buffer != '') {
505
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
506
+		if ($buffer != '') {
507 507
 		//echo $buffer;
508 508
 		$all_data = json_decode($buffer,true);
509 509
 		//print_r($all_data);
510 510
 		if (isset($all_data[0]['DATA'])) {
511
-		    foreach ($all_data[0]['DATA'] as $line) {
511
+			foreach ($all_data[0]['DATA'] as $line) {
512 512
 			if ($line != '') {
513
-			    $data = array();
514
-			    $data['ident'] = $line['NAME'];
515
-			    $data['mmsi'] = $line['MMSI'];
516
-			    $data['speed'] = $line['SOG'];
517
-			    $data['heading'] = $line['COG'];
518
-			    $data['latitude'] = $line['LAT'];
519
-			    $data['longitude'] = $line['LNG'];
520
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
521
-			    $data['imo'] = $line['IMO'];
522
-			    //$data['arrival_code'] = $ais_data['destination'];
523
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
524
-			    $data['format_source'] = 'myshiptracking';
525
-			    $data['id_source'] = $id_source;
526
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
527
-			    $MI->add($data);
528
-			    unset($data);
513
+				$data = array();
514
+				$data['ident'] = $line['NAME'];
515
+				$data['mmsi'] = $line['MMSI'];
516
+				$data['speed'] = $line['SOG'];
517
+				$data['heading'] = $line['COG'];
518
+				$data['latitude'] = $line['LAT'];
519
+				$data['longitude'] = $line['LNG'];
520
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
521
+				$data['imo'] = $line['IMO'];
522
+				//$data['arrival_code'] = $ais_data['destination'];
523
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
524
+				$data['format_source'] = 'myshiptracking';
525
+				$data['id_source'] = $id_source;
526
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
527
+				$MI->add($data);
528
+				unset($data);
529
+			}
529 530
 			}
530
-		    }
531 531
 		}
532
-	    }
533
-	    $last_exec[$id]['last'] = time();
532
+		}
533
+		$last_exec[$id]['last'] = time();
534 534
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
535
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
536
-	    if ($buffer != '') {
535
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
536
+		if ($buffer != '') {
537 537
 		$all_data = json_decode($buffer,true);
538 538
 		if (isset($all_data[0]['mmsi'])) {
539
-		    foreach ($all_data as $line) {
539
+			foreach ($all_data as $line) {
540 540
 			if ($line != '') {
541
-			    $data = array();
542
-			    $data['ident'] = $line['shipname'];
543
-			    $data['callsign'] = $line['callsign'];
544
-			    $data['mmsi'] = $line['mmsi'];
545
-			    $data['speed'] = $line['sog'];
546
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
547
-			    $data['latitude'] = $line['latitude'];
548
-			    $data['longitude'] = $line['longitude'];
549
-			    $data['type_id'] = $line['shiptype'];
550
-			    $data['arrival_code'] = $line['destination'];
551
-			    $data['datetime'] = $line['time'];
552
-			    $data['format_source'] = 'boatbeaconapp';
553
-			    $data['id_source'] = $id_source;
554
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
555
-			    $MI->add($data);
556
-			    unset($data);
541
+				$data = array();
542
+				$data['ident'] = $line['shipname'];
543
+				$data['callsign'] = $line['callsign'];
544
+				$data['mmsi'] = $line['mmsi'];
545
+				$data['speed'] = $line['sog'];
546
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
547
+				$data['latitude'] = $line['latitude'];
548
+				$data['longitude'] = $line['longitude'];
549
+				$data['type_id'] = $line['shiptype'];
550
+				$data['arrival_code'] = $line['destination'];
551
+				$data['datetime'] = $line['time'];
552
+				$data['format_source'] = 'boatbeaconapp';
553
+				$data['id_source'] = $id_source;
554
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
555
+				$MI->add($data);
556
+				unset($data);
557
+			}
557 558
 			}
558
-		    }
559 559
 		}
560 560
 		
561
-	    }
562
-    	    $last_exec[$id]['last'] = time();
561
+		}
562
+			$last_exec[$id]['last'] = time();
563 563
 	} elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
564
-	    $buffer = $Common->getData($value['host']);
565
-	    if ($buffer != '') {
564
+		$buffer = $Common->getData($value['host']);
565
+		if ($buffer != '') {
566 566
 		$all_data = json_decode($buffer,true);
567 567
 		if (isset($all_data['features'][0]['id'])) {
568
-		    foreach ($all_data['features'] as $line) {
568
+			foreach ($all_data['features'] as $line) {
569 569
 			$data = array();
570 570
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
571 571
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
@@ -584,59 +584,59 @@  discard block
 block discarded – undo
584 584
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
585 585
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
586 586
 			unset($data);
587
-		    }
587
+			}
588 588
 		}
589 589
 		
590
-	    }
591
-    	    $last_exec[$id]['last'] = time();
590
+		}
591
+			$last_exec[$id]['last'] = time();
592 592
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
593
-	    echo 'download...';
594
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
595
-	    echo 'done !'."\n";
596
-	    if ($buffer != '') $reset = 0;
597
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
598
-	    $buffer = explode('\n',$buffer);
599
-	    foreach ($buffer as $line) {
593
+		echo 'download...';
594
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
595
+		echo 'done !'."\n";
596
+		if ($buffer != '') $reset = 0;
597
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
598
+		$buffer = explode('\n',$buffer);
599
+		foreach ($buffer as $line) {
600 600
 		if ($line != '') {
601
-		    $data = array();
602
-		    $data['mmsi'] = (int)substr($line,0,9);
603
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
604
-		    //$data['status'] = substr($line,21,2);
605
-		    //$data['type'] = substr($line,24,3);
606
-		    $data['latitude'] = substr($line,29,9);
607
-		    $data['longitude'] = substr($line,41,9);
608
-		    $data['speed'] = round(substr($line,51,5));
609
-		    //$data['course'] = substr($line,57,5);
610
-		    $data['heading'] = round(substr($line,63,3));
611
-		    //$data['draft'] = substr($line,67,4);
612
-		    //$data['length'] = substr($line,72,3);
613
-		    //$data['beam'] = substr($line,76,2);
614
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
615
-		    //$data['callsign'] = trim(substr($line,100,7);
616
-		    //$data['dest'] = substr($line,108,20);
617
-		    //$data['etaDate'] = substr($line,129,5);
618
-		    //$data['etaTime'] = substr($line,135,5);
619
-		    $data['format_source'] = 'shipplotter';
620
-    		    $data['id_source'] = $id_source;
621
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
622
-		    //print_r($data);
623
-		    echo 'Add...'."\n";
624
-		    $MI->add($data);
625
-		    unset($data);
601
+			$data = array();
602
+			$data['mmsi'] = (int)substr($line,0,9);
603
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
604
+			//$data['status'] = substr($line,21,2);
605
+			//$data['type'] = substr($line,24,3);
606
+			$data['latitude'] = substr($line,29,9);
607
+			$data['longitude'] = substr($line,41,9);
608
+			$data['speed'] = round(substr($line,51,5));
609
+			//$data['course'] = substr($line,57,5);
610
+			$data['heading'] = round(substr($line,63,3));
611
+			//$data['draft'] = substr($line,67,4);
612
+			//$data['length'] = substr($line,72,3);
613
+			//$data['beam'] = substr($line,76,2);
614
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
615
+			//$data['callsign'] = trim(substr($line,100,7);
616
+			//$data['dest'] = substr($line,108,20);
617
+			//$data['etaDate'] = substr($line,129,5);
618
+			//$data['etaTime'] = substr($line,135,5);
619
+			$data['format_source'] = 'shipplotter';
620
+				$data['id_source'] = $id_source;
621
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
622
+			//print_r($data);
623
+			echo 'Add...'."\n";
624
+			$MI->add($data);
625
+			unset($data);
626 626
 		}
627
-    	    }
628
-    	    $last_exec[$id]['last'] = time();
627
+			}
628
+			$last_exec[$id]['last'] = time();
629 629
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
630 630
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
631
-	    //$buffer = $Common->getData($hosts[$id]);
632
-	    $buffer = $Common->getData($value['host']);
633
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
634
-	    $buffer = explode('\n',$buffer);
635
-	    $reset = 0;
636
-	    foreach ($buffer as $line) {
637
-    		if ($line != '') {
638
-    		    $line = explode(':', $line);
639
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
631
+		//$buffer = $Common->getData($hosts[$id]);
632
+		$buffer = $Common->getData($value['host']);
633
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
634
+		$buffer = explode('\n',$buffer);
635
+		$reset = 0;
636
+		foreach ($buffer as $line) {
637
+			if ($line != '') {
638
+				$line = explode(':', $line);
639
+				if (count($line) > 30 && $line[0] != 'callsign') {
640 640
 			$data = array();
641 641
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
642 642
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -649,37 +649,37 @@  discard block
 block discarded – undo
649 649
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
650 650
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
651 651
 			$data['latitude'] = $line[5]; // lat
652
-	        	$data['longitude'] = $line[6]; // long
653
-	        	$data['verticalrate'] = ''; // vertical rate
654
-	        	$data['squawk'] = ''; // squawk
655
-	        	$data['emergency'] = ''; // emergency
656
-	        	$data['waypoints'] = $line[30];
652
+				$data['longitude'] = $line[6]; // long
653
+				$data['verticalrate'] = ''; // vertical rate
654
+				$data['squawk'] = ''; // squawk
655
+				$data['emergency'] = ''; // emergency
656
+				$data['waypoints'] = $line[30];
657 657
 			$data['datetime'] = date('Y-m-d H:i:s');
658 658
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
659 659
 			//if (isset($line[37])) $data['last_update'] = $line[37];
660
-		        $data['departure_airport_icao'] = $line[11];
661
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
662
-		        $data['arrival_airport_icao'] = $line[13];
660
+				$data['departure_airport_icao'] = $line[11];
661
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
662
+				$data['arrival_airport_icao'] = $line[13];
663 663
 			$data['frequency'] = $line[4];
664 664
 			$data['type'] = $line[18];
665 665
 			$data['range'] = $line[19];
666 666
 			if (isset($line[35])) $data['info'] = $line[35];
667
-    			$data['id_source'] = $id_source;
668
-	    		//$data['arrival_airport_time'] = ;
669
-	    		if ($line[9] != '') {
670
-	    		    $aircraft_data = explode('/',$line[9]);
671
-	    		    if (isset($aircraft_data[1])) {
672
-	    			$data['aircraft_icao'] = $aircraft_data[1];
673
-	    		    }
674
-        		}
675
-	    		/*
667
+				$data['id_source'] = $id_source;
668
+				//$data['arrival_airport_time'] = ;
669
+				if ($line[9] != '') {
670
+					$aircraft_data = explode('/',$line[9]);
671
+					if (isset($aircraft_data[1])) {
672
+					$data['aircraft_icao'] = $aircraft_data[1];
673
+					}
674
+				}
675
+				/*
676 676
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
677 677
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
678 678
 	    		*/
679
-	    		$data['format_source'] = $value['format'];
679
+				$data['format_source'] = $value['format'];
680 680
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
681 681
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
682
-    			if ($line[3] == 'PILOT') $SI->add($data);
682
+				if ($line[3] == 'PILOT') $SI->add($data);
683 683
 			elseif ($line[3] == 'ATC') {
684 684
 				//print_r($data);
685 685
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -700,16 +700,16 @@  discard block
 block discarded – undo
700 700
 					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']);
701 701
 				}
702 702
 			}
703
-    			unset($data);
704
-    		    }
705
-    		}
706
-    	    }
707
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
708
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
709
-    	    $last_exec[$id]['last'] = time();
710
-    	} elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
711
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
712
-	    if ($buffer != '') {
703
+				unset($data);
704
+				}
705
+			}
706
+			}
707
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
708
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
709
+			$last_exec[$id]['last'] = time();
710
+		} elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
711
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
712
+		if ($buffer != '') {
713 713
 		$all_data = simplexml_load_string($buffer);
714 714
 		foreach($all_data->children() as $childdata) {
715 715
 			$data = array();
@@ -730,10 +730,10 @@  discard block
 block discarded – undo
730 730
 			$SI->add($data);
731 731
 			unset($data);
732 732
 		}
733
-	    }
734
-	    $Source->deleteOldLocationByType('gs');
735
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
736
-	    if ($buffer != '') {
733
+		}
734
+		$Source->deleteOldLocationByType('gs');
735
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
736
+		if ($buffer != '') {
737 737
 		$all_data = simplexml_load_string($buffer);
738 738
 		foreach($all_data->children() as $childdata) {
739 739
 			$data = array();
@@ -750,249 +750,249 @@  discard block
 block discarded – undo
750 750
 			}
751 751
 			unset($data);
752 752
 		}
753
-	    }
754
-	    $last_exec[$id]['last'] = time();
753
+		}
754
+		$last_exec[$id]['last'] = time();
755 755
 	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
756
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
757
-	    if ($buffer != '') {
758
-	    $all_data = json_decode($buffer,true);
759
-	    if (isset($all_data['acList'])) {
756
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
757
+		if ($buffer != '') {
758
+		$all_data = json_decode($buffer,true);
759
+		if (isset($all_data['acList'])) {
760 760
 		$reset = 0;
761 761
 		foreach ($all_data['acList'] as $line) {
762
-		    $data = array();
763
-		    $data['hex'] = $line['Icao']; // hex
764
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
765
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
766
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
767
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
768
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
769
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
770
-		    //$data['verticalrate'] = $line['']; // verticale rate
771
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
772
-		    $data['emergency'] = ''; // emergency
773
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
762
+			$data = array();
763
+			$data['hex'] = $line['Icao']; // hex
764
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
765
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
766
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
767
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
768
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
769
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
770
+			//$data['verticalrate'] = $line['']; // verticale rate
771
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
772
+			$data['emergency'] = ''; // emergency
773
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
774 774
 		    
775
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
776
-		    else $data['datetime'] = date('Y-m-d H:i:s');
775
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
776
+			else $data['datetime'] = date('Y-m-d H:i:s');
777 777
 		    
778
-		    //$data['datetime'] = date('Y-m-d H:i:s');
779
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
780
-	    	    $data['format_source'] = 'aircraftlistjson';
781
-		    $data['id_source'] = $id_source;
782
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
783
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
784
-		    if (isset($data['latitude'])) $SI->add($data);
785
-		    unset($data);
778
+			//$data['datetime'] = date('Y-m-d H:i:s');
779
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
780
+				$data['format_source'] = 'aircraftlistjson';
781
+			$data['id_source'] = $id_source;
782
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
783
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
784
+			if (isset($data['latitude'])) $SI->add($data);
785
+			unset($data);
786 786
 		}
787
-	    } elseif (is_array($all_data)) {
787
+		} elseif (is_array($all_data)) {
788 788
 		$reset = 0;
789 789
 		foreach ($all_data as $line) {
790
-		    $data = array();
791
-		    $data['hex'] = $line['hex']; // hex
792
-		    $data['ident'] = $line['flight']; // ident
793
-		    $data['altitude'] = $line['altitude']; // altitude
794
-		    $data['speed'] = $line['speed']; // speed
795
-		    $data['heading'] = $line['track']; // heading
796
-		    $data['latitude'] = $line['lat']; // lat
797
-		    $data['longitude'] = $line['lon']; // long
798
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
799
-		    $data['squawk'] = $line['squawk']; // squawk
800
-		    $data['emergency'] = ''; // emergency
801
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
802
-		    else $data['datetime'] = date('Y-m-d H:i:s');
803
-	    	    $data['format_source'] = 'aircraftlistjson';
804
-    		    $data['id_source'] = $id_source;
805
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
806
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
807
-		    $SI->add($data);
808
-		    unset($data);
790
+			$data = array();
791
+			$data['hex'] = $line['hex']; // hex
792
+			$data['ident'] = $line['flight']; // ident
793
+			$data['altitude'] = $line['altitude']; // altitude
794
+			$data['speed'] = $line['speed']; // speed
795
+			$data['heading'] = $line['track']; // heading
796
+			$data['latitude'] = $line['lat']; // lat
797
+			$data['longitude'] = $line['lon']; // long
798
+			$data['verticalrate'] = $line['vrt']; // verticale rate
799
+			$data['squawk'] = $line['squawk']; // squawk
800
+			$data['emergency'] = ''; // emergency
801
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
802
+			else $data['datetime'] = date('Y-m-d H:i:s');
803
+				$data['format_source'] = 'aircraftlistjson';
804
+				$data['id_source'] = $id_source;
805
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
806
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
807
+			$SI->add($data);
808
+			unset($data);
809
+		}
809 810
 		}
810
-	    }
811
-	    }
812
-    	    //$last_exec['aircraftlistjson'] = time();
813
-    	    $last_exec[$id]['last'] = time();
814
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
815
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
816
-	    $buffer = $Common->getData($value['host']);
817
-	    $all_data = json_decode($buffer,true);
818
-	    if (isset($all_data['planes'])) {
811
+		}
812
+			//$last_exec['aircraftlistjson'] = time();
813
+			$last_exec[$id]['last'] = time();
814
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
815
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
816
+		$buffer = $Common->getData($value['host']);
817
+		$all_data = json_decode($buffer,true);
818
+		if (isset($all_data['planes'])) {
819 819
 		$reset = 0;
820 820
 		foreach ($all_data['planes'] as $key => $line) {
821
-		    $data = array();
822
-		    $data['hex'] = $key; // hex
823
-		    $data['ident'] = $line[3]; // ident
824
-		    $data['altitude'] = $line[6]; // altitude
825
-		    $data['speed'] = $line[8]; // speed
826
-		    $data['heading'] = $line[7]; // heading
827
-		    $data['latitude'] = $line[4]; // lat
828
-		    $data['longitude'] = $line[5]; // long
829
-		    //$data['verticalrate'] = $line[]; // verticale rate
830
-		    $data['squawk'] = $line[10]; // squawk
831
-		    $data['emergency'] = ''; // emergency
832
-		    $data['registration'] = $line[2];
833
-		    $data['aircraft_icao'] = $line[0];
834
-		    $deparr = explode('-',$line[1]);
835
-		    if (count($deparr) == 2) {
821
+			$data = array();
822
+			$data['hex'] = $key; // hex
823
+			$data['ident'] = $line[3]; // ident
824
+			$data['altitude'] = $line[6]; // altitude
825
+			$data['speed'] = $line[8]; // speed
826
+			$data['heading'] = $line[7]; // heading
827
+			$data['latitude'] = $line[4]; // lat
828
+			$data['longitude'] = $line[5]; // long
829
+			//$data['verticalrate'] = $line[]; // verticale rate
830
+			$data['squawk'] = $line[10]; // squawk
831
+			$data['emergency'] = ''; // emergency
832
+			$data['registration'] = $line[2];
833
+			$data['aircraft_icao'] = $line[0];
834
+			$deparr = explode('-',$line[1]);
835
+			if (count($deparr) == 2) {
836 836
 			$data['departure_airport_icao'] = $deparr[0];
837 837
 			$data['arrival_airport_icao'] = $deparr[1];
838
-		    }
839
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
840
-	    	    $data['format_source'] = 'planeupdatefaa';
841
-    		    $data['id_source'] = $id_source;
842
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
843
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
844
-		    $SI->add($data);
845
-		    unset($data);
838
+			}
839
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
840
+				$data['format_source'] = 'planeupdatefaa';
841
+				$data['id_source'] = $id_source;
842
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
843
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
844
+			$SI->add($data);
845
+			unset($data);
846 846
 		}
847
-	    }
848
-    	    //$last_exec['planeupdatefaa'] = time();
849
-    	    $last_exec[$id]['last'] = time();
850
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
851
-	    $buffer = $Common->getData($value['host']);
852
-	    $all_data = json_decode($buffer,true);
853
-	    if (isset($all_data['states'])) {
847
+		}
848
+			//$last_exec['planeupdatefaa'] = time();
849
+			$last_exec[$id]['last'] = time();
850
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
851
+		$buffer = $Common->getData($value['host']);
852
+		$all_data = json_decode($buffer,true);
853
+		if (isset($all_data['states'])) {
854 854
 		$reset = 0;
855 855
 		foreach ($all_data['states'] as $key => $line) {
856
-		    $data = array();
857
-		    $data['hex'] = $line[0]; // hex
858
-		    $data['ident'] = trim($line[1]); // ident
859
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
860
-		    $data['speed'] = round($line[9]*1.94384); // speed
861
-		    $data['heading'] = round($line[10]); // heading
862
-		    $data['latitude'] = $line[6]; // lat
863
-		    $data['longitude'] = $line[5]; // long
864
-		    $data['verticalrate'] = $line[11]; // verticale rate
865
-		    //$data['squawk'] = $line[10]; // squawk
866
-		    //$data['emergency'] = ''; // emergency
867
-		    //$data['registration'] = $line[2];
868
-		    //$data['aircraft_icao'] = $line[0];
869
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
870
-	    	    $data['format_source'] = 'opensky';
871
-    		    $data['id_source'] = $id_source;
872
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
873
-		    $SI->add($data);
874
-		    unset($data);
856
+			$data = array();
857
+			$data['hex'] = $line[0]; // hex
858
+			$data['ident'] = trim($line[1]); // ident
859
+			$data['altitude'] = round($line[7]*3.28084); // altitude
860
+			$data['speed'] = round($line[9]*1.94384); // speed
861
+			$data['heading'] = round($line[10]); // heading
862
+			$data['latitude'] = $line[6]; // lat
863
+			$data['longitude'] = $line[5]; // long
864
+			$data['verticalrate'] = $line[11]; // verticale rate
865
+			//$data['squawk'] = $line[10]; // squawk
866
+			//$data['emergency'] = ''; // emergency
867
+			//$data['registration'] = $line[2];
868
+			//$data['aircraft_icao'] = $line[0];
869
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
870
+				$data['format_source'] = 'opensky';
871
+				$data['id_source'] = $id_source;
872
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
873
+			$SI->add($data);
874
+			unset($data);
875
+		}
875 876
 		}
876
-	    }
877
-    	    //$last_exec['planeupdatefaa'] = time();
878
-    	    $last_exec[$id]['last'] = time();
879
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
880
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
881
-	    //$buffer = $Common->getData($hosts[$id]);
882
-	    $buffer = $Common->getData($value['host']);
883
-	    $all_data = json_decode($buffer,true);
884
-	    if (!empty($all_data)) $reset = 0;
885
-	    foreach ($all_data as $key => $line) {
877
+			//$last_exec['planeupdatefaa'] = time();
878
+			$last_exec[$id]['last'] = time();
879
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
880
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
881
+		//$buffer = $Common->getData($hosts[$id]);
882
+		$buffer = $Common->getData($value['host']);
883
+		$all_data = json_decode($buffer,true);
884
+		if (!empty($all_data)) $reset = 0;
885
+		foreach ($all_data as $key => $line) {
886 886
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
887
-		    $data = array();
888
-		    $data['hex'] = $line[0];
889
-		    $data['ident'] = $line[16]; //$line[13]
890
-	    	    $data['altitude'] = $line[4]; // altitude
891
-	    	    $data['speed'] = $line[5]; // speed
892
-	    	    $data['heading'] = $line[3]; // heading
893
-	    	    $data['latitude'] = $line[1]; // lat
894
-	    	    $data['longitude'] = $line[2]; // long
895
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
896
-	    	    $data['squawk'] = $line[6]; // squawk
897
-	    	    $data['aircraft_icao'] = $line[8];
898
-	    	    $data['registration'] = $line[9];
899
-		    $data['departure_airport_iata'] = $line[11];
900
-		    $data['arrival_airport_iata'] = $line[12];
901
-	    	    $data['emergency'] = ''; // emergency
902
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
903
-	    	    $data['format_source'] = 'fr24json';
904
-    		    $data['id_source'] = $id_source;
905
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
906
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
907
-		    $SI->add($data);
908
-		    unset($data);
887
+			$data = array();
888
+			$data['hex'] = $line[0];
889
+			$data['ident'] = $line[16]; //$line[13]
890
+				$data['altitude'] = $line[4]; // altitude
891
+				$data['speed'] = $line[5]; // speed
892
+				$data['heading'] = $line[3]; // heading
893
+				$data['latitude'] = $line[1]; // lat
894
+				$data['longitude'] = $line[2]; // long
895
+				$data['verticalrate'] = $line[15]; // verticale rate
896
+				$data['squawk'] = $line[6]; // squawk
897
+				$data['aircraft_icao'] = $line[8];
898
+				$data['registration'] = $line[9];
899
+			$data['departure_airport_iata'] = $line[11];
900
+			$data['arrival_airport_iata'] = $line[12];
901
+				$data['emergency'] = ''; // emergency
902
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
903
+				$data['format_source'] = 'fr24json';
904
+				$data['id_source'] = $id_source;
905
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
906
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
907
+			$SI->add($data);
908
+			unset($data);
909 909
 		}
910
-	    }
911
-    	    //$last_exec['fr24json'] = time();
912
-    	    $last_exec[$id]['last'] = time();
913
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
914
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
915
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
916
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
917
-	    //echo $buffer;
918
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
919
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
920
-	    $all_data = json_decode($buffer,true);
921
-	    if (json_last_error() != JSON_ERROR_NONE) {
910
+		}
911
+			//$last_exec['fr24json'] = time();
912
+			$last_exec[$id]['last'] = time();
913
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
914
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
915
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
916
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
917
+		//echo $buffer;
918
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
919
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
920
+		$all_data = json_decode($buffer,true);
921
+		if (json_last_error() != JSON_ERROR_NONE) {
922 922
 		die(json_last_error_msg());
923
-	    }
924
-	    if (isset($all_data['mrkrs'])) {
923
+		}
924
+		if (isset($all_data['mrkrs'])) {
925 925
 		$reset = 0;
926 926
 		foreach ($all_data['mrkrs'] as $key => $line) {
927
-		    if (isset($line['inf'])) {
927
+			if (isset($line['inf'])) {
928 928
 			$data = array();
929 929
 			$data['hex'] = $line['inf']['ia'];
930 930
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
931
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
932
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
933
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
934
-	    		$data['latitude'] = $line['pt'][0]; // lat
935
-	    		$data['longitude'] = $line['pt'][1]; // long
936
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
937
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
938
-	    		//$data['aircraft_icao'] = $line[8];
939
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
931
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
932
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
933
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
934
+				$data['latitude'] = $line['pt'][0]; // lat
935
+				$data['longitude'] = $line['pt'][1]; // long
936
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
937
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
938
+				//$data['aircraft_icao'] = $line[8];
939
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
940 940
 			//$data['departure_airport_iata'] = $line[11];
941 941
 			//$data['arrival_airport_iata'] = $line[12];
942
-	    		//$data['emergency'] = ''; // emergency
942
+				//$data['emergency'] = ''; // emergency
943 943
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
944
-	    		$data['format_source'] = 'radarvirtueljson';
945
-    			$data['id_source'] = $id_source;
944
+				$data['format_source'] = 'radarvirtueljson';
945
+				$data['id_source'] = $id_source;
946 946
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
947 947
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
948 948
 			$SI->add($data);
949 949
 			unset($data);
950
-		    }
950
+			}
951
+		}
951 952
 		}
952
-	    }
953
-    	    //$last_exec['radarvirtueljson'] = time();
954
-    	    $last_exec[$id]['last'] = time();
955
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
956
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
957
-	    //$buffer = $Common->getData($hosts[$id]);
958
-	    $buffer = $Common->getData($value['host'].'?'.time());
959
-	    $all_data = json_decode(utf8_encode($buffer),true);
953
+			//$last_exec['radarvirtueljson'] = time();
954
+			$last_exec[$id]['last'] = time();
955
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
956
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
957
+		//$buffer = $Common->getData($hosts[$id]);
958
+		$buffer = $Common->getData($value['host'].'?'.time());
959
+		$all_data = json_decode(utf8_encode($buffer),true);
960 960
 	    
961
-	    if (isset($all_data['pireps'])) {
961
+		if (isset($all_data['pireps'])) {
962 962
 		$reset = 0;
963
-	        foreach ($all_data['pireps'] as $line) {
964
-		    $data = array();
965
-		    $data['id'] = $line['id'];
966
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
967
-		    $data['ident'] = $line['callsign']; // ident
968
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
969
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
970
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
971
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
972
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
973
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
974
-		    $data['latitude'] = $line['lat']; // lat
975
-		    $data['longitude'] = $line['lon']; // long
976
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
977
-		    //$data['squawk'] = $line['squawk']; // squawk
978
-		    //$data['emergency'] = ''; // emergency
979
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
980
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
981
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
982
-		    //$data['arrival_airport_time'] = $line['arrtime'];
983
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
984
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
985
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
986
-		    else $data['info'] = '';
987
-		    $data['format_source'] = 'pireps';
988
-    		    $data['id_source'] = $id_source;
989
-		    $data['datetime'] = date('Y-m-d H:i:s');
990
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
991
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
992
-		    if ($line['icon'] == 'plane') {
963
+			foreach ($all_data['pireps'] as $line) {
964
+			$data = array();
965
+			$data['id'] = $line['id'];
966
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
967
+			$data['ident'] = $line['callsign']; // ident
968
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
969
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
970
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
971
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
972
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
973
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
974
+			$data['latitude'] = $line['lat']; // lat
975
+			$data['longitude'] = $line['lon']; // long
976
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
977
+			//$data['squawk'] = $line['squawk']; // squawk
978
+			//$data['emergency'] = ''; // emergency
979
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
980
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
981
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
982
+			//$data['arrival_airport_time'] = $line['arrtime'];
983
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
984
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
985
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
986
+			else $data['info'] = '';
987
+			$data['format_source'] = 'pireps';
988
+				$data['id_source'] = $id_source;
989
+			$data['datetime'] = date('Y-m-d H:i:s');
990
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
991
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
992
+			if ($line['icon'] == 'plane') {
993 993
 			$SI->add($data);
994
-		    //    print_r($data);
995
-    		    } elseif ($line['icon'] == 'ct') {
994
+			//    print_r($data);
995
+				} elseif ($line['icon'] == 'ct') {
996 996
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
997 997
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
998 998
 			$typec = substr($data['ident'],-3);
@@ -1007,203 +1007,203 @@  discard block
 block discarded – undo
1007 1007
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1008 1008
 			else $data['type'] = 'Observer';
1009 1009
 			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']);
1010
-		    }
1011
-		    unset($data);
1010
+			}
1011
+			unset($data);
1012
+		}
1012 1013
 		}
1013
-	    }
1014
-    	    //$last_exec['pirepsjson'] = time();
1015
-    	    $last_exec[$id]['last'] = time();
1016
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1017
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1018
-	    //$buffer = $Common->getData($hosts[$id]);
1019
-	    if ($globalDebug) echo 'Get Data...'."\n";
1020
-	    $buffer = $Common->getData($value['host']);
1021
-	    $all_data = json_decode($buffer,true);
1022
-	    if ($buffer != '' && is_array($all_data)) {
1014
+			//$last_exec['pirepsjson'] = time();
1015
+			$last_exec[$id]['last'] = time();
1016
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1017
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1018
+		//$buffer = $Common->getData($hosts[$id]);
1019
+		if ($globalDebug) echo 'Get Data...'."\n";
1020
+		$buffer = $Common->getData($value['host']);
1021
+		$all_data = json_decode($buffer,true);
1022
+		if ($buffer != '' && is_array($all_data)) {
1023 1023
 		$reset = 0;
1024 1024
 		foreach ($all_data as $line) {
1025
-	    	    $data = array();
1026
-	    	    //$data['id'] = $line['id']; // id not usable
1027
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1028
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1029
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1030
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1031
-	    	    $data['ident'] = $line['flightnum']; // ident
1032
-	    	    $data['altitude'] = $line['alt']; // altitude
1033
-	    	    $data['speed'] = $line['gs']; // speed
1034
-	    	    $data['heading'] = $line['heading']; // heading
1035
-	    	    $data['latitude'] = $line['lat']; // lat
1036
-	    	    $data['longitude'] = $line['lng']; // long
1037
-	    	    $data['verticalrate'] = ''; // verticale rate
1038
-	    	    $data['squawk'] = ''; // squawk
1039
-	    	    $data['emergency'] = ''; // emergency
1040
-	    	    //$data['datetime'] = $line['lastupdate'];
1041
-	    	    //$data['last_update'] = $line['lastupdate'];
1042
-	    	    if (isset($value['timezone'])) {
1043
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1044
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1045
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1046
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1047
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1048
-	    	    $data['departure_airport_time'] = $line['deptime'];
1049
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1050
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1051
-    		    $data['registration'] = $line['aircraft'];
1052
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1053
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1054
-		    if (isset($line['aircraftname'])) {
1025
+				$data = array();
1026
+				//$data['id'] = $line['id']; // id not usable
1027
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1028
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1029
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1030
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1031
+				$data['ident'] = $line['flightnum']; // ident
1032
+				$data['altitude'] = $line['alt']; // altitude
1033
+				$data['speed'] = $line['gs']; // speed
1034
+				$data['heading'] = $line['heading']; // heading
1035
+				$data['latitude'] = $line['lat']; // lat
1036
+				$data['longitude'] = $line['lng']; // long
1037
+				$data['verticalrate'] = ''; // verticale rate
1038
+				$data['squawk'] = ''; // squawk
1039
+				$data['emergency'] = ''; // emergency
1040
+				//$data['datetime'] = $line['lastupdate'];
1041
+				//$data['last_update'] = $line['lastupdate'];
1042
+				if (isset($value['timezone'])) {
1043
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1044
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1045
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1046
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1047
+				$data['departure_airport_icao'] = $line['depicao'];
1048
+				$data['departure_airport_time'] = $line['deptime'];
1049
+				$data['arrival_airport_icao'] = $line['arricao'];
1050
+				$data['arrival_airport_time'] = $line['arrtime'];
1051
+				$data['registration'] = $line['aircraft'];
1052
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1053
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1054
+			if (isset($line['aircraftname'])) {
1055 1055
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1056 1056
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1057
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1058
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1059
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1060
-	    		else {
1061
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1062
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1063
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1064
-	    		}
1065
-	    	    }
1066
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1067
-    		    $data['id_source'] = $id_source;
1068
-	    	    $data['format_source'] = 'phpvmacars';
1069
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1070
-		    $SI->add($data);
1071
-		    unset($data);
1057
+				$aircraft_data = explode('-',$line['aircraftname']);
1058
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1059
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1060
+				else {
1061
+					$aircraft_data = explode(' ',$line['aircraftname']);
1062
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1063
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1064
+				}
1065
+				}
1066
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1067
+				$data['id_source'] = $id_source;
1068
+				$data['format_source'] = 'phpvmacars';
1069
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1070
+			$SI->add($data);
1071
+			unset($data);
1072 1072
 		}
1073 1073
 		if ($globalDebug) echo 'No more data...'."\n";
1074 1074
 		unset($buffer);
1075 1075
 		unset($all_data);
1076
-	    }
1077
-    	    //$last_exec['phpvmacars'] = time();
1078
-    	    $last_exec[$id]['last'] = time();
1079
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1080
-	    //$buffer = $Common->getData($hosts[$id]);
1081
-	    if ($globalDebug) echo 'Get Data...'."\n";
1082
-	    $buffer = $Common->getData($value['host']);
1083
-	    $all_data = json_decode($buffer,true);
1084
-	    if ($buffer != '' && is_array($all_data)) {
1076
+		}
1077
+			//$last_exec['phpvmacars'] = time();
1078
+			$last_exec[$id]['last'] = time();
1079
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1080
+		//$buffer = $Common->getData($hosts[$id]);
1081
+		if ($globalDebug) echo 'Get Data...'."\n";
1082
+		$buffer = $Common->getData($value['host']);
1083
+		$all_data = json_decode($buffer,true);
1084
+		if ($buffer != '' && is_array($all_data)) {
1085 1085
 		$reset = 0;
1086 1086
 		foreach ($all_data as $line) {
1087
-	    	    $data = array();
1088
-	    	    //$data['id'] = $line['id']; // id not usable
1089
-	    	    $data['id'] = trim($line['flight_id']);
1090
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1091
-	    	    $data['pilot_name'] = $line['pilot_name'];
1092
-	    	    $data['pilot_id'] = $line['pilot_id'];
1093
-	    	    $data['ident'] = trim($line['callsign']); // ident
1094
-	    	    $data['altitude'] = $line['altitude']; // altitude
1095
-	    	    $data['speed'] = $line['gs']; // speed
1096
-	    	    $data['heading'] = $line['heading']; // heading
1097
-	    	    $data['latitude'] = $line['latitude']; // lat
1098
-	    	    $data['longitude'] = $line['longitude']; // long
1099
-	    	    $data['verticalrate'] = ''; // verticale rate
1100
-	    	    $data['squawk'] = ''; // squawk
1101
-	    	    $data['emergency'] = ''; // emergency
1102
-	    	    //$data['datetime'] = $line['lastupdate'];
1103
-	    	    $data['last_update'] = $line['last_update'];
1104
-		    $data['datetime'] = date('Y-m-d H:i:s');
1105
-	    	    $data['departure_airport_icao'] = $line['departure'];
1106
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1107
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1108
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1109
-    		    //$data['registration'] = $line['aircraft'];
1110
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1111
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1112
-    		    $data['id_source'] = $id_source;
1113
-	    	    $data['format_source'] = 'vam';
1114
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1115
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1116
-		    $SI->add($data);
1117
-		    unset($data);
1087
+				$data = array();
1088
+				//$data['id'] = $line['id']; // id not usable
1089
+				$data['id'] = trim($line['flight_id']);
1090
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1091
+				$data['pilot_name'] = $line['pilot_name'];
1092
+				$data['pilot_id'] = $line['pilot_id'];
1093
+				$data['ident'] = trim($line['callsign']); // ident
1094
+				$data['altitude'] = $line['altitude']; // altitude
1095
+				$data['speed'] = $line['gs']; // speed
1096
+				$data['heading'] = $line['heading']; // heading
1097
+				$data['latitude'] = $line['latitude']; // lat
1098
+				$data['longitude'] = $line['longitude']; // long
1099
+				$data['verticalrate'] = ''; // verticale rate
1100
+				$data['squawk'] = ''; // squawk
1101
+				$data['emergency'] = ''; // emergency
1102
+				//$data['datetime'] = $line['lastupdate'];
1103
+				$data['last_update'] = $line['last_update'];
1104
+			$data['datetime'] = date('Y-m-d H:i:s');
1105
+				$data['departure_airport_icao'] = $line['departure'];
1106
+				//$data['departure_airport_time'] = $line['departure_time'];
1107
+				$data['arrival_airport_icao'] = $line['arrival'];
1108
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1109
+				//$data['registration'] = $line['aircraft'];
1110
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1111
+				$data['aircraft_icao'] = $line['plane_type'];
1112
+				$data['id_source'] = $id_source;
1113
+				$data['format_source'] = 'vam';
1114
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1115
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1116
+			$SI->add($data);
1117
+			unset($data);
1118 1118
 		}
1119 1119
 		if ($globalDebug) echo 'No more data...'."\n";
1120 1120
 		unset($buffer);
1121 1121
 		unset($all_data);
1122
-	    }
1123
-    	    //$last_exec['phpvmacars'] = time();
1124
-    	    $last_exec[$id]['last'] = time();
1122
+		}
1123
+			//$last_exec['phpvmacars'] = time();
1124
+			$last_exec[$id]['last'] = time();
1125 1125
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1126 1126
 	} 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') {
1127
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1128
-    	    //$last_exec[$id]['last'] = time();
1127
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1128
+			//$last_exec[$id]['last'] = time();
1129 1129
 
1130
-	    //$read = array( $sockets[$id] );
1131
-	    $read = $sockets;
1132
-	    $write = NULL;
1133
-	    $e = NULL;
1134
-	    $n = socket_select($read, $write, $e, $timeout);
1135
-	    if ($e != NULL) var_dump($e);
1136
-	    if ($n > 0) {
1130
+		//$read = array( $sockets[$id] );
1131
+		$read = $sockets;
1132
+		$write = NULL;
1133
+		$e = NULL;
1134
+		$n = socket_select($read, $write, $e, $timeout);
1135
+		if ($e != NULL) var_dump($e);
1136
+		if ($n > 0) {
1137 1137
 		$reset = 0;
1138 1138
 		foreach ($read as $nb => $r) {
1139
-		    //$value = $formats[$nb];
1140
-		    $format = $globalSources[$nb]['format'];
1141
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1139
+			//$value = $formats[$nb];
1140
+			$format = $globalSources[$nb]['format'];
1141
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1142 1142
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1143
-		    } elseif ($format == 'vrstcp') {
1143
+			} elseif ($format == 'vrstcp') {
1144 1144
 			$buffer = @socket_read($r, 6000);
1145
-		    } else {
1145
+			} else {
1146 1146
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1147
-		    }
1148
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1149
-		    //echo $buffer."\n";
1150
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1151
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1152
-		    $error = false;
1153
-		    //$SI::del();
1154
-		    if ($format == 'vrstcp') {
1147
+			}
1148
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1149
+			//echo $buffer."\n";
1150
+			// lets play nice and handle signals such as ctrl-c/kill properly
1151
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1152
+			$error = false;
1153
+			//$SI::del();
1154
+			if ($format == 'vrstcp') {
1155 1155
 			$buffer = explode('},{',$buffer);
1156
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1157
-		    // SBS format is CSV format
1158
-		    if ($buffer !== FALSE && $buffer != '') {
1156
+			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1157
+			// SBS format is CSV format
1158
+			if ($buffer !== FALSE && $buffer != '') {
1159 1159
 			$tt[$format] = 0;
1160 1160
 			if ($format == 'acarssbs3') {
1161
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1162
-			    $ACARS->add(trim($buffer));
1163
-			    $ACARS->deleteLiveAcarsData();
1161
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1162
+				$ACARS->add(trim($buffer));
1163
+				$ACARS->deleteLiveAcarsData();
1164 1164
 			} elseif ($format == 'raw') {
1165
-			    // AVR format
1166
-			    $data = $SBS->parse($buffer);
1167
-			    if (is_array($data)) {
1165
+				// AVR format
1166
+				$data = $SBS->parse($buffer);
1167
+				if (is_array($data)) {
1168 1168
 				$data['datetime'] = date('Y-m-d H:i:s');
1169 1169
 				$data['format_source'] = 'raw';
1170 1170
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1171 1171
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1172 1172
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1173 1173
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1174
-			    }
1174
+				}
1175 1175
 			} elseif ($format == 'ais') {
1176
-			    $ais_data = $AIS->parse_line(trim($buffer));
1177
-			    $data = array();
1178
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1179
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1180
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1181
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1182
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1183
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1184
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1185
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1186
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1187
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1188
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1189
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1190
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1191
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1192
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1193
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1176
+				$ais_data = $AIS->parse_line(trim($buffer));
1177
+				$data = array();
1178
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1179
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1180
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1181
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1182
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1183
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1184
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1185
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1186
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1187
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1188
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1189
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1190
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1191
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1192
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1193
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1194 1194
 
1195
-			    if (isset($ais_data['timestamp'])) {
1195
+				if (isset($ais_data['timestamp'])) {
1196 1196
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1197
-			    } else {
1197
+				} else {
1198 1198
 				$data['datetime'] = date('Y-m-d H:i:s');
1199
-			    }
1200
-			    $data['format_source'] = 'aisnmea';
1201
-    			    $data['id_source'] = $id_source;
1202
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1203
-			    unset($data);
1204
-                        } elseif ($format == 'flightgearsp') {
1205
-                    	    //echo $buffer."\n";
1206
-                    	    if (strlen($buffer) > 5) {
1199
+				}
1200
+				$data['format_source'] = 'aisnmea';
1201
+					$data['id_source'] = $id_source;
1202
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1203
+				unset($data);
1204
+						} elseif ($format == 'flightgearsp') {
1205
+							//echo $buffer."\n";
1206
+							if (strlen($buffer) > 5) {
1207 1207
 				$line = explode(',',$buffer);
1208 1208
 				$data = array();
1209 1209
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1220,38 +1220,38 @@  discard block
 block discarded – undo
1220 1220
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1221 1221
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1222 1222
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1223
-			    }
1224
-                        } elseif ($format == 'acars') {
1225
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1226
-			    $ACARS->add(trim($buffer));
1227
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1228
-			    $ACARS->deleteLiveAcarsData();
1223
+				}
1224
+						} elseif ($format == 'acars') {
1225
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1226
+				$ACARS->add(trim($buffer));
1227
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1228
+				$ACARS->deleteLiveAcarsData();
1229 1229
 			} elseif ($format == 'flightgearmp') {
1230
-			    if (substr($buffer,0,1) != '#') {
1230
+				if (substr($buffer,0,1) != '#') {
1231 1231
 				$data = array();
1232 1232
 				//echo $buffer."\n";
1233 1233
 				$line = explode(' ',$buffer);
1234 1234
 				if (count($line) == 11) {
1235
-				    $userserver = explode('@',$line[0]);
1236
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1237
-				    $data['ident'] = $userserver[0];
1238
-				    $data['registration'] = $userserver[0];
1239
-				    $data['latitude'] = $line[4];
1240
-				    $data['longitude'] = $line[5];
1241
-				    $data['altitude'] = $line[6];
1242
-				    $data['datetime'] = date('Y-m-d H:i:s');
1243
-				    $aircraft_type = $line[10];
1244
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1245
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1246
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1247
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1235
+					$userserver = explode('@',$line[0]);
1236
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1237
+					$data['ident'] = $userserver[0];
1238
+					$data['registration'] = $userserver[0];
1239
+					$data['latitude'] = $line[4];
1240
+					$data['longitude'] = $line[5];
1241
+					$data['altitude'] = $line[6];
1242
+					$data['datetime'] = date('Y-m-d H:i:s');
1243
+					$aircraft_type = $line[10];
1244
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1245
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1246
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1247
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1248
+				}
1248 1249
 				}
1249
-			    }
1250 1250
 			} elseif ($format == 'beast') {
1251
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1252
-			    die;
1251
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1252
+				die;
1253 1253
 			} elseif ($format == 'vrstcp') {
1254
-			    foreach($buffer as $all_data) {
1254
+				foreach($buffer as $all_data) {
1255 1255
 				$line = json_decode('{'.$all_data.'}',true);
1256 1256
 				$data = array();
1257 1257
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1271,114 +1271,114 @@  discard block
 block discarded – undo
1271 1271
 				*/
1272 1272
 				$data['datetime'] = date('Y-m-d H:i:s');
1273 1273
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1274
-		    		$data['format_source'] = 'vrstcp';
1274
+					$data['format_source'] = 'vrstcp';
1275 1275
 				$data['id_source'] = $id_source;
1276 1276
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1277 1277
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1278 1278
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1279 1279
 				unset($data);
1280
-			    }
1280
+				}
1281 1281
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1282
-			    $line = explode("\t", $buffer);
1283
-			    for($k = 0; $k < count($line); $k=$k+2) {
1282
+				$line = explode("\t", $buffer);
1283
+				for($k = 0; $k < count($line); $k=$k+2) {
1284 1284
 				$key = $line[$k];
1285
-			        $lined[$key] = $line[$k+1];
1286
-			    }
1287
-    			    if (count($lined) > 3) {
1288
-    				$data['hex'] = $lined['hexid'];
1289
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1290
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1291
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1292
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1293
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1294
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1295
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1296
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1297
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1298
-    				$data['id_source'] = $id_source;
1299
-    				$data['format_source'] = 'tsv';
1300
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1301
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1285
+					$lined[$key] = $line[$k+1];
1286
+				}
1287
+					if (count($lined) > 3) {
1288
+					$data['hex'] = $lined['hexid'];
1289
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1290
+					$data['datetime'] = date('Y-m-d H:i:s');;
1291
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1292
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1293
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1294
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1295
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1296
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1297
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1298
+					$data['id_source'] = $id_source;
1299
+					$data['format_source'] = 'tsv';
1300
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1301
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1302 1302
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1303
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1304
-    				unset($lined);
1305
-    				unset($data);
1306
-    			    } else $error = true;
1303
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1304
+					unset($lined);
1305
+					unset($data);
1306
+					} else $error = true;
1307 1307
 			} elseif ($format == 'aprs' && $use_aprs) {
1308
-			    if ($aprs_connect == 0) {
1308
+				if ($aprs_connect == 0) {
1309 1309
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1310 1310
 				$aprs_connect = 1;
1311
-			    }
1311
+				}
1312 1312
 			    
1313
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1313
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1314 1314
 				$aprs_last_tx = time();
1315 1315
 				$data_aprs = "# Keep alive";
1316 1316
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1317
-			    }
1317
+				}
1318 1318
 			    
1319
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1320
-			    //echo 'APRS data : '.$buffer."\n";
1321
-			    $buffer = str_replace('APRS <- ','',$buffer);
1322
-			    $buffer = str_replace('APRS -> ','',$buffer);
1323
-			    //echo $buffer."\n";
1324
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1319
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1320
+				//echo 'APRS data : '.$buffer."\n";
1321
+				$buffer = str_replace('APRS <- ','',$buffer);
1322
+				$buffer = str_replace('APRS -> ','',$buffer);
1323
+				//echo $buffer."\n";
1324
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1325 1325
 				$line = $APRS->parse($buffer);
1326 1326
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1327 1327
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1328
-				    $aprs_last_tx = time();
1329
-				    $data = array();
1330
-				    //print_r($line);
1331
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1332
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1333
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1334
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1335
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1336
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1337
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1338
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1339
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1340
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1341
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1342
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1343
-				    $data['latitude'] = $line['latitude'];
1344
-				    $data['longitude'] = $line['longitude'];
1345
-				    //$data['verticalrate'] = $line[16];
1346
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1347
-				    //else $data['speed'] = 0;
1348
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1349
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1350
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1351
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1352
-				    //else $data['heading'] = 0;
1353
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1354
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1355
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1356
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1357
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1358
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1359
-    				    $data['id_source'] = $id_source;
1360
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1361
-				    else $data['format_source'] = 'aprs';
1362
-				    $data['source_name'] = $line['source'];
1363
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1364
-				    else $data['source_type'] = 'flarm';
1365
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1366
-				    $currentdate = date('Y-m-d H:i:s');
1367
-				    $aprsdate = strtotime($data['datetime']);
1368
-				    // Accept data if time <= system time + 20s
1369
-				    //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'])))) {
1370
-				    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'])))) {
1328
+					$aprs_last_tx = time();
1329
+					$data = array();
1330
+					//print_r($line);
1331
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1332
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1333
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1334
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1335
+					if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1336
+					if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1337
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1338
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1339
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1340
+					else $data['datetime'] = date('Y-m-d H:i:s');
1341
+					//$data['datetime'] = date('Y-m-d H:i:s');
1342
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1343
+					$data['latitude'] = $line['latitude'];
1344
+					$data['longitude'] = $line['longitude'];
1345
+					//$data['verticalrate'] = $line[16];
1346
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1347
+					//else $data['speed'] = 0;
1348
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1349
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1350
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1351
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
1352
+					//else $data['heading'] = 0;
1353
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1354
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1355
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1356
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1357
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1358
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1359
+						$data['id_source'] = $id_source;
1360
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1361
+					else $data['format_source'] = 'aprs';
1362
+					$data['source_name'] = $line['source'];
1363
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1364
+					else $data['source_type'] = 'flarm';
1365
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1366
+					$currentdate = date('Y-m-d H:i:s');
1367
+					$aprsdate = strtotime($data['datetime']);
1368
+					// Accept data if time <= system time + 20s
1369
+					//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'])))) {
1370
+					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'])))) {
1371 1371
 					$send = $SI->add($data);
1372
-				    } elseif ($data['source_type'] == 'ais') {
1372
+					} elseif ($data['source_type'] == 'ais') {
1373 1373
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1374
-				    } elseif (isset($line['stealth'])) {
1374
+					} elseif (isset($line['stealth'])) {
1375 1375
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1376 1376
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1377
-				    //} elseif (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' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1378
-				    } 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') {
1377
+					//} elseif (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' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1378
+					} 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') {
1379 1379
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1380 1380
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1381
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1381
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1382 1382
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1383 1383
 					$Source->deleteOldLocationByType('gs');
1384 1384
 					if (count($Source->getLocationInfoByName($data['ident'])) > 0) {
@@ -1386,11 +1386,11 @@  discard block
 block discarded – undo
1386 1386
 					} else {
1387 1387
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1388 1388
 					}
1389
-				    } else {
1390
-				    	echo '/!\ Not added'."\n";
1391
-				    	print_r($line);
1392
-				    }
1393
-				    unset($data);
1389
+					} else {
1390
+						echo '/!\ Not added'."\n";
1391
+						print_r($line);
1392
+					}
1393
+					unset($data);
1394 1394
 				} 
1395 1395
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1396 1396
 					echo '!! Weather Station not yet supported'."\n";
@@ -1406,12 +1406,12 @@  discard block
 block discarded – undo
1406 1406
 				*/
1407 1407
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1408 1408
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1409
-			    }
1409
+				}
1410 1410
 			} else {
1411
-			    $line = explode(',', $buffer);
1412
-    			    if (count($line) > 20) {
1413
-    			    	$data['hex'] = $line[4];
1414
-    				/*
1411
+				$line = explode(',', $buffer);
1412
+					if (count($line) > 20) {
1413
+						$data['hex'] = $line[4];
1414
+					/*
1415 1415
     				$data['datetime'] = $line[6].' '.$line[7];
1416 1416
     					date_default_timezone_set($globalTimezone);
1417 1417
     					$datetime = new DateTime($data['datetime']);
@@ -1419,30 +1419,30 @@  discard block
 block discarded – undo
1419 1419
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1420 1420
     					date_default_timezone_set('UTC');
1421 1421
     				*/
1422
-    				// Force datetime to current UTC datetime
1423
-    				date_default_timezone_set('UTC');
1424
-    				$data['datetime'] = date('Y-m-d H:i:s');
1425
-    				$data['ident'] = trim($line[10]);
1426
-    				$data['latitude'] = $line[14];
1427
-    				$data['longitude'] = $line[15];
1428
-    				$data['verticalrate'] = $line[16];
1429
-    				$data['emergency'] = $line[20];
1430
-    				$data['speed'] = $line[12];
1431
-    				$data['squawk'] = $line[17];
1432
-    				$data['altitude'] = $line[11];
1433
-    				$data['heading'] = $line[13];
1434
-    				$data['ground'] = $line[21];
1435
-    				$data['emergency'] = $line[19];
1436
-    				$data['format_source'] = 'sbs';
1422
+					// Force datetime to current UTC datetime
1423
+					date_default_timezone_set('UTC');
1424
+					$data['datetime'] = date('Y-m-d H:i:s');
1425
+					$data['ident'] = trim($line[10]);
1426
+					$data['latitude'] = $line[14];
1427
+					$data['longitude'] = $line[15];
1428
+					$data['verticalrate'] = $line[16];
1429
+					$data['emergency'] = $line[20];
1430
+					$data['speed'] = $line[12];
1431
+					$data['squawk'] = $line[17];
1432
+					$data['altitude'] = $line[11];
1433
+					$data['heading'] = $line[13];
1434
+					$data['ground'] = $line[21];
1435
+					$data['emergency'] = $line[19];
1436
+					$data['format_source'] = 'sbs';
1437 1437
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1438
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1438
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1439 1439
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1440
-    				$data['id_source'] = $id_source;
1441
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1442
-    				else $error = true;
1443
-    				unset($data);
1444
-    			    } else $error = true;
1445
-			    if ($error) {
1440
+					$data['id_source'] = $id_source;
1441
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1442
+					else $error = true;
1443
+					unset($data);
1444
+					} else $error = true;
1445
+				if ($error) {
1446 1446
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1447 1447
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1448 1448
 				} else {
@@ -1458,13 +1458,13 @@  discard block
 block discarded – undo
1458 1458
 					connect_all($sourceer);
1459 1459
 					$sourceer = array();
1460 1460
 				}
1461
-			    }
1461
+				}
1462 1462
 			}
1463 1463
 			// Sleep for xxx microseconds
1464 1464
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1465
-		    } else {
1465
+			} else {
1466 1466
 			if ($format == 'flightgearmp') {
1467
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1467
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1468 1468
 				//@socket_close($r);
1469 1469
 				sleep($globalMinFetch);
1470 1470
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1473,9 +1473,9 @@  discard block
 block discarded – undo
1473 1473
 				break;
1474 1474
 				
1475 1475
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1476
-			    if (isset($tt[$format])) $tt[$format]++;
1477
-			    else $tt[$format] = 0;
1478
-			    if ($tt[$format] > 30) {
1476
+				if (isset($tt[$format])) $tt[$format]++;
1477
+				else $tt[$format] = 0;
1478
+				if ($tt[$format] > 30) {
1479 1479
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1480 1480
 				//@socket_close($r);
1481 1481
 				sleep(2);
@@ -1486,23 +1486,23 @@  discard block
 block discarded – undo
1486 1486
 				//connect_all($globalSources);
1487 1487
 				$tt[$format]=0;
1488 1488
 				break;
1489
-			    }
1489
+				}
1490
+			}
1490 1491
 			}
1491
-		    }
1492 1492
 		}
1493
-	    } else {
1493
+		} else {
1494 1494
 		$error = socket_strerror(socket_last_error());
1495 1495
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1496 1496
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1497 1497
 			if (isset($globalDebug)) echo "Restarting...\n";
1498 1498
 			// Restart the script if possible
1499 1499
 			if (is_array($sockets)) {
1500
-			    if ($globalDebug) echo "Shutdown all sockets...";
1500
+				if ($globalDebug) echo "Shutdown all sockets...";
1501 1501
 			    
1502
-			    foreach ($sockets as $sock) {
1502
+				foreach ($sockets as $sock) {
1503 1503
 				@socket_shutdown($sock,2);
1504 1504
 				@socket_close($sock);
1505
-			    }
1505
+				}
1506 1506
 			    
1507 1507
 			}
1508 1508
 			if ($globalDebug) echo "Waiting...";
@@ -1517,13 +1517,13 @@  discard block
 block discarded – undo
1517 1517
 			if ($globalDebug) echo "Restart all connections...";
1518 1518
 			connect_all($globalSources);
1519 1519
 		}
1520
-	    }
1520
+		}
1521 1521
 	}
1522 1522
 	if ($globalDaemon === false) {
1523
-	    if ($globalDebug) echo 'Check all...'."\n";
1524
-	    $SI->checkAll();
1523
+		if ($globalDebug) echo 'Check all...'."\n";
1524
+		$SI->checkAll();
1525
+	}
1525 1526
 	}
1526
-    }
1527 1527
 }
1528 1528
 
1529 1529
 ?>
Please login to merge, or discard this patch.
install/index.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -317,18 +317,18 @@  discard block
 block discarded – undo
317 317
 				</tr>
318 318
 				<!--
319 319
 		<?php
320
-		    require_once(dirname(__FILE__).'/../require/class.Connection.php');
321
-		    $Connection = new Connection();
320
+			require_once(dirname(__FILE__).'/../require/class.Connection.php');
321
+			$Connection = new Connection();
322 322
 		?>
323 323
 				-->
324 324
 		<?php
325
-		    if ($Connection->db != NULL) {
325
+			if ($Connection->db != NULL) {
326 326
 			if ($Connection->tableExists('source_location')) {
327
-			    require_once(dirname(__FILE__).'/../require/class.Source.php');
328
-			    $Source = new Source();
329
-			    //$alllocations = $Source->getAllLocationInfo();
330
-			    $alllocations = $Source->getLocationInfobyType('');
331
-			    foreach ($alllocations as $location) {
327
+				require_once(dirname(__FILE__).'/../require/class.Source.php');
328
+				$Source = new Source();
329
+				//$alllocations = $Source->getAllLocationInfo();
330
+				$alllocations = $Source->getLocationInfobyType('');
331
+				foreach ($alllocations as $location) {
332 332
 		?>
333 333
 				<tr>
334 334
 	    				<input type="hidden" name="source_id[]" value="<?php print $location['id']; ?>" />
@@ -342,9 +342,9 @@  discard block
 block discarded – undo
342 342
 				</tr>
343 343
 		
344 344
 		<?php
345
-			    }
345
+				}
346
+			}
346 347
 			}
347
-		    }
348 348
 		?>
349 349
 
350 350
 				<tr>
@@ -452,12 +452,12 @@  discard block
 block discarded – undo
452 452
 ?>
453 453
 							<tr>
454 454
 								<?php
455
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
455
+									if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
456 456
 								?>
457 457
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
458 458
 								<td><input type="number" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
459 459
 								<?php
460
-								    } else {
460
+									} else {
461 461
 									$hostport = explode(':',$source['host']);
462 462
 									if (isset($hostport[1])) {
463 463
 										$host = $hostport[0];
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 								<td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td>
471 471
 								<td><input type="number" name="port[]" id="port" class="col-xs-2" value="<?php print $port; ?>" /></td>
472 472
 								<?php
473
-								    }
473
+									}
474 474
 								?>
475 475
 								<td>
476 476
 									<select name="format[]" id="format">
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 			<br />
864 864
 			<p>
865 865
 			<?php 
866
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
866
+				if (extension_loaded('gd') && function_exists('gd_info')) {
867 867
 			?>
868 868
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
869 869
 				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
@@ -873,11 +873,11 @@  discard block
 block discarded – undo
873 873
 				<b>The directory cache is not writable, aircraft icon will not be cached</b>
874 874
 			<?php
875 875
 				}
876
-			    } else {
876
+				} else {
877 877
 			?>
878 878
 				<b>PHP GD is not installed, you can t change color of aircraft icon on map</b>
879 879
 			<?php
880
-			    }
880
+				}
881 881
 			?>
882 882
 			</p>
883 883
 			<br />
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 	</p>
902 902
 <?php
903 903
 	require('../footer.php');
904
-        exit;
904
+		exit;
905 905
 }
906 906
 	
907 907
 $settings = array();
@@ -992,8 +992,8 @@  discard block
 block discarded – undo
992 992
 	
993 993
 	$sources = array();
994 994
 	foreach ($source_name as $keys => $name) {
995
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
996
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
995
+		if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
996
+		else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
997 997
 	}
998 998
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
999 999
 
@@ -1362,14 +1362,14 @@  discard block
 block discarded – undo
1362 1362
 
1363 1363
 	// Set some defaults values...
1364 1364
 	if (!isset($globalAircraftImageSources)) {
1365
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1366
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1365
+		$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1366
+		$settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1367 1367
 	}
1368 1368
 
1369 1369
 	if (!isset($globalSchedulesSources)) {
1370
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1371
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1372
-    	}
1370
+		$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1371
+			$settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1372
+		}
1373 1373
 
1374 1374
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1375 1375
 
@@ -1421,21 +1421,21 @@  discard block
 block discarded – undo
1421 1421
 	$popi = false;
1422 1422
 	$popw = false;
1423 1423
 	foreach ($_SESSION['done'] as $done) {
1424
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1425
-	    if ($done == 'Create database') $pop = true;
1426
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1427
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1428
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1424
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1425
+		if ($done == 'Create database') $pop = true;
1426
+		if ($_SESSION['install'] == 'database_create') $pop = true;
1427
+		if ($_SESSION['install'] == 'database_import') $popi = true;
1428
+		if ($_SESSION['install'] == 'waypoints') $popw = true;
1429 1429
 	}
1430 1430
 	if ($pop) {
1431
-	    sleep(5);
1432
-	    print '<li>Create database....<img src="../images/loading.gif" /></li>';
1431
+		sleep(5);
1432
+		print '<li>Create database....<img src="../images/loading.gif" /></li>';
1433 1433
 	} else if ($popi) {
1434
-	    sleep(5);
1435
-	    print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1434
+		sleep(5);
1435
+		print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1436 1436
 	} else if ($popw) {
1437
-	    sleep(5);
1438
-	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1437
+		sleep(5);
1438
+		print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1439 1439
 	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1440 1440
 	print '</div></ul>';
1441 1441
 	print '<div id="error"></div>';
@@ -1498,7 +1498,7 @@  discard block
 block discarded – undo
1498 1498
 	unset($_COOKIE['install']);
1499 1499
 	print '<div class="info column"><ul>';
1500 1500
 	foreach ($_SESSION['done'] as $done) {
1501
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1501
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1502 1502
 	}
1503 1503
 	print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>';
1504 1504
 	print '</ul></div>';
Please login to merge, or discard this patch.