Completed
Push — master ( c4688e...41b901 )
by Yannick
06:49
created
scripts/daemon-spotter.php 1 patch
Indentation   +832 added lines, -832 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16 16
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17 17
 if (isset($globalMarine) && $globalMarine) {
18
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
19
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
18
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
19
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
20 20
 }
21 21
 
22 22
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -24,52 +24,52 @@  discard block
 block discarded – undo
24 24
 // Check if schema is at latest version
25 25
 $Connection = new Connection();
26 26
 if ($Connection->latest() === false) {
27
-    echo "You MUST update to latest schema. Run install/index.php";
28
-    exit();
27
+	echo "You MUST update to latest schema. Run install/index.php";
28
+	exit();
29 29
 }
30 30
 if (PHP_SAPI != 'cli') {
31
-    echo "This script MUST be called from console, not a web browser.";
31
+	echo "This script MUST be called from console, not a web browser.";
32 32
 //    exit();
33 33
 }
34 34
 
35 35
 // This is to be compatible with old version of settings.php
36 36
 if (!isset($globalSources)) {
37
-    if (isset($globalSBS1Hosts)) {
38
-        //$hosts = $globalSBS1Hosts;
39
-        foreach ($globalSBS1Hosts as $host) {
40
-	    $globalSources[] = array('host' => $host);
41
-    	}
42
-    } else {
43
-        if (!isset($globalSBS1Host)) {
44
-	    echo '$globalSources MUST be defined !';
45
-	    die;
37
+	if (isset($globalSBS1Hosts)) {
38
+		//$hosts = $globalSBS1Hosts;
39
+		foreach ($globalSBS1Hosts as $host) {
40
+		$globalSources[] = array('host' => $host);
41
+		}
42
+	} else {
43
+		if (!isset($globalSBS1Host)) {
44
+		echo '$globalSources MUST be defined !';
45
+		die;
46 46
 	}
47 47
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
48 48
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
49
-    }
49
+	}
50 50
 }
51 51
 
52 52
 $options = getopt('s::',array('source::','server','idsource::'));
53 53
 //if (isset($options['s'])) $hosts = array($options['s']);
54 54
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 55
 if (isset($options['s'])) {
56
-    $globalSources = array();
57
-    $globalSources[] = array('host' => $options['s']);
56
+	$globalSources = array();
57
+	$globalSources[] = array('host' => $options['s']);
58 58
 } elseif (isset($options['source'])) {
59
-    $globalSources = array();
60
-    $globalSources[] = array('host' => $options['source']);
59
+	$globalSources = array();
60
+	$globalSources[] = array('host' => $options['source']);
61 61
 }
62 62
 if (isset($options['server'])) $globalServer = TRUE;
63 63
 if (isset($options['idsource'])) $id_source = $options['idsource'];
64 64
 else $id_source = 1;
65 65
 if (isset($globalServer) && $globalServer) {
66
-    if ($globalDebug) echo "Using Server Mode\n";
67
-    $SI=new SpotterServer();
66
+	if ($globalDebug) echo "Using Server Mode\n";
67
+	$SI=new SpotterServer();
68 68
 } else $SI=new SpotterImport($Connection->db);
69 69
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
70 70
 if (isset($globalMarine) && $globalMarine) {
71
-    $AIS = new AIS();
72
-    $MI = new MarineImport($Connection->db);
71
+	$AIS = new AIS();
72
+	$MI = new MarineImport($Connection->db);
73 73
 }
74 74
 //$APRS=new APRS($Connection->db);
75 75
 $SBS=new SBS();
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
 //$servertz = system('date +%Z');
80 80
 // signal handler - playing nice with sockets and dump1090
81 81
 if (function_exists('pcntl_fork')) {
82
-    pcntl_signal(SIGINT,  function() {
83
-        global $sockets;
84
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
85
-        die("Bye!\n");
86
-    });
87
-    pcntl_signal_dispatch();
82
+	pcntl_signal(SIGINT,  function() {
83
+		global $sockets;
84
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
85
+		die("Bye!\n");
86
+	});
87
+	pcntl_signal_dispatch();
88 88
 }
89 89
 
90 90
 // let's try and connect
@@ -94,169 +94,169 @@  discard block
 block discarded – undo
94 94
 $reset = 0;
95 95
 
96 96
 function create_socket($host, $port, &$errno, &$errstr) {
97
-    $ip = gethostbyname($host);
98
-    $s = socket_create(AF_INET, SOCK_STREAM, 0);
99
-    $r = @socket_connect($s, $ip, $port);
100
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
101
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
102
-        return $s;
103
-    }
104
-    $errno = socket_last_error($s);
105
-    $errstr = socket_strerror($errno);
106
-    socket_close($s);
107
-    return false;
97
+	$ip = gethostbyname($host);
98
+	$s = socket_create(AF_INET, SOCK_STREAM, 0);
99
+	$r = @socket_connect($s, $ip, $port);
100
+	if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
101
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
102
+		return $s;
103
+	}
104
+	$errno = socket_last_error($s);
105
+	$errstr = socket_strerror($errno);
106
+	socket_close($s);
107
+	return false;
108 108
 }
109 109
 
110 110
 function create_socket_udp($host, $port, &$errno, &$errstr) {
111
-    echo "Create an UDP socket...\n";
112
-    $ip = gethostbyname($host);
113
-    $s = socket_create(AF_INET, SOCK_DGRAM, 0);
114
-    $r = @socket_bind($s, $ip, $port);
115
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
116
-        return $s;
117
-    }
118
-    $errno = socket_last_error($s);
119
-    $errstr = socket_strerror($errno);
120
-    socket_close($s);
121
-    return false;
111
+	echo "Create an UDP socket...\n";
112
+	$ip = gethostbyname($host);
113
+	$s = socket_create(AF_INET, SOCK_DGRAM, 0);
114
+	$r = @socket_bind($s, $ip, $port);
115
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
116
+		return $s;
117
+	}
118
+	$errno = socket_last_error($s);
119
+	$errstr = socket_strerror($errno);
120
+	socket_close($s);
121
+	return false;
122 122
 }
123 123
 
124 124
 function connect_all($hosts) {
125
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
126
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
127
-    $reset++;
128
-    if ($globalDebug) echo 'Connect to all...'."\n";
129
-    foreach ($hosts as $id => $value) {
125
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
126
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
127
+	$reset++;
128
+	if ($globalDebug) echo 'Connect to all...'."\n";
129
+	foreach ($hosts as $id => $value) {
130 130
 	$host = $value['host'];
131 131
 	$globalSources[$id]['last_exec'] = 0;
132 132
 	// Here we check type of source(s)
133 133
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
134
-            if (preg_match('/deltadb.txt$/i',$host)) {
135
-        	//$formats[$id] = 'deltadbtxt';
136
-        	$globalSources[$id]['format'] = 'deltadbtxt';
137
-        	//$last_exec['deltadbtxt'] = 0;
138
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
139
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
140
-        	//$formats[$id] = 'vatsimtxt';
141
-        	$globalSources[$id]['format'] = 'vatsimtxt';
142
-        	//$last_exec['vatsimtxt'] = 0;
143
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
144
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
145
-        	//$formats[$id] = 'aircraftlistjson';
146
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
147
-        	//$last_exec['aircraftlistjson'] = 0;
148
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
149
-    	    } else if (preg_match('/opensky/i',$host)) {
150
-        	//$formats[$id] = 'aircraftlistjson';
151
-        	$globalSources[$id]['format'] = 'opensky';
152
-        	//$last_exec['aircraftlistjson'] = 0;
153
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
154
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
155
-        	//$formats[$id] = 'radarvirtueljson';
156
-        	$globalSources[$id]['format'] = 'radarvirtueljson';
157
-        	//$last_exec['radarvirtueljson'] = 0;
158
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
159
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
160
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
161
-        	    exit(0);
162
-        	}
163
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
164
-        	//$formats[$id] = 'planeupdatefaa';
165
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
166
-        	//$last_exec['planeupdatefaa'] = 0;
167
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
168
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
169
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
170
-        	    exit(0);
171
-        	}
172
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
173
-        	//$formats[$id] = 'phpvmacars';
174
-        	$globalSources[$id]['format'] = 'phpvmacars';
175
-        	//$last_exec['phpvmacars'] = 0;
176
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
177
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
178
-        	//$formats[$id] = 'phpvmacars';
179
-        	$globalSources[$id]['format'] = 'vam';
180
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
181
-            } else if (preg_match('/whazzup/i',$host)) {
182
-        	//$formats[$id] = 'whazzup';
183
-        	$globalSources[$id]['format'] = 'whazzup';
184
-        	//$last_exec['whazzup'] = 0;
185
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
186
-            } else if (preg_match('/recentpireps/i',$host)) {
187
-        	//$formats[$id] = 'pirepsjson';
188
-        	$globalSources[$id]['format'] = 'pirepsjson';
189
-        	//$last_exec['pirepsjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
191
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
192
-        	//$formats[$id] = 'fr24json';
193
-        	$globalSources[$id]['format'] = 'fr24json';
194
-        	//$last_exec['fr24json'] = 0;
195
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
196
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
197
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
198
-        	    exit(0);
199
-        	}
200
-            //} else if (preg_match('/10001/',$host)) {
201
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
202
-        	//$formats[$id] = 'tsv';
203
-        	$globalSources[$id]['format'] = 'tsv';
204
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
205
-            }
206
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
207
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
208
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
209
-    		    if ($idf !== false) {
210
-    			$httpfeeds[$id] = $idf;
211
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
212
-    		    }
213
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
214
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
215
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
216
-	    $hostport = explode(':',$host);
217
-	    if (isset($hostport[1])) {
134
+			if (preg_match('/deltadb.txt$/i',$host)) {
135
+			//$formats[$id] = 'deltadbtxt';
136
+			$globalSources[$id]['format'] = 'deltadbtxt';
137
+			//$last_exec['deltadbtxt'] = 0;
138
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
139
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
140
+			//$formats[$id] = 'vatsimtxt';
141
+			$globalSources[$id]['format'] = 'vatsimtxt';
142
+			//$last_exec['vatsimtxt'] = 0;
143
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
144
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
145
+			//$formats[$id] = 'aircraftlistjson';
146
+			$globalSources[$id]['format'] = 'aircraftlistjson';
147
+			//$last_exec['aircraftlistjson'] = 0;
148
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
149
+			} else if (preg_match('/opensky/i',$host)) {
150
+			//$formats[$id] = 'aircraftlistjson';
151
+			$globalSources[$id]['format'] = 'opensky';
152
+			//$last_exec['aircraftlistjson'] = 0;
153
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
154
+			} else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
155
+			//$formats[$id] = 'radarvirtueljson';
156
+			$globalSources[$id]['format'] = 'radarvirtueljson';
157
+			//$last_exec['radarvirtueljson'] = 0;
158
+			if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
159
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
160
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
161
+				exit(0);
162
+			}
163
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
164
+			//$formats[$id] = 'planeupdatefaa';
165
+			$globalSources[$id]['format'] = 'planeupdatefaa';
166
+			//$last_exec['planeupdatefaa'] = 0;
167
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
168
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
169
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
170
+				exit(0);
171
+			}
172
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
173
+			//$formats[$id] = 'phpvmacars';
174
+			$globalSources[$id]['format'] = 'phpvmacars';
175
+			//$last_exec['phpvmacars'] = 0;
176
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
177
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
178
+			//$formats[$id] = 'phpvmacars';
179
+			$globalSources[$id]['format'] = 'vam';
180
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
181
+			} else if (preg_match('/whazzup/i',$host)) {
182
+			//$formats[$id] = 'whazzup';
183
+			$globalSources[$id]['format'] = 'whazzup';
184
+			//$last_exec['whazzup'] = 0;
185
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
186
+			} else if (preg_match('/recentpireps/i',$host)) {
187
+			//$formats[$id] = 'pirepsjson';
188
+			$globalSources[$id]['format'] = 'pirepsjson';
189
+			//$last_exec['pirepsjson'] = 0;
190
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
191
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
192
+			//$formats[$id] = 'fr24json';
193
+			$globalSources[$id]['format'] = 'fr24json';
194
+			//$last_exec['fr24json'] = 0;
195
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
196
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
197
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
198
+				exit(0);
199
+			}
200
+			//} else if (preg_match('/10001/',$host)) {
201
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
202
+			//$formats[$id] = 'tsv';
203
+			$globalSources[$id]['format'] = 'tsv';
204
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
205
+			}
206
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
207
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
208
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
209
+				if ($idf !== false) {
210
+				$httpfeeds[$id] = $idf;
211
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
212
+				}
213
+				elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
214
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
215
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
216
+		$hostport = explode(':',$host);
217
+		if (isset($hostport[1])) {
218 218
 		$port = $hostport[1];
219 219
 		$hostn = $hostport[0];
220
-	    } else {
220
+		} else {
221 221
 		$port = $globalSources[$id]['port'];
222 222
 		$hostn = $globalSources[$id]['host'];
223
-	    }
224
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
225
-        	$s = create_socket($hostn,$port, $errno, $errstr);
226
-    	    } else {
227
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
228
-	    }
229
-	    if ($s) {
230
-    	        $sockets[$id] = $s;
231
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
232
-		    if (preg_match('/aprs/',$hostn)) {
223
+		}
224
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
225
+			$s = create_socket($hostn,$port, $errno, $errstr);
226
+			} else {
227
+			$s = create_socket_udp($hostn,$port, $errno, $errstr);
228
+		}
229
+		if ($s) {
230
+				$sockets[$id] = $s;
231
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
232
+			if (preg_match('/aprs/',$hostn)) {
233 233
 			//$formats[$id] = 'aprs';
234 234
 			$globalSources[$id]['format'] = 'aprs';
235 235
 			//$aprs_connect = 0;
236 236
 			//$use_aprs = true;
237
-    		    } elseif ($port == '10001') {
238
-        		//$formats[$id] = 'tsv';
239
-        		$globalSources[$id]['format'] = 'tsv';
240
-		    } elseif ($port == '30002') {
241
-        		//$formats[$id] = 'raw';
242
-        		$globalSources[$id]['format'] = 'raw';
243
-		    } elseif ($port == '5001') {
244
-        		//$formats[$id] = 'raw';
245
-        		$globalSources[$id]['format'] = 'flightgearmp';
246
-		    } elseif ($port == '30005') {
237
+				} elseif ($port == '10001') {
238
+				//$formats[$id] = 'tsv';
239
+				$globalSources[$id]['format'] = 'tsv';
240
+			} elseif ($port == '30002') {
241
+				//$formats[$id] = 'raw';
242
+				$globalSources[$id]['format'] = 'raw';
243
+			} elseif ($port == '5001') {
244
+				//$formats[$id] = 'raw';
245
+				$globalSources[$id]['format'] = 'flightgearmp';
246
+			} elseif ($port == '30005') {
247 247
 			// Not yet supported
248
-        		//$formats[$id] = 'beast';
249
-        		$globalSources[$id]['format'] = 'beast';
250
-		    //} else $formats[$id] = 'sbs';
251
-		    } else $globalSources[$id]['format'] = 'sbs';
252
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
248
+				//$formats[$id] = 'beast';
249
+				$globalSources[$id]['format'] = 'beast';
250
+			//} else $formats[$id] = 'sbs';
251
+			} else $globalSources[$id]['format'] = 'sbs';
252
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
253 253
 		}
254 254
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
255
-            } else {
255
+			} else {
256 256
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
257
-    	    }
258
-        }
259
-    }
257
+			}
258
+		}
259
+	}
260 260
 }
261 261
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
262 262
 
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
 //connect_all($globalSources);
280 280
 
281 281
 if (isset($globalProxy) && $globalProxy) {
282
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
282
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
283 283
 } else {
284
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
284
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
285 285
 }
286 286
 
287 287
 // APRS Configuration
@@ -290,18 +290,18 @@  discard block
 block discarded – undo
290 290
 	die;
291 291
 }
292 292
 foreach ($globalSources as $key => $source) {
293
-    if (!isset($source['format'])) {
294
-        $globalSources[$key]['format'] = 'auto';
295
-    }
293
+	if (!isset($source['format'])) {
294
+		$globalSources[$key]['format'] = 'auto';
295
+	}
296 296
 }
297 297
 connect_all($globalSources);
298 298
 foreach ($globalSources as $key => $source) {
299
-    if (isset($source['format']) && $source['format'] == 'aprs') {
299
+	if (isset($source['format']) && $source['format'] == 'aprs') {
300 300
 	$aprs_connect = 0;
301 301
 	$use_aprs = true;
302 302
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
303 303
 	break;
304
-    }
304
+	}
305 305
 }
306 306
 
307 307
 if ($use_aprs) {
@@ -340,188 +340,188 @@  discard block
 block discarded – undo
340 340
 
341 341
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
342 342
 while ($i > 0) {
343
-    if (!$globalDaemon) $i = $endtime-time();
344
-    // Delete old ATC
345
-    if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
343
+	if (!$globalDaemon) $i = $endtime-time();
344
+	// Delete old ATC
345
+	if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
346 346
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
347
-        $ATC->deleteOldATC();
348
-    }
347
+		$ATC->deleteOldATC();
348
+	}
349 349
     
350
-    //if (count($last_exec) > 0) {
351
-    if (count($last_exec) == count($globalSources)) {
350
+	//if (count($last_exec) > 0) {
351
+	if (count($last_exec) == count($globalSources)) {
352 352
 	$max = $globalMinFetch;
353 353
 	foreach ($last_exec as $last) {
354
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
354
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
355 355
 	}
356 356
 	if ($max != $globalMinFetch) {
357
-	    if ($globalDebug) echo 'Sleeping...'."\n";
358
-	    sleep($globalMinFetch-$max+2);
357
+		if ($globalDebug) echo 'Sleeping...'."\n";
358
+		sleep($globalMinFetch-$max+2);
359
+	}
359 360
 	}
360
-    }
361 361
 
362 362
     
363
-    //foreach ($formats as $id => $value) {
364
-    foreach ($globalSources as $id => $value) {
363
+	//foreach ($formats as $id => $value) {
364
+	foreach ($globalSources as $id => $value) {
365 365
 	date_default_timezone_set('UTC');
366 366
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
367 367
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
368
-	    //$buffer = $Common->getData($hosts[$id]);
369
-	    $buffer = $Common->getData($value['host']);
370
-	    if ($buffer != '') $reset = 0;
371
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
372
-	    $buffer = explode('\n',$buffer);
373
-	    foreach ($buffer as $line) {
374
-    		if ($line != '' && count($line) > 7) {
375
-    		    $line = explode(',', $line);
376
-	            $data = array();
377
-	            $data['hex'] = $line[1]; // hex
378
-	            $data['ident'] = $line[2]; // ident
379
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
380
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
381
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
382
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
383
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
384
-	            $data['verticalrate'] = ''; // vertical rate
385
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
386
-	            $data['emergency'] = ''; // emergency
387
-		    $data['datetime'] = date('Y-m-d H:i:s');
388
-		    $data['format_source'] = 'deltadbtxt';
389
-    		    $data['id_source'] = $id_source;
390
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
391
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
392
-    		    $SI->add($data);
393
-		    unset($data);
394
-    		}
395
-    	    }
396
-    	    $last_exec[$id]['last'] = time();
368
+		//$buffer = $Common->getData($hosts[$id]);
369
+		$buffer = $Common->getData($value['host']);
370
+		if ($buffer != '') $reset = 0;
371
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
372
+		$buffer = explode('\n',$buffer);
373
+		foreach ($buffer as $line) {
374
+			if ($line != '' && count($line) > 7) {
375
+				$line = explode(',', $line);
376
+				$data = array();
377
+				$data['hex'] = $line[1]; // hex
378
+				$data['ident'] = $line[2]; // ident
379
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
380
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
381
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
382
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
383
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
384
+				$data['verticalrate'] = ''; // vertical rate
385
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
386
+				$data['emergency'] = ''; // emergency
387
+			$data['datetime'] = date('Y-m-d H:i:s');
388
+			$data['format_source'] = 'deltadbtxt';
389
+				$data['id_source'] = $id_source;
390
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
391
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
392
+				$SI->add($data);
393
+			unset($data);
394
+			}
395
+			}
396
+			$last_exec[$id]['last'] = time();
397 397
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
398
-	    date_default_timezone_set('CET');
399
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
400
-	    date_default_timezone_set('UTC');
401
-	    if ($buffer != '') $reset = 0;
402
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
403
-	    $buffer = explode('\n',$buffer);
404
-	    foreach ($buffer as $line) {
398
+		date_default_timezone_set('CET');
399
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
400
+		date_default_timezone_set('UTC');
401
+		if ($buffer != '') $reset = 0;
402
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
403
+		$buffer = explode('\n',$buffer);
404
+		foreach ($buffer as $line) {
405 405
 		if ($line != '') {
406
-		    echo "'".$line."'\n";
407
-		    $add = false;
408
-		    $ais_data = $AIS->parse_line(trim($line));
409
-		    $data = array();
410
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
411
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
412
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
413
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
414
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
415
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
416
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
417
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
418
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
419
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
420
-		    if (isset($ais_data['timestamp'])) {
406
+			echo "'".$line."'\n";
407
+			$add = false;
408
+			$ais_data = $AIS->parse_line(trim($line));
409
+			$data = array();
410
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
411
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
412
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
413
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
414
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
415
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
416
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
417
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
418
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
419
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
420
+			if (isset($ais_data['timestamp'])) {
421 421
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
422 422
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
423
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
424
-			    $add = true;
423
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
424
+				$add = true;
425 425
 			}
426
-		    } else {
426
+			} else {
427 427
 			$data['datetime'] = date('Y-m-d H:i:s');
428 428
 			$add = true;
429
-		    }
430
-		    $data['format_source'] = 'aisnmeatxt';
431
-    		    $data['id_source'] = $id_source;
432
-		    print_r($data);
433
-		    echo 'Add...'."\n";
434
-		    if ($add) $MI->add($data);
435
-		    unset($data);
429
+			}
430
+			$data['format_source'] = 'aisnmeatxt';
431
+				$data['id_source'] = $id_source;
432
+			print_r($data);
433
+			echo 'Add...'."\n";
434
+			if ($add) $MI->add($data);
435
+			unset($data);
436 436
 		}
437
-    	    }
438
-    	    $last_exec[$id]['last'] = time();
437
+			}
438
+			$last_exec[$id]['last'] = time();
439 439
 	} elseif ($value['format'] == 'aisnmeahttp') {
440
-	    $arr = $httpfeeds;
441
-	    $w = $e = null;
440
+		$arr = $httpfeeds;
441
+		$w = $e = null;
442 442
 	    
443
-	    if (isset($arr[$id])) {
444
-	    $nn = stream_select($arr,$w,$e,$timeout);
445
-	    if ($nn > 0) {
443
+		if (isset($arr[$id])) {
444
+		$nn = stream_select($arr,$w,$e,$timeout);
445
+		if ($nn > 0) {
446 446
 		foreach ($httpfeeds as $feed) {
447
-		    $buffer = stream_get_line($feed,2000,"\n");
448
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
449
-		    $buffer = explode('\n',$buffer);
450
-		    foreach ($buffer as $line) {
447
+			$buffer = stream_get_line($feed,2000,"\n");
448
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
449
+			$buffer = explode('\n',$buffer);
450
+			foreach ($buffer as $line) {
451 451
 			if ($line != '') {
452
-			    $ais_data = $AIS->parse_line(trim($line));
453
-			    $data = array();
454
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
455
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
456
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
457
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
458
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
459
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
460
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
461
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
462
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
463
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
464
-			    if (isset($ais_data['timestamp'])) {
452
+				$ais_data = $AIS->parse_line(trim($line));
453
+				$data = array();
454
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
455
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
456
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
457
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
458
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
459
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
460
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
461
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
462
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
463
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
464
+				if (isset($ais_data['timestamp'])) {
465 465
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
466
-			    } else {
466
+				} else {
467 467
 				$data['datetime'] = date('Y-m-d H:i:s');
468
-			    }
469
-			    $data['format_source'] = 'aisnmeahttp';
470
-			    $data['id_source'] = $id_source;
471
-			    $MI->add($data);
472
-			    unset($data);
468
+				}
469
+				$data['format_source'] = 'aisnmeahttp';
470
+				$data['id_source'] = $id_source;
471
+				$MI->add($data);
472
+				unset($data);
473 473
 			}
474
-		    }
474
+			}
475
+		}
475 476
 		}
476 477
 		}
477
-	    }
478 478
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
479
-	    echo 'download...';
480
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
481
-	    echo 'done !'."\n";
482
-	    if ($buffer != '') $reset = 0;
483
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
484
-	    $buffer = explode('\n',$buffer);
485
-	    foreach ($buffer as $line) {
479
+		echo 'download...';
480
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
481
+		echo 'done !'."\n";
482
+		if ($buffer != '') $reset = 0;
483
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
484
+		$buffer = explode('\n',$buffer);
485
+		foreach ($buffer as $line) {
486 486
 		if ($line != '') {
487
-		    $data = array();
488
-		    $data['mmsi'] = (int)substr($line,0,9);
489
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
490
-		    //$data['status'] = substr($line,21,2);
491
-		    //$data['type'] = substr($line,24,3);
492
-		    $data['latitude'] = substr($line,29,9);
493
-		    $data['longitude'] = substr($line,41,9);
494
-		    $data['speed'] = round(substr($line,51,5));
495
-		    //$data['course'] = substr($line,57,5);
496
-		    $data['heading'] = round(substr($line,63,3));
497
-		    //$data['draft'] = substr($line,67,4);
498
-		    //$data['length'] = substr($line,72,3);
499
-		    //$data['beam'] = substr($line,76,2);
500
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
501
-		    //$data['callsign'] = trim(substr($line,100,7);
502
-		    //$data['dest'] = substr($line,108,20);
503
-		    //$data['etaDate'] = substr($line,129,5);
504
-		    //$data['etaTime'] = substr($line,135,5);
505
-		    $data['format_source'] = 'shipplotter';
506
-    		    $data['id_source'] = $id_source;
507
-		    print_r($data);
508
-		    echo 'Add...'."\n";
509
-		    $MI->add($data);
510
-		    unset($data);
487
+			$data = array();
488
+			$data['mmsi'] = (int)substr($line,0,9);
489
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
490
+			//$data['status'] = substr($line,21,2);
491
+			//$data['type'] = substr($line,24,3);
492
+			$data['latitude'] = substr($line,29,9);
493
+			$data['longitude'] = substr($line,41,9);
494
+			$data['speed'] = round(substr($line,51,5));
495
+			//$data['course'] = substr($line,57,5);
496
+			$data['heading'] = round(substr($line,63,3));
497
+			//$data['draft'] = substr($line,67,4);
498
+			//$data['length'] = substr($line,72,3);
499
+			//$data['beam'] = substr($line,76,2);
500
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
501
+			//$data['callsign'] = trim(substr($line,100,7);
502
+			//$data['dest'] = substr($line,108,20);
503
+			//$data['etaDate'] = substr($line,129,5);
504
+			//$data['etaTime'] = substr($line,135,5);
505
+			$data['format_source'] = 'shipplotter';
506
+				$data['id_source'] = $id_source;
507
+			print_r($data);
508
+			echo 'Add...'."\n";
509
+			$MI->add($data);
510
+			unset($data);
511 511
 		}
512
-    	    }
513
-    	    $last_exec[$id]['last'] = time();
512
+			}
513
+			$last_exec[$id]['last'] = time();
514 514
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
515 515
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
516
-	    //$buffer = $Common->getData($hosts[$id]);
517
-	    $buffer = $Common->getData($value['host']);
518
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
519
-	    $buffer = explode('\n',$buffer);
520
-	    $reset = 0;
521
-	    foreach ($buffer as $line) {
522
-    		if ($line != '') {
523
-    		    $line = explode(':', $line);
524
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
516
+		//$buffer = $Common->getData($hosts[$id]);
517
+		$buffer = $Common->getData($value['host']);
518
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
519
+		$buffer = explode('\n',$buffer);
520
+		$reset = 0;
521
+		foreach ($buffer as $line) {
522
+			if ($line != '') {
523
+				$line = explode(':', $line);
524
+				if (count($line) > 30 && $line[0] != 'callsign') {
525 525
 			$data = array();
526 526
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
527 527
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -534,36 +534,36 @@  discard block
 block discarded – undo
534 534
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
535 535
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
536 536
 			$data['latitude'] = $line[5]; // lat
537
-	        	$data['longitude'] = $line[6]; // long
538
-	        	$data['verticalrate'] = ''; // vertical rate
539
-	        	$data['squawk'] = ''; // squawk
540
-	        	$data['emergency'] = ''; // emergency
541
-	        	$data['waypoints'] = $line[30];
537
+				$data['longitude'] = $line[6]; // long
538
+				$data['verticalrate'] = ''; // vertical rate
539
+				$data['squawk'] = ''; // squawk
540
+				$data['emergency'] = ''; // emergency
541
+				$data['waypoints'] = $line[30];
542 542
 			$data['datetime'] = date('Y-m-d H:i:s');
543 543
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
544 544
 			//if (isset($line[37])) $data['last_update'] = $line[37];
545
-		        $data['departure_airport_icao'] = $line[11];
546
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
547
-		        $data['arrival_airport_icao'] = $line[13];
545
+				$data['departure_airport_icao'] = $line[11];
546
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
547
+				$data['arrival_airport_icao'] = $line[13];
548 548
 			$data['frequency'] = $line[4];
549 549
 			$data['type'] = $line[18];
550 550
 			$data['range'] = $line[19];
551 551
 			if (isset($line[35])) $data['info'] = $line[35];
552
-    			$data['id_source'] = $id_source;
553
-	    		//$data['arrival_airport_time'] = ;
554
-	    		if ($line[9] != '') {
555
-	    		    $aircraft_data = explode('/',$line[9]);
556
-	    		    if (isset($aircraft_data[1])) {
557
-	    			$data['aircraft_icao'] = $aircraft_data[1];
558
-	    		    }
559
-        		}
560
-	    		/*
552
+				$data['id_source'] = $id_source;
553
+				//$data['arrival_airport_time'] = ;
554
+				if ($line[9] != '') {
555
+					$aircraft_data = explode('/',$line[9]);
556
+					if (isset($aircraft_data[1])) {
557
+					$data['aircraft_icao'] = $aircraft_data[1];
558
+					}
559
+				}
560
+				/*
561 561
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
562 562
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
563 563
 	    		*/
564
-	    		$data['format_source'] = $value['format'];
564
+				$data['format_source'] = $value['format'];
565 565
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
566
-    			if ($line[3] == 'PILOT') $SI->add($data);
566
+				if ($line[3] == 'PILOT') $SI->add($data);
567 567
 			elseif ($line[3] == 'ATC') {
568 568
 				//print_r($data);
569 569
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -581,247 +581,247 @@  discard block
 block discarded – undo
581 581
 				if (!isset($data['source_name'])) $data['source_name'] = '';
582 582
 				if (isset($ATC)) 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']);
583 583
 			}
584
-    			unset($data);
585
-    		    }
586
-    		}
587
-    	    }
588
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
589
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
590
-    	    $last_exec[$id]['last'] = time();
591
-    	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
592
-    	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
593
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
594
-	    if ($buffer != '') {
595
-	    $all_data = json_decode($buffer,true);
596
-	    if (isset($all_data['acList'])) {
584
+				unset($data);
585
+				}
586
+			}
587
+			}
588
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
589
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
590
+			$last_exec[$id]['last'] = time();
591
+		//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
592
+		} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
593
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
594
+		if ($buffer != '') {
595
+		$all_data = json_decode($buffer,true);
596
+		if (isset($all_data['acList'])) {
597 597
 		$reset = 0;
598 598
 		foreach ($all_data['acList'] as $line) {
599
-		    $data = array();
600
-		    $data['hex'] = $line['Icao']; // hex
601
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
602
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
603
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
604
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
605
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
606
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
607
-		    //$data['verticalrate'] = $line['']; // verticale rate
608
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
609
-		    $data['emergency'] = ''; // emergency
610
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
611
-		    /*
599
+			$data = array();
600
+			$data['hex'] = $line['Icao']; // hex
601
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
602
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
603
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
604
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
605
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
606
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
607
+			//$data['verticalrate'] = $line['']; // verticale rate
608
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
609
+			$data['emergency'] = ''; // emergency
610
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
611
+			/*
612 612
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
613 613
 		    else $data['datetime'] = date('Y-m-d H:i:s');
614 614
 		    */
615
-		    $data['datetime'] = date('Y-m-d H:i:s');
616
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
617
-	    	    $data['format_source'] = 'aircraftlistjson';
618
-		    $data['id_source'] = $id_source;
619
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
620
-		    if (isset($data['datetime'])) $SI->add($data);
621
-		    unset($data);
615
+			$data['datetime'] = date('Y-m-d H:i:s');
616
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
617
+				$data['format_source'] = 'aircraftlistjson';
618
+			$data['id_source'] = $id_source;
619
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
620
+			if (isset($data['datetime'])) $SI->add($data);
621
+			unset($data);
622 622
 		}
623
-	    } else {
623
+		} else {
624 624
 		$reset = 0;
625 625
 		foreach ($all_data as $line) {
626
-		    $data = array();
627
-		    $data['hex'] = $line['hex']; // hex
628
-		    $data['ident'] = $line['flight']; // ident
629
-		    $data['altitude'] = $line['altitude']; // altitude
630
-		    $data['speed'] = $line['speed']; // speed
631
-		    $data['heading'] = $line['track']; // heading
632
-		    $data['latitude'] = $line['lat']; // lat
633
-		    $data['longitude'] = $line['lon']; // long
634
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
635
-		    $data['squawk'] = $line['squawk']; // squawk
636
-		    $data['emergency'] = ''; // emergency
637
-		    $data['datetime'] = date('Y-m-d H:i:s');
638
-	    	    $data['format_source'] = 'aircraftlistjson';
639
-    		    $data['id_source'] = $id_source;
640
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
641
-		    $SI->add($data);
642
-		    unset($data);
626
+			$data = array();
627
+			$data['hex'] = $line['hex']; // hex
628
+			$data['ident'] = $line['flight']; // ident
629
+			$data['altitude'] = $line['altitude']; // altitude
630
+			$data['speed'] = $line['speed']; // speed
631
+			$data['heading'] = $line['track']; // heading
632
+			$data['latitude'] = $line['lat']; // lat
633
+			$data['longitude'] = $line['lon']; // long
634
+			$data['verticalrate'] = $line['vrt']; // verticale rate
635
+			$data['squawk'] = $line['squawk']; // squawk
636
+			$data['emergency'] = ''; // emergency
637
+			$data['datetime'] = date('Y-m-d H:i:s');
638
+				$data['format_source'] = 'aircraftlistjson';
639
+				$data['id_source'] = $id_source;
640
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
641
+			$SI->add($data);
642
+			unset($data);
643
+		}
643 644
 		}
644
-	    }
645
-	    }
646
-    	    //$last_exec['aircraftlistjson'] = time();
647
-    	    $last_exec[$id]['last'] = time();
648
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
649
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
650
-	    $buffer = $Common->getData($value['host']);
651
-	    $all_data = json_decode($buffer,true);
652
-	    if (isset($all_data['planes'])) {
645
+		}
646
+			//$last_exec['aircraftlistjson'] = time();
647
+			$last_exec[$id]['last'] = time();
648
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
649
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
650
+		$buffer = $Common->getData($value['host']);
651
+		$all_data = json_decode($buffer,true);
652
+		if (isset($all_data['planes'])) {
653 653
 		$reset = 0;
654 654
 		foreach ($all_data['planes'] as $key => $line) {
655
-		    $data = array();
656
-		    $data['hex'] = $key; // hex
657
-		    $data['ident'] = $line[3]; // ident
658
-		    $data['altitude'] = $line[6]; // altitude
659
-		    $data['speed'] = $line[8]; // speed
660
-		    $data['heading'] = $line[7]; // heading
661
-		    $data['latitude'] = $line[4]; // lat
662
-		    $data['longitude'] = $line[5]; // long
663
-		    //$data['verticalrate'] = $line[]; // verticale rate
664
-		    $data['squawk'] = $line[10]; // squawk
665
-		    $data['emergency'] = ''; // emergency
666
-		    $data['registration'] = $line[2];
667
-		    $data['aircraft_icao'] = $line[0];
668
-		    $deparr = explode('-',$line[1]);
669
-		    if (count($deparr) == 2) {
655
+			$data = array();
656
+			$data['hex'] = $key; // hex
657
+			$data['ident'] = $line[3]; // ident
658
+			$data['altitude'] = $line[6]; // altitude
659
+			$data['speed'] = $line[8]; // speed
660
+			$data['heading'] = $line[7]; // heading
661
+			$data['latitude'] = $line[4]; // lat
662
+			$data['longitude'] = $line[5]; // long
663
+			//$data['verticalrate'] = $line[]; // verticale rate
664
+			$data['squawk'] = $line[10]; // squawk
665
+			$data['emergency'] = ''; // emergency
666
+			$data['registration'] = $line[2];
667
+			$data['aircraft_icao'] = $line[0];
668
+			$deparr = explode('-',$line[1]);
669
+			if (count($deparr) == 2) {
670 670
 			$data['departure_airport_icao'] = $deparr[0];
671 671
 			$data['arrival_airport_icao'] = $deparr[1];
672
-		    }
673
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
674
-	    	    $data['format_source'] = 'planeupdatefaa';
675
-    		    $data['id_source'] = $id_source;
676
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
677
-		    $SI->add($data);
678
-		    unset($data);
672
+			}
673
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
674
+				$data['format_source'] = 'planeupdatefaa';
675
+				$data['id_source'] = $id_source;
676
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
677
+			$SI->add($data);
678
+			unset($data);
679 679
 		}
680
-	    }
681
-    	    //$last_exec['planeupdatefaa'] = time();
682
-    	    $last_exec[$id]['last'] = time();
683
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
684
-	    $buffer = $Common->getData($value['host']);
685
-	    $all_data = json_decode($buffer,true);
686
-	    if (isset($all_data['states'])) {
680
+		}
681
+			//$last_exec['planeupdatefaa'] = time();
682
+			$last_exec[$id]['last'] = time();
683
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
684
+		$buffer = $Common->getData($value['host']);
685
+		$all_data = json_decode($buffer,true);
686
+		if (isset($all_data['states'])) {
687 687
 		$reset = 0;
688 688
 		foreach ($all_data['states'] as $key => $line) {
689
-		    $data = array();
690
-		    $data['hex'] = $line[0]; // hex
691
-		    $data['ident'] = trim($line[1]); // ident
692
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
693
-		    $data['speed'] = round($line[9]*1.94384); // speed
694
-		    $data['heading'] = round($line[10]); // heading
695
-		    $data['latitude'] = $line[5]; // lat
696
-		    $data['longitude'] = $line[6]; // long
697
-		    $data['verticalrate'] = $line[11]; // verticale rate
698
-		    //$data['squawk'] = $line[10]; // squawk
699
-		    //$data['emergency'] = ''; // emergency
700
-		    //$data['registration'] = $line[2];
701
-		    //$data['aircraft_icao'] = $line[0];
702
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
703
-	    	    $data['format_source'] = 'opensky';
704
-    		    $data['id_source'] = $id_source;
705
-		    $SI->add($data);
706
-		    unset($data);
689
+			$data = array();
690
+			$data['hex'] = $line[0]; // hex
691
+			$data['ident'] = trim($line[1]); // ident
692
+			$data['altitude'] = round($line[7]*3.28084); // altitude
693
+			$data['speed'] = round($line[9]*1.94384); // speed
694
+			$data['heading'] = round($line[10]); // heading
695
+			$data['latitude'] = $line[5]; // lat
696
+			$data['longitude'] = $line[6]; // long
697
+			$data['verticalrate'] = $line[11]; // verticale rate
698
+			//$data['squawk'] = $line[10]; // squawk
699
+			//$data['emergency'] = ''; // emergency
700
+			//$data['registration'] = $line[2];
701
+			//$data['aircraft_icao'] = $line[0];
702
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
703
+				$data['format_source'] = 'opensky';
704
+				$data['id_source'] = $id_source;
705
+			$SI->add($data);
706
+			unset($data);
707
+		}
707 708
 		}
708
-	    }
709
-    	    //$last_exec['planeupdatefaa'] = time();
710
-    	    $last_exec[$id]['last'] = time();
711
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
712
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
713
-	    //$buffer = $Common->getData($hosts[$id]);
714
-	    $buffer = $Common->getData($value['host']);
715
-	    $all_data = json_decode($buffer,true);
716
-	    if (!empty($all_data)) $reset = 0;
717
-	    foreach ($all_data as $key => $line) {
709
+			//$last_exec['planeupdatefaa'] = time();
710
+			$last_exec[$id]['last'] = time();
711
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
712
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
713
+		//$buffer = $Common->getData($hosts[$id]);
714
+		$buffer = $Common->getData($value['host']);
715
+		$all_data = json_decode($buffer,true);
716
+		if (!empty($all_data)) $reset = 0;
717
+		foreach ($all_data as $key => $line) {
718 718
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
719
-		    $data = array();
720
-		    $data['hex'] = $line[0];
721
-		    $data['ident'] = $line[16]; //$line[13]
722
-	    	    $data['altitude'] = $line[4]; // altitude
723
-	    	    $data['speed'] = $line[5]; // speed
724
-	    	    $data['heading'] = $line[3]; // heading
725
-	    	    $data['latitude'] = $line[1]; // lat
726
-	    	    $data['longitude'] = $line[2]; // long
727
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
728
-	    	    $data['squawk'] = $line[6]; // squawk
729
-	    	    $data['aircraft_icao'] = $line[8];
730
-	    	    $data['registration'] = $line[9];
731
-		    $data['departure_airport_iata'] = $line[11];
732
-		    $data['arrival_airport_iata'] = $line[12];
733
-	    	    $data['emergency'] = ''; // emergency
734
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
735
-	    	    $data['format_source'] = 'fr24json';
736
-    		    $data['id_source'] = $id_source;
737
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
738
-		    $SI->add($data);
739
-		    unset($data);
719
+			$data = array();
720
+			$data['hex'] = $line[0];
721
+			$data['ident'] = $line[16]; //$line[13]
722
+				$data['altitude'] = $line[4]; // altitude
723
+				$data['speed'] = $line[5]; // speed
724
+				$data['heading'] = $line[3]; // heading
725
+				$data['latitude'] = $line[1]; // lat
726
+				$data['longitude'] = $line[2]; // long
727
+				$data['verticalrate'] = $line[15]; // verticale rate
728
+				$data['squawk'] = $line[6]; // squawk
729
+				$data['aircraft_icao'] = $line[8];
730
+				$data['registration'] = $line[9];
731
+			$data['departure_airport_iata'] = $line[11];
732
+			$data['arrival_airport_iata'] = $line[12];
733
+				$data['emergency'] = ''; // emergency
734
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
735
+				$data['format_source'] = 'fr24json';
736
+				$data['id_source'] = $id_source;
737
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
738
+			$SI->add($data);
739
+			unset($data);
740
+		}
740 741
 		}
741
-	    }
742
-    	    //$last_exec['fr24json'] = time();
743
-    	    $last_exec[$id]['last'] = time();
744
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
745
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
746
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
747
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
748
-	    //echo $buffer;
749
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
750
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
751
-	    $all_data = json_decode($buffer,true);
752
-	    if (json_last_error() != JSON_ERROR_NONE) {
742
+			//$last_exec['fr24json'] = time();
743
+			$last_exec[$id]['last'] = time();
744
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
745
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
746
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
747
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
748
+		//echo $buffer;
749
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
750
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
751
+		$all_data = json_decode($buffer,true);
752
+		if (json_last_error() != JSON_ERROR_NONE) {
753 753
 		die(json_last_error_msg());
754
-	    }
755
-	    if (isset($all_data['mrkrs'])) {
754
+		}
755
+		if (isset($all_data['mrkrs'])) {
756 756
 		$reset = 0;
757 757
 		foreach ($all_data['mrkrs'] as $key => $line) {
758
-		    if (isset($line['inf'])) {
758
+			if (isset($line['inf'])) {
759 759
 			$data = array();
760 760
 			$data['hex'] = $line['inf']['ia'];
761 761
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
762
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
763
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
764
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
765
-	    		$data['latitude'] = $line['pt'][0]; // lat
766
-	    		$data['longitude'] = $line['pt'][1]; // long
767
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
768
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
769
-	    		//$data['aircraft_icao'] = $line[8];
770
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
762
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
763
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
764
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
765
+				$data['latitude'] = $line['pt'][0]; // lat
766
+				$data['longitude'] = $line['pt'][1]; // long
767
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
768
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
769
+				//$data['aircraft_icao'] = $line[8];
770
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
771 771
 			//$data['departure_airport_iata'] = $line[11];
772 772
 			//$data['arrival_airport_iata'] = $line[12];
773
-	    		//$data['emergency'] = ''; // emergency
773
+				//$data['emergency'] = ''; // emergency
774 774
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
775
-	    		$data['format_source'] = 'radarvirtueljson';
776
-    			$data['id_source'] = $id_source;
775
+				$data['format_source'] = 'radarvirtueljson';
776
+				$data['id_source'] = $id_source;
777 777
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
778 778
 			$SI->add($data);
779 779
 			unset($data);
780
-		    }
780
+			}
781 781
 		}
782
-	    }
783
-    	    //$last_exec['radarvirtueljson'] = time();
784
-    	    $last_exec[$id]['last'] = time();
785
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
786
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
787
-	    //$buffer = $Common->getData($hosts[$id]);
788
-	    $buffer = $Common->getData($value['host'].'?'.time());
789
-	    $all_data = json_decode(utf8_encode($buffer),true);
782
+		}
783
+			//$last_exec['radarvirtueljson'] = time();
784
+			$last_exec[$id]['last'] = time();
785
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
786
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
787
+		//$buffer = $Common->getData($hosts[$id]);
788
+		$buffer = $Common->getData($value['host'].'?'.time());
789
+		$all_data = json_decode(utf8_encode($buffer),true);
790 790
 	    
791
-	    if (isset($all_data['pireps'])) {
791
+		if (isset($all_data['pireps'])) {
792 792
 		$reset = 0;
793
-	        foreach ($all_data['pireps'] as $line) {
794
-		    $data = array();
795
-		    $data['id'] = $line['id'];
796
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
797
-		    $data['ident'] = $line['callsign']; // ident
798
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
799
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
800
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
801
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
802
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
803
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
804
-		    $data['latitude'] = $line['lat']; // lat
805
-		    $data['longitude'] = $line['lon']; // long
806
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
807
-		    //$data['squawk'] = $line['squawk']; // squawk
808
-		    //$data['emergency'] = ''; // emergency
809
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
810
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
811
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
812
-		    //$data['arrival_airport_time'] = $line['arrtime'];
813
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
814
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
815
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
816
-		    else $data['info'] = '';
817
-		    $data['format_source'] = 'pireps';
818
-    		    $data['id_source'] = $id_source;
819
-		    $data['datetime'] = date('Y-m-d H:i:s');
820
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
821
-		    if ($line['icon'] == 'plane') {
793
+			foreach ($all_data['pireps'] as $line) {
794
+			$data = array();
795
+			$data['id'] = $line['id'];
796
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
797
+			$data['ident'] = $line['callsign']; // ident
798
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
799
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
800
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
801
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
802
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
803
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
804
+			$data['latitude'] = $line['lat']; // lat
805
+			$data['longitude'] = $line['lon']; // long
806
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
807
+			//$data['squawk'] = $line['squawk']; // squawk
808
+			//$data['emergency'] = ''; // emergency
809
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
810
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
811
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
812
+			//$data['arrival_airport_time'] = $line['arrtime'];
813
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
814
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
815
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
816
+			else $data['info'] = '';
817
+			$data['format_source'] = 'pireps';
818
+				$data['id_source'] = $id_source;
819
+			$data['datetime'] = date('Y-m-d H:i:s');
820
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
821
+			if ($line['icon'] == 'plane') {
822 822
 			$SI->add($data);
823
-		    //    print_r($data);
824
-    		    } elseif ($line['icon'] == 'ct') {
823
+			//    print_r($data);
824
+				} elseif ($line['icon'] == 'ct') {
825 825
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
826 826
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
827 827
 			$typec = substr($data['ident'],-3);
@@ -836,186 +836,186 @@  discard block
 block discarded – undo
836 836
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
837 837
 			else $data['type'] = 'Observer';
838 838
 			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']);
839
-		    }
840
-		    unset($data);
839
+			}
840
+			unset($data);
841 841
 		}
842
-	    }
843
-    	    //$last_exec['pirepsjson'] = time();
844
-    	    $last_exec[$id]['last'] = time();
845
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
846
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
847
-	    //$buffer = $Common->getData($hosts[$id]);
848
-	    if ($globalDebug) echo 'Get Data...'."\n";
849
-	    $buffer = $Common->getData($value['host']);
850
-	    $all_data = json_decode($buffer,true);
851
-	    if ($buffer != '' && is_array($all_data)) {
842
+		}
843
+			//$last_exec['pirepsjson'] = time();
844
+			$last_exec[$id]['last'] = time();
845
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
846
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
847
+		//$buffer = $Common->getData($hosts[$id]);
848
+		if ($globalDebug) echo 'Get Data...'."\n";
849
+		$buffer = $Common->getData($value['host']);
850
+		$all_data = json_decode($buffer,true);
851
+		if ($buffer != '' && is_array($all_data)) {
852 852
 		$reset = 0;
853 853
 		foreach ($all_data as $line) {
854
-	    	    $data = array();
855
-	    	    //$data['id'] = $line['id']; // id not usable
856
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
857
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
858
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
859
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
860
-	    	    $data['ident'] = $line['flightnum']; // ident
861
-	    	    $data['altitude'] = $line['alt']; // altitude
862
-	    	    $data['speed'] = $line['gs']; // speed
863
-	    	    $data['heading'] = $line['heading']; // heading
864
-	    	    $data['latitude'] = $line['lat']; // lat
865
-	    	    $data['longitude'] = $line['lng']; // long
866
-	    	    $data['verticalrate'] = ''; // verticale rate
867
-	    	    $data['squawk'] = ''; // squawk
868
-	    	    $data['emergency'] = ''; // emergency
869
-	    	    //$data['datetime'] = $line['lastupdate'];
870
-	    	    $data['last_update'] = $line['lastupdate'];
871
-		    $data['datetime'] = date('Y-m-d H:i:s');
872
-	    	    $data['departure_airport_icao'] = $line['depicao'];
873
-	    	    $data['departure_airport_time'] = $line['deptime'];
874
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
875
-    		    $data['arrival_airport_time'] = $line['arrtime'];
876
-    		    $data['registration'] = $line['aircraft'];
877
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
878
-		    if (isset($line['aircraftname'])) {
854
+				$data = array();
855
+				//$data['id'] = $line['id']; // id not usable
856
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
857
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
858
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
859
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
860
+				$data['ident'] = $line['flightnum']; // ident
861
+				$data['altitude'] = $line['alt']; // altitude
862
+				$data['speed'] = $line['gs']; // speed
863
+				$data['heading'] = $line['heading']; // heading
864
+				$data['latitude'] = $line['lat']; // lat
865
+				$data['longitude'] = $line['lng']; // long
866
+				$data['verticalrate'] = ''; // verticale rate
867
+				$data['squawk'] = ''; // squawk
868
+				$data['emergency'] = ''; // emergency
869
+				//$data['datetime'] = $line['lastupdate'];
870
+				$data['last_update'] = $line['lastupdate'];
871
+			$data['datetime'] = date('Y-m-d H:i:s');
872
+				$data['departure_airport_icao'] = $line['depicao'];
873
+				$data['departure_airport_time'] = $line['deptime'];
874
+				$data['arrival_airport_icao'] = $line['arricao'];
875
+				$data['arrival_airport_time'] = $line['arrtime'];
876
+				$data['registration'] = $line['aircraft'];
877
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
878
+			if (isset($line['aircraftname'])) {
879 879
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
880 880
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
881
-	    		$aircraft_data = explode('-',$line['aircraftname']);
882
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
883
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
884
-	    		else {
885
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
886
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
887
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
888
-	    		}
889
-	    	    }
890
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
891
-    		    $data['id_source'] = $id_source;
892
-	    	    $data['format_source'] = 'phpvmacars';
893
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
894
-		    $SI->add($data);
895
-		    unset($data);
881
+				$aircraft_data = explode('-',$line['aircraftname']);
882
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
883
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
884
+				else {
885
+					$aircraft_data = explode(' ',$line['aircraftname']);
886
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
887
+					else $data['aircraft_icao'] = $line['aircraftname'];
888
+				}
889
+				}
890
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
891
+				$data['id_source'] = $id_source;
892
+				$data['format_source'] = 'phpvmacars';
893
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
894
+			$SI->add($data);
895
+			unset($data);
896 896
 		}
897 897
 		if ($globalDebug) echo 'No more data...'."\n";
898 898
 		unset($buffer);
899 899
 		unset($all_data);
900
-	    }
901
-    	    //$last_exec['phpvmacars'] = time();
902
-    	    $last_exec[$id]['last'] = time();
903
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
904
-	    //$buffer = $Common->getData($hosts[$id]);
905
-	    if ($globalDebug) echo 'Get Data...'."\n";
906
-	    $buffer = $Common->getData($value['host']);
907
-	    $all_data = json_decode($buffer,true);
908
-	    if ($buffer != '' && is_array($all_data)) {
900
+		}
901
+			//$last_exec['phpvmacars'] = time();
902
+			$last_exec[$id]['last'] = time();
903
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
904
+		//$buffer = $Common->getData($hosts[$id]);
905
+		if ($globalDebug) echo 'Get Data...'."\n";
906
+		$buffer = $Common->getData($value['host']);
907
+		$all_data = json_decode($buffer,true);
908
+		if ($buffer != '' && is_array($all_data)) {
909 909
 		$reset = 0;
910 910
 		foreach ($all_data as $line) {
911
-	    	    $data = array();
912
-	    	    //$data['id'] = $line['id']; // id not usable
913
-	    	    $data['id'] = trim($line['flight_id']);
914
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
915
-	    	    $data['pilot_name'] = $line['pilot_name'];
916
-	    	    $data['pilot_id'] = $line['pilot_id'];
917
-	    	    $data['ident'] = trim($line['callsign']); // ident
918
-	    	    $data['altitude'] = $line['altitude']; // altitude
919
-	    	    $data['speed'] = $line['gs']; // speed
920
-	    	    $data['heading'] = $line['heading']; // heading
921
-	    	    $data['latitude'] = $line['latitude']; // lat
922
-	    	    $data['longitude'] = $line['longitude']; // long
923
-	    	    $data['verticalrate'] = ''; // verticale rate
924
-	    	    $data['squawk'] = ''; // squawk
925
-	    	    $data['emergency'] = ''; // emergency
926
-	    	    //$data['datetime'] = $line['lastupdate'];
927
-	    	    $data['last_update'] = $line['last_update'];
928
-		    $data['datetime'] = date('Y-m-d H:i:s');
929
-	    	    $data['departure_airport_icao'] = $line['departure'];
930
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
931
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
932
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
933
-    		    //$data['registration'] = $line['aircraft'];
934
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
935
-	    	    $data['aircraft_icao'] = $line['plane_type'];
936
-    		    $data['id_source'] = $id_source;
937
-	    	    $data['format_source'] = 'vam';
938
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
939
-		    $SI->add($data);
940
-		    unset($data);
911
+				$data = array();
912
+				//$data['id'] = $line['id']; // id not usable
913
+				$data['id'] = trim($line['flight_id']);
914
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
915
+				$data['pilot_name'] = $line['pilot_name'];
916
+				$data['pilot_id'] = $line['pilot_id'];
917
+				$data['ident'] = trim($line['callsign']); // ident
918
+				$data['altitude'] = $line['altitude']; // altitude
919
+				$data['speed'] = $line['gs']; // speed
920
+				$data['heading'] = $line['heading']; // heading
921
+				$data['latitude'] = $line['latitude']; // lat
922
+				$data['longitude'] = $line['longitude']; // long
923
+				$data['verticalrate'] = ''; // verticale rate
924
+				$data['squawk'] = ''; // squawk
925
+				$data['emergency'] = ''; // emergency
926
+				//$data['datetime'] = $line['lastupdate'];
927
+				$data['last_update'] = $line['last_update'];
928
+			$data['datetime'] = date('Y-m-d H:i:s');
929
+				$data['departure_airport_icao'] = $line['departure'];
930
+				//$data['departure_airport_time'] = $line['departure_time'];
931
+				$data['arrival_airport_icao'] = $line['arrival'];
932
+				//$data['arrival_airport_time'] = $line['arrival_time'];
933
+				//$data['registration'] = $line['aircraft'];
934
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
935
+				$data['aircraft_icao'] = $line['plane_type'];
936
+				$data['id_source'] = $id_source;
937
+				$data['format_source'] = 'vam';
938
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
939
+			$SI->add($data);
940
+			unset($data);
941 941
 		}
942 942
 		if ($globalDebug) echo 'No more data...'."\n";
943 943
 		unset($buffer);
944 944
 		unset($all_data);
945
-	    }
946
-    	    //$last_exec['phpvmacars'] = time();
947
-    	    $last_exec[$id]['last'] = time();
945
+		}
946
+			//$last_exec['phpvmacars'] = time();
947
+			$last_exec[$id]['last'] = time();
948 948
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
949 949
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais') {
950
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
951
-    	    //$last_exec[$id]['last'] = time();
950
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
951
+			//$last_exec[$id]['last'] = time();
952 952
 
953
-	    //$read = array( $sockets[$id] );
954
-	    $read = $sockets;
955
-	    $write = NULL;
956
-	    $e = NULL;
957
-	    $n = socket_select($read, $write, $e, $timeout);
958
-	    if ($e != NULL) var_dump($e);
959
-	    if ($n > 0) {
953
+		//$read = array( $sockets[$id] );
954
+		$read = $sockets;
955
+		$write = NULL;
956
+		$e = NULL;
957
+		$n = socket_select($read, $write, $e, $timeout);
958
+		if ($e != NULL) var_dump($e);
959
+		if ($n > 0) {
960 960
 		$reset = 0;
961 961
 		foreach ($read as $nb => $r) {
962
-		    //$value = $formats[$nb];
963
-		    $format = $globalSources[$nb]['format'];
964
-        	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
965
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
966
-        	    } else {
967
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
968
-	    	    }
969
-        	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
970
-        	    //echo $buffer."\n";
971
-		    // lets play nice and handle signals such as ctrl-c/kill properly
972
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
973
-		    $error = false;
974
-		    //$SI::del();
975
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
976
-		    // SBS format is CSV format
977
-		    if ($buffer != '') {
962
+			//$value = $formats[$nb];
963
+			$format = $globalSources[$nb]['format'];
964
+				if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
965
+				$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
966
+				} else {
967
+					$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
968
+				}
969
+				//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
970
+				//echo $buffer."\n";
971
+			// lets play nice and handle signals such as ctrl-c/kill properly
972
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
973
+			$error = false;
974
+			//$SI::del();
975
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
976
+			// SBS format is CSV format
977
+			if ($buffer != '') {
978 978
 			$tt[$format] = 0;
979 979
 			if ($format == 'acarssbs3') {
980
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
981
-			    $ACARS->add(trim($buffer));
982
-			    $ACARS->deleteLiveAcarsData();
980
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
981
+				$ACARS->add(trim($buffer));
982
+				$ACARS->deleteLiveAcarsData();
983 983
 			} elseif ($format == 'raw') {
984
-			    // AVR format
985
-			    $data = $SBS->parse($buffer);
986
-			    if (is_array($data)) {
984
+				// AVR format
985
+				$data = $SBS->parse($buffer);
986
+				if (is_array($data)) {
987 987
 				$data['datetime'] = date('Y-m-d H:i:s');
988 988
 				$data['format_source'] = 'raw';
989 989
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
990
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
991
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
992
-                            }
993
-                        } elseif ($format == 'ais') {
994
-			    $ais_data = $AIS->parse_line(trim($buffer));
995
-			    $data = array();
996
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
997
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
998
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
999
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1000
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1001
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1002
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1003
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1004
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1005
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
990
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
991
+								if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
992
+							}
993
+						} elseif ($format == 'ais') {
994
+				$ais_data = $AIS->parse_line(trim($buffer));
995
+				$data = array();
996
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
997
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
998
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
999
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1000
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1001
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1002
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1003
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1004
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1005
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1006 1006
 
1007
-			    if (isset($ais_data['timestamp'])) {
1007
+				if (isset($ais_data['timestamp'])) {
1008 1008
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1009
-			    } else {
1009
+				} else {
1010 1010
 				$data['datetime'] = date('Y-m-d H:i:s');
1011
-			    }
1012
-			    $data['format_source'] = 'nmeatxt';
1013
-    			    $data['id_source'] = $id_source;
1014
-			    $MI->add($data);
1015
-			    unset($data);
1016
-                        } elseif ($format == 'flightgearsp') {
1017
-                    	    //echo $buffer."\n";
1018
-                    	    if (strlen($buffer) > 5) {
1011
+				}
1012
+				$data['format_source'] = 'nmeatxt';
1013
+					$data['id_source'] = $id_source;
1014
+				$MI->add($data);
1015
+				unset($data);
1016
+						} elseif ($format == 'flightgearsp') {
1017
+							//echo $buffer."\n";
1018
+							if (strlen($buffer) > 5) {
1019 1019
 				$line = explode(',',$buffer);
1020 1020
 				$data = array();
1021 1021
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1031,120 +1031,120 @@  discard block
 block discarded – undo
1031 1031
 				$data['format_source'] = 'flightgearsp';
1032 1032
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1033 1033
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1034
-			    }
1035
-                        } elseif ($format == 'acars') {
1036
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1037
-			    $ACARS->add(trim($buffer));
1038
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1039
-			    $ACARS->deleteLiveAcarsData();
1034
+				}
1035
+						} elseif ($format == 'acars') {
1036
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1037
+				$ACARS->add(trim($buffer));
1038
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1039
+				$ACARS->deleteLiveAcarsData();
1040 1040
 			} elseif ($format == 'flightgearmp') {
1041
-			    if (substr($buffer,0,1) != '#') {
1041
+				if (substr($buffer,0,1) != '#') {
1042 1042
 				$data = array();
1043 1043
 				//echo $buffer."\n";
1044 1044
 				$line = explode(' ',$buffer);
1045 1045
 				if (count($line) == 11) {
1046
-				    $userserver = explode('@',$line[0]);
1047
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1048
-				    $data['ident'] = $userserver[0];
1049
-				    $data['registration'] = $userserver[0];
1050
-				    $data['latitude'] = $line[4];
1051
-				    $data['longitude'] = $line[5];
1052
-				    $data['altitude'] = $line[6];
1053
-				    $data['datetime'] = date('Y-m-d H:i:s');
1054
-				    $aircraft_type = $line[10];
1055
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1056
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1057
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1046
+					$userserver = explode('@',$line[0]);
1047
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1048
+					$data['ident'] = $userserver[0];
1049
+					$data['registration'] = $userserver[0];
1050
+					$data['latitude'] = $line[4];
1051
+					$data['longitude'] = $line[5];
1052
+					$data['altitude'] = $line[6];
1053
+					$data['datetime'] = date('Y-m-d H:i:s');
1054
+					$aircraft_type = $line[10];
1055
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1056
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1057
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1058
+				}
1058 1059
 				}
1059
-			    }
1060 1060
 			} elseif ($format == 'beast') {
1061
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1062
-			    die;
1061
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1062
+				die;
1063 1063
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1064
-			    $line = explode("\t", $buffer);
1065
-			    for($k = 0; $k < count($line); $k=$k+2) {
1064
+				$line = explode("\t", $buffer);
1065
+				for($k = 0; $k < count($line); $k=$k+2) {
1066 1066
 				$key = $line[$k];
1067
-			        $lined[$key] = $line[$k+1];
1068
-			    }
1069
-    			    if (count($lined) > 3) {
1070
-    				$data['hex'] = $lined['hexid'];
1071
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1072
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1073
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1074
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1075
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1076
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1077
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1078
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1079
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1080
-    				$data['id_source'] = $id_source;
1081
-    				$data['format_source'] = 'tsv';
1082
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1083
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1084
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1085
-    				unset($lined);
1086
-    				unset($data);
1087
-    			    } else $error = true;
1067
+					$lined[$key] = $line[$k+1];
1068
+				}
1069
+					if (count($lined) > 3) {
1070
+					$data['hex'] = $lined['hexid'];
1071
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1072
+					$data['datetime'] = date('Y-m-d H:i:s');;
1073
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1074
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1075
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1076
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1077
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1078
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1079
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1080
+					$data['id_source'] = $id_source;
1081
+					$data['format_source'] = 'tsv';
1082
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1083
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1084
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1085
+					unset($lined);
1086
+					unset($data);
1087
+					} else $error = true;
1088 1088
 			} elseif ($format == 'aprs' && $use_aprs) {
1089
-			    if ($aprs_connect == 0) {
1089
+				if ($aprs_connect == 0) {
1090 1090
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1091 1091
 				$aprs_connect = 1;
1092
-			    }
1092
+				}
1093 1093
 			    
1094
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1094
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1095 1095
 				$aprs_last_tx = time();
1096 1096
 				$data_aprs = "# Keep alive";
1097 1097
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1098
-			    }
1098
+				}
1099 1099
 			    
1100
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1101
-			    $buffer = str_replace('APRS <- ','',$buffer);
1102
-			    $buffer = str_replace('APRS -> ','',$buffer);
1103
-			    //echo $buffer."\n";
1104
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1100
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1101
+				$buffer = str_replace('APRS <- ','',$buffer);
1102
+				$buffer = str_replace('APRS -> ','',$buffer);
1103
+				//echo $buffer."\n";
1104
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1105 1105
 				$line = $APRS->parse($buffer);
1106 1106
 				//print_r($line);
1107 1107
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1108 1108
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && isset($line['ident'])) {
1109
-				    $aprs_last_tx = time();
1110
-				    $data = array();
1111
-				    //print_r($line);
1112
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1113
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1114
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1115
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1116
-				    $data['ident'] = $line['ident'];
1117
-				    $data['latitude'] = $line['latitude'];
1118
-				    $data['longitude'] = $line['longitude'];
1119
-				    //$data['verticalrate'] = $line[16];
1120
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1121
-				    else $data['speed'] = 0;
1122
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1123
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1124
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1125
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1126
-				    //else $data['heading'] = 0;
1127
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1128
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1129
-    				    $data['id_source'] = $id_source;
1130
-				    $data['format_source'] = 'aprs';
1131
-				    $data['source_name'] = $line['source'];
1132
-				    $data['source_type'] = 'flarm';
1133
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1134
-				    $currentdate = date('Y-m-d H:i:s');
1135
-				    $aprsdate = strtotime($data['datetime']);
1136
-				    // Accept data if time <= system time + 20s
1137
-				    if (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'])))) {
1109
+					$aprs_last_tx = time();
1110
+					$data = array();
1111
+					//print_r($line);
1112
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1113
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1114
+					else $data['datetime'] = date('Y-m-d H:i:s');
1115
+					//$data['datetime'] = date('Y-m-d H:i:s');
1116
+					$data['ident'] = $line['ident'];
1117
+					$data['latitude'] = $line['latitude'];
1118
+					$data['longitude'] = $line['longitude'];
1119
+					//$data['verticalrate'] = $line[16];
1120
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1121
+					else $data['speed'] = 0;
1122
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1123
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1124
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1125
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
1126
+					//else $data['heading'] = 0;
1127
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1128
+					if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1129
+						$data['id_source'] = $id_source;
1130
+					$data['format_source'] = 'aprs';
1131
+					$data['source_name'] = $line['source'];
1132
+					$data['source_type'] = 'flarm';
1133
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1134
+					$currentdate = date('Y-m-d H:i:s');
1135
+					$aprsdate = strtotime($data['datetime']);
1136
+					// Accept data if time <= system time + 20s
1137
+					if (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'])))) {
1138 1138
 					$send = $SI->add($data);
1139
-				    } elseif (isset($line['stealth'])) {
1139
+					} elseif (isset($line['stealth'])) {
1140 1140
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1141 1141
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1142
-				    //} 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')) {
1143
-				    } 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') {
1142
+					//} 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')) {
1143
+					} 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') {
1144 1144
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1145 1145
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1146
-				    }
1147
-				    unset($data);
1146
+					}
1147
+					unset($data);
1148 1148
 				} 
1149 1149
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1150 1150
 					echo '!! Weather Station not yet supported'."\n";
@@ -1154,12 +1154,12 @@  discard block
 block discarded – undo
1154 1154
 				}
1155 1155
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1156 1156
 				//elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1157
-			    }
1157
+				}
1158 1158
 			} else {
1159
-			    $line = explode(',', $buffer);
1160
-    			    if (count($line) > 20) {
1161
-    			    	$data['hex'] = $line[4];
1162
-    				/*
1159
+				$line = explode(',', $buffer);
1160
+					if (count($line) > 20) {
1161
+						$data['hex'] = $line[4];
1162
+					/*
1163 1163
     				$data['datetime'] = $line[6].' '.$line[7];
1164 1164
     					date_default_timezone_set($globalTimezone);
1165 1165
     					$datetime = new DateTime($data['datetime']);
@@ -1167,29 +1167,29 @@  discard block
 block discarded – undo
1167 1167
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1168 1168
     					date_default_timezone_set('UTC');
1169 1169
     				*/
1170
-    				// Force datetime to current UTC datetime
1171
-    				date_default_timezone_set('UTC');
1172
-    				$data['datetime'] = date('Y-m-d H:i:s');
1173
-    				$data['ident'] = trim($line[10]);
1174
-    				$data['latitude'] = $line[14];
1175
-    				$data['longitude'] = $line[15];
1176
-    				$data['verticalrate'] = $line[16];
1177
-    				$data['emergency'] = $line[20];
1178
-    				$data['speed'] = $line[12];
1179
-    				$data['squawk'] = $line[17];
1180
-    				$data['altitude'] = $line[11];
1181
-    				$data['heading'] = $line[13];
1182
-    				$data['ground'] = $line[21];
1183
-    				$data['emergency'] = $line[19];
1184
-    				$data['format_source'] = 'sbs';
1170
+					// Force datetime to current UTC datetime
1171
+					date_default_timezone_set('UTC');
1172
+					$data['datetime'] = date('Y-m-d H:i:s');
1173
+					$data['ident'] = trim($line[10]);
1174
+					$data['latitude'] = $line[14];
1175
+					$data['longitude'] = $line[15];
1176
+					$data['verticalrate'] = $line[16];
1177
+					$data['emergency'] = $line[20];
1178
+					$data['speed'] = $line[12];
1179
+					$data['squawk'] = $line[17];
1180
+					$data['altitude'] = $line[11];
1181
+					$data['heading'] = $line[13];
1182
+					$data['ground'] = $line[21];
1183
+					$data['emergency'] = $line[19];
1184
+					$data['format_source'] = 'sbs';
1185 1185
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1186
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1187
-    				$data['id_source'] = $id_source;
1188
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1189
-    				else $error = true;
1190
-    				unset($data);
1191
-    			    } else $error = true;
1192
-			    if ($error) {
1186
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1187
+					$data['id_source'] = $id_source;
1188
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1189
+					else $error = true;
1190
+					unset($data);
1191
+					} else $error = true;
1192
+				if ($error) {
1193 1193
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1194 1194
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1195 1195
 				} else {
@@ -1205,13 +1205,13 @@  discard block
 block discarded – undo
1205 1205
 					connect_all($sourceer);
1206 1206
 					$sourceer = array();
1207 1207
 				}
1208
-			    }
1208
+				}
1209 1209
 			}
1210 1210
 			// Sleep for xxx microseconds
1211 1211
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1212
-		    } else {
1212
+			} else {
1213 1213
 			if ($format == 'flightgearmp') {
1214
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1214
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1215 1215
 				//@socket_close($r);
1216 1216
 				sleep($globalMinFetch);
1217 1217
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1220,9 +1220,9 @@  discard block
 block discarded – undo
1220 1220
 				break;
1221 1221
 				
1222 1222
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1223
-			    if (isset($tt[$format])) $tt[$format]++;
1224
-			    else $tt[$format] = 0;
1225
-			    if ($tt[$format] > 30) {
1223
+				if (isset($tt[$format])) $tt[$format]++;
1224
+				else $tt[$format] = 0;
1225
+				if ($tt[$format] > 30) {
1226 1226
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1227 1227
 				//@socket_close($r);
1228 1228
 				sleep(2);
@@ -1233,23 +1233,23 @@  discard block
 block discarded – undo
1233 1233
 				//connect_all($globalSources);
1234 1234
 				$tt[$format]=0;
1235 1235
 				break;
1236
-			    }
1236
+				}
1237
+			}
1237 1238
 			}
1238
-		    }
1239 1239
 		}
1240
-	    } else {
1240
+		} else {
1241 1241
 		$error = socket_strerror(socket_last_error());
1242 1242
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1243 1243
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1244 1244
 			if (isset($globalDebug)) echo "Restarting...\n";
1245 1245
 			// Restart the script if possible
1246 1246
 			if (is_array($sockets)) {
1247
-			    if ($globalDebug) echo "Shutdown all sockets...";
1247
+				if ($globalDebug) echo "Shutdown all sockets...";
1248 1248
 			    
1249
-			    foreach ($sockets as $sock) {
1249
+				foreach ($sockets as $sock) {
1250 1250
 				@socket_shutdown($sock,2);
1251 1251
 				@socket_close($sock);
1252
-			    }
1252
+				}
1253 1253
 			    
1254 1254
 			}
1255 1255
 			if ($globalDebug) echo "Restart all connections...";
@@ -1260,13 +1260,13 @@  discard block
 block discarded – undo
1260 1260
 			if ($reset > 40) exit('Too many attempts...');
1261 1261
 			connect_all($globalSources);
1262 1262
 		}
1263
-	    }
1263
+		}
1264 1264
 	}
1265 1265
 	if ($globalDaemon === false) {
1266
-	    if ($globalDebug) echo 'Check all...'."\n";
1267
-	    $SI->checkAll();
1266
+		if ($globalDebug) echo 'Check all...'."\n";
1267
+		$SI->checkAll();
1268
+	}
1268 1269
 	}
1269
-    }
1270 1270
 }
1271 1271
 
1272 1272
 ?>
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Indentation   +197 added lines, -197 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 	}
14 14
 
15 15
 	/**
16
-	* Get SQL query part for filter used
17
-	* @param Array $filter the filter
18
-	* @return Array the SQL part
19
-	*/
16
+	 * Get SQL query part for filter used
17
+	 * @param Array $filter the filter
18
+	 * @return Array the SQL part
19
+	 */
20 20
 	
21 21
 	public function getFilter($filter = array(),$where = false,$and = false) {
22 22
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
 	}
81 81
 
82 82
 	/**
83
-	* Executes the SQL statements to get the spotter information
84
-	*
85
-	* @param String $query the SQL query
86
-	* @param Array $params parameter of the query
87
-	* @param String $limitQuery the limit query
88
-	* @return Array the spotter information
89
-	*
90
-	*/
83
+	 * Executes the SQL statements to get the spotter information
84
+	 *
85
+	 * @param String $query the SQL query
86
+	 * @param Array $params parameter of the query
87
+	 * @param String $limitQuery the limit query
88
+	 * @return Array the spotter information
89
+	 *
90
+	 */
91 91
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
92 92
 	{
93 93
 		date_default_timezone_set('UTC');
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	
200 200
 	
201 201
 	/**
202
-	* Gets all the spotter information based on the latest data entry
203
-	*
204
-	* @return Array the spotter information
205
-	*
206
-	*/
202
+	 * Gets all the spotter information based on the latest data entry
203
+	 *
204
+	 * @return Array the spotter information
205
+	 *
206
+	 */
207 207
 	public function getLatestMarineData($limit = '', $sort = '', $filter = array())
208 208
 	{
209 209
 		global $global_query;
@@ -261,11 +261,11 @@  discard block
 block discarded – undo
261 261
 	}
262 262
 
263 263
 	/**
264
-	* Gets all the spotter information based on the callsign
265
-	*
266
-	* @return Array the spotter information
267
-	*
268
-	*/
264
+	 * Gets all the spotter information based on the callsign
265
+	 *
266
+	 * @return Array the spotter information
267
+	 *
268
+	 */
269 269
 	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
270 270
 	{
271 271
 		global $global_query;
@@ -376,12 +376,12 @@  discard block
 block discarded – undo
376 376
 
377 377
 
378 378
 	/**
379
-	* Gets all source name
380
-	*
381
-	* @param String type format of source
382
-	* @return Array list of source name
383
-	*
384
-	*/
379
+	 * Gets all source name
380
+	 *
381
+	 * @param String type format of source
382
+	 * @return Array list of source name
383
+	 *
384
+	 */
385 385
 	public function getAllSourceName($type = '',$filters = array())
386 386
 	{
387 387
 		$filter_query = $this->getFilter($filters,true,true);
@@ -411,11 +411,11 @@  discard block
 block discarded – undo
411 411
 
412 412
 
413 413
 	/**
414
-	* Gets a list of all idents/callsigns
415
-	*
416
-	* @return Array list of ident/callsign names
417
-	*
418
-	*/
414
+	 * Gets a list of all idents/callsigns
415
+	 *
416
+	 * @return Array list of ident/callsign names
417
+	 *
418
+	 */
419 419
 	public function getAllIdents($filters = array())
420 420
 	{
421 421
 		$filter_query = $this->getFilter($filters,true,true);
@@ -439,11 +439,11 @@  discard block
 block discarded – undo
439 439
 	}
440 440
 
441 441
 	/**
442
-	* Gets all info from a mmsi
443
-	*
444
-	* @return Array list of mmsi info
445
-	*
446
-	*/
442
+	 * Gets all info from a mmsi
443
+	 *
444
+	 * @return Array list of mmsi info
445
+	 *
446
+	 */
447 447
 	public function getIdentity($mmsi)
448 448
 	{
449 449
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -500,18 +500,18 @@  discard block
 block discarded – undo
500 500
 	
501 501
 	
502 502
 	/**
503
-	* Update ident tracker data
504
-	*
505
-	* @param String $fammarine_id the ID
506
-	* @param String $ident the marine ident
507
-	* @return String success or false
508
-	*
509
-	*/	
503
+	 * Update ident tracker data
504
+	 *
505
+	 * @param String $fammarine_id the ID
506
+	 * @param String $ident the marine ident
507
+	 * @return String success or false
508
+	 *
509
+	 */	
510 510
 	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
511 511
 	{
512 512
 
513 513
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
514
-                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
514
+				$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
515 515
 
516 516
 		try {
517 517
 			$sth = $this->db->prepare($query);
@@ -524,17 +524,17 @@  discard block
 block discarded – undo
524 524
 
525 525
 	}
526 526
 	/**
527
-	* Update latest marine data
528
-	*
529
-	* @param String $fammarine_id the ID
530
-	* @param String $ident the marine ident
531
-	* @return String success or false
532
-	*
533
-	*/	
527
+	 * Update latest marine data
528
+	 *
529
+	 * @param String $fammarine_id the ID
530
+	 * @param String $ident the marine ident
531
+	 * @return String success or false
532
+	 *
533
+	 */	
534 534
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
535 535
 	{
536 536
 		$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id';
537
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
537
+				$query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
538 538
 
539 539
 		try {
540 540
 			$sth = $this->db->prepare($query);
@@ -548,30 +548,30 @@  discard block
 block discarded – undo
548 548
 	}
549 549
 
550 550
 	/**
551
-	* Adds a new spotter data
552
-	*
553
-	* @param String $fammarine_id the ID
554
-	* @param String $ident the marine ident
555
-	* @param String $departure_airport_icao the departure airport
556
-	* @param String $arrival_airport_icao the arrival airport
557
-	* @param String $latitude latitude of flight
558
-	* @param String $longitude latitude of flight
559
-	* @param String $waypoints waypoints of flight
560
-	* @param String $heading heading of flight
561
-	* @param String $groundspeed speed of flight
562
-	* @param String $date date of flight
563
-	* @param String $departure_airport_time departure time of flight
564
-	* @param String $arrival_airport_time arrival time of flight
565
-	* @param String $squawk squawk code of flight
566
-	* @param String $route_stop route stop of flight
567
-	* @param String $highlight highlight or not
568
-	* @param String $ModeS ModesS code of flight
569
-	* @param String $registration registration code of flight
570
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
571
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
572
-	* @param String $verticalrate vertival rate of flight
573
-	* @return String success or false
574
-	*/
551
+	 * Adds a new spotter data
552
+	 *
553
+	 * @param String $fammarine_id the ID
554
+	 * @param String $ident the marine ident
555
+	 * @param String $departure_airport_icao the departure airport
556
+	 * @param String $arrival_airport_icao the arrival airport
557
+	 * @param String $latitude latitude of flight
558
+	 * @param String $longitude latitude of flight
559
+	 * @param String $waypoints waypoints of flight
560
+	 * @param String $heading heading of flight
561
+	 * @param String $groundspeed speed of flight
562
+	 * @param String $date date of flight
563
+	 * @param String $departure_airport_time departure time of flight
564
+	 * @param String $arrival_airport_time arrival time of flight
565
+	 * @param String $squawk squawk code of flight
566
+	 * @param String $route_stop route stop of flight
567
+	 * @param String $highlight highlight or not
568
+	 * @param String $ModeS ModesS code of flight
569
+	 * @param String $registration registration code of flight
570
+	 * @param String $pilot_id pilot id of flight (for virtual airlines)
571
+	 * @param String $pilot_name pilot name of flight (for virtual airlines)
572
+	 * @param String $verticalrate vertival rate of flight
573
+	 * @return String success or false
574
+	 */
575 575
 	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$imo = '',$callsign = '',$status = '',$format_source = '', $source_name = '')
576 576
 	{
577 577
 		global $globalURL;
@@ -657,16 +657,16 @@  discard block
 block discarded – undo
657 657
 		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
658 658
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
659 659
 	
660
-                if ($latitude == '' && $longitude == '') {
661
-            		$latitude = 0;
662
-            		$longitude = 0;
663
-            	}
664
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
665
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
666
-                $query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo) 
660
+				if ($latitude == '' && $longitude == '') {
661
+					$latitude = 0;
662
+					$longitude = 0;
663
+				}
664
+				if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
665
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
666
+				$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo) 
667 667
                 VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo)";
668 668
 
669
-                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo);
669
+				$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo);
670 670
 
671 671
 		try {
672 672
 		        
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 			$sth->execute($query_values);
675 675
 			$this->db = null;
676 676
 		} catch (PDOException $e) {
677
-		    return "error : ".$e->getMessage();
677
+			return "error : ".$e->getMessage();
678 678
 		}
679 679
 		
680 680
 		return "success";
@@ -683,11 +683,11 @@  discard block
 block discarded – undo
683 683
 	
684 684
   
685 685
 	/**
686
-	* Gets the aircraft ident within the last hour
687
-	*
688
-	* @return String the ident
689
-	*
690
-	*/
686
+	 * Gets the aircraft ident within the last hour
687
+	 *
688
+	 * @return String the ident
689
+	 *
690
+	 */
691 691
 	public function getIdentFromLastHour($ident)
692 692
 	{
693 693
 		global $globalDBdriver, $globalTimezone;
@@ -703,11 +703,11 @@  discard block
 block discarded – undo
703 703
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
704 704
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
705 705
 			$query_data = array(':ident' => $ident);
706
-    		}
706
+			}
707 707
 		
708 708
 		$sth = $this->db->prepare($query);
709 709
 		$sth->execute($query_data);
710
-    		$ident_result='';
710
+			$ident_result='';
711 711
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
712 712
 		{
713 713
 			$ident_result = $row['ident'];
@@ -718,11 +718,11 @@  discard block
 block discarded – undo
718 718
 	
719 719
 	
720 720
 	/**
721
-	* Gets the aircraft data from the last 20 seconds
722
-	*
723
-	* @return Array the spotter data
724
-	*
725
-	*/
721
+	 * Gets the aircraft data from the last 20 seconds
722
+	 *
723
+	 * @return Array the spotter data
724
+	 *
725
+	 */
726 726
 	public function getRealTimeData($q = '')
727 727
 	{
728 728
 		global $globalDBdriver;
@@ -760,11 +760,11 @@  discard block
 block discarded – undo
760 760
 	
761 761
 
762 762
 	/**
763
-	* Gets all number of flight over countries
764
-	*
765
-	* @return Array the airline country list
766
-	*
767
-	*/
763
+	 * Gets all number of flight over countries
764
+	 *
765
+	 * @return Array the airline country list
766
+	 *
767
+	 */
768 768
 /*
769 769
 	public function countAllTrackedOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
770 770
 	{
@@ -815,11 +815,11 @@  discard block
 block discarded – undo
815 815
 	
816 816
 	
817 817
 	/**
818
-	* Gets all callsigns that have flown over
819
-	*
820
-	* @return Array the callsign list
821
-	*
822
-	*/
818
+	 * Gets all callsigns that have flown over
819
+	 *
820
+	 * @return Array the callsign list
821
+	 *
822
+	 */
823 823
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
824 824
 	{
825 825
 		global $globalDBdriver;
@@ -886,11 +886,11 @@  discard block
 block discarded – undo
886 886
 
887 887
 
888 888
 	/**
889
-	* Counts all dates
890
-	*
891
-	* @return Array the date list
892
-	*
893
-	*/
889
+	 * Counts all dates
890
+	 *
891
+	 * @return Array the date list
892
+	 *
893
+	 */
894 894
 	public function countAllDates($filters = array())
895 895
 	{
896 896
 		global $globalTimezone, $globalDBdriver;
@@ -936,11 +936,11 @@  discard block
 block discarded – undo
936 936
 	
937 937
 	
938 938
 	/**
939
-	* Counts all dates during the last 7 days
940
-	*
941
-	* @return Array the date list
942
-	*
943
-	*/
939
+	 * Counts all dates during the last 7 days
940
+	 *
941
+	 * @return Array the date list
942
+	 *
943
+	 */
944 944
 	public function countAllDatesLast7Days($filters = array())
945 945
 	{
946 946
 		global $globalTimezone, $globalDBdriver;
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
 			$query .= " GROUP BY date_name 
963 963
 								ORDER BY date_name ASC";
964 964
 			$query_data = array(':offset' => $offset);
965
-    		}
965
+			}
966 966
 		
967 967
 		$sth = $this->db->prepare($query);
968 968
 		$sth->execute($query_data);
@@ -982,11 +982,11 @@  discard block
 block discarded – undo
982 982
 	}
983 983
 
984 984
 	/**
985
-	* Counts all dates during the last month
986
-	*
987
-	* @return Array the date list
988
-	*
989
-	*/
985
+	 * Counts all dates during the last month
986
+	 *
987
+	 * @return Array the date list
988
+	 *
989
+	 */
990 990
 	public function countAllDatesLastMonth($filters = array())
991 991
 	{
992 992
 		global $globalTimezone, $globalDBdriver;
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
 			$query .= " GROUP BY date_name 
1009 1009
 								ORDER BY date_name ASC";
1010 1010
 			$query_data = array(':offset' => $offset);
1011
-    		}
1011
+			}
1012 1012
 		
1013 1013
 		$sth = $this->db->prepare($query);
1014 1014
 		$sth->execute($query_data);
@@ -1030,11 +1030,11 @@  discard block
 block discarded – undo
1030 1030
 
1031 1031
 
1032 1032
 	/**
1033
-	* Counts all month
1034
-	*
1035
-	* @return Array the month list
1036
-	*
1037
-	*/
1033
+	 * Counts all month
1034
+	 *
1035
+	 * @return Array the month list
1036
+	 *
1037
+	 */
1038 1038
 	public function countAllMonths($filters = array())
1039 1039
 	{
1040 1040
 		global $globalTimezone, $globalDBdriver;
@@ -1079,11 +1079,11 @@  discard block
 block discarded – undo
1079 1079
 	
1080 1080
 
1081 1081
 	/**
1082
-	* Counts all dates during the last year
1083
-	*
1084
-	* @return Array the date list
1085
-	*
1086
-	*/
1082
+	 * Counts all dates during the last year
1083
+	 *
1084
+	 * @return Array the date list
1085
+	 *
1086
+	 */
1087 1087
 	public function countAllMonthsLastYear($filters)
1088 1088
 	{
1089 1089
 		global $globalTimezone, $globalDBdriver;
@@ -1105,7 +1105,7 @@  discard block
 block discarded – undo
1105 1105
 			$query .= " GROUP BY year_name, month_name
1106 1106
 								ORDER BY year_name, month_name ASC";
1107 1107
 			$query_data = array(':offset' => $offset);
1108
-    		}
1108
+			}
1109 1109
 		
1110 1110
 		$sth = $this->db->prepare($query);
1111 1111
 		$sth->execute($query_data);
@@ -1128,11 +1128,11 @@  discard block
 block discarded – undo
1128 1128
 	
1129 1129
 	
1130 1130
 	/**
1131
-	* Counts all hours
1132
-	*
1133
-	* @return Array the hour list
1134
-	*
1135
-	*/
1131
+	 * Counts all hours
1132
+	 *
1133
+	 * @return Array the hour list
1134
+	 *
1135
+	 */
1136 1136
 	public function countAllHours($orderby,$filters = array())
1137 1137
 	{
1138 1138
 		global $globalTimezone, $globalDBdriver;
@@ -1195,11 +1195,11 @@  discard block
 block discarded – undo
1195 1195
 	
1196 1196
 	
1197 1197
 	/**
1198
-	* Counts all hours by date
1199
-	*
1200
-	* @return Array the hour list
1201
-	*
1202
-	*/
1198
+	 * Counts all hours by date
1199
+	 *
1200
+	 * @return Array the hour list
1201
+	 *
1202
+	 */
1203 1203
 	public function countAllHoursByDate($date, $filters = array())
1204 1204
 	{
1205 1205
 		global $globalTimezone, $globalDBdriver;
@@ -1243,11 +1243,11 @@  discard block
 block discarded – undo
1243 1243
 	
1244 1244
 	
1245 1245
 	/**
1246
-	* Counts all hours by a ident/callsign
1247
-	*
1248
-	* @return Array the hour list
1249
-	*
1250
-	*/
1246
+	 * Counts all hours by a ident/callsign
1247
+	 *
1248
+	 * @return Array the hour list
1249
+	 *
1250
+	 */
1251 1251
 	public function countAllHoursByIdent($ident, $filters = array())
1252 1252
 	{
1253 1253
 		global $globalTimezone, $globalDBdriver;
@@ -1292,11 +1292,11 @@  discard block
 block discarded – undo
1292 1292
 	
1293 1293
 	
1294 1294
 	/**
1295
-	* Counts all flights that have flown over
1296
-	*
1297
-	* @return Integer the number of flights
1298
-	*
1299
-	*/
1295
+	 * Counts all flights that have flown over
1296
+	 *
1297
+	 * @return Integer the number of flights
1298
+	 *
1299
+	 */
1300 1300
 	public function countOverallTracked($filters = array(),$year = '',$month = '')
1301 1301
 	{
1302 1302
 		global $globalDBdriver;
@@ -1331,11 +1331,11 @@  discard block
 block discarded – undo
1331 1331
 	
1332 1332
   
1333 1333
 	/**
1334
-	* Counts all hours of today
1335
-	*
1336
-	* @return Array the hour list
1337
-	*
1338
-	*/
1334
+	 * Counts all hours of today
1335
+	 *
1336
+	 * @return Array the hour list
1337
+	 *
1338
+	 */
1339 1339
 	public function countAllHoursFromToday($filters = array())
1340 1340
 	{
1341 1341
 		global $globalTimezone, $globalDBdriver;
@@ -1375,12 +1375,12 @@  discard block
 block discarded – undo
1375 1375
 	}
1376 1376
     
1377 1377
     
1378
-     /**
1379
-	* Gets the Barrie Spotter ID based on the FlightAware ID
1380
-	*
1381
-	* @return Integer the Barrie Spotter ID
1378
+	 /**
1379
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
1380
+	  *
1381
+	  * @return Integer the Barrie Spotter ID
1382 1382
 q	*
1383
-	*/
1383
+	  */
1384 1384
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1385 1385
 	{
1386 1386
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -1401,13 +1401,13 @@  discard block
 block discarded – undo
1401 1401
   
1402 1402
  
1403 1403
 	/**
1404
-	* Parses a date string
1405
-	*
1406
-	* @param String $dateString the date string
1407
-	* @param String $timezone the timezone of a user
1408
-	* @return Array the time information
1409
-	*
1410
-	*/
1404
+	 * Parses a date string
1405
+	 *
1406
+	 * @param String $dateString the date string
1407
+	 * @param String $timezone the timezone of a user
1408
+	 * @return Array the time information
1409
+	 *
1410
+	 */
1411 1411
 	public function parseDateString($dateString, $timezone = '')
1412 1412
 	{
1413 1413
 		$time_array = array();
@@ -1440,12 +1440,12 @@  discard block
 block discarded – undo
1440 1440
 	}
1441 1441
 	
1442 1442
 	/**
1443
-	* Parses the direction degrees to working
1444
-	*
1445
-	* @param Float $direction the direction in degrees
1446
-	* @return Array the direction information
1447
-	*
1448
-	*/
1443
+	 * Parses the direction degrees to working
1444
+	 *
1445
+	 * @param Float $direction the direction in degrees
1446
+	 * @return Array the direction information
1447
+	 *
1448
+	 */
1449 1449
 	public function parseDirection($direction = 0)
1450 1450
 	{
1451 1451
 		if ($direction == '') $direction = 0;
@@ -1524,12 +1524,12 @@  discard block
 block discarded – undo
1524 1524
 	
1525 1525
 	
1526 1526
 	/**
1527
-	* Gets Country from latitude/longitude
1528
-	*
1529
-	* @param Float $latitude latitute of the flight
1530
-	* @param Float $longitude longitute of the flight
1531
-	* @return String the countrie
1532
-	*/
1527
+	 * Gets Country from latitude/longitude
1528
+	 *
1529
+	 * @param Float $latitude latitute of the flight
1530
+	 * @param Float $longitude longitute of the flight
1531
+	 * @return String the countrie
1532
+	 */
1533 1533
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1534 1534
 	{
1535 1535
 		global $globalDBdriver, $globalDebug;
@@ -1566,11 +1566,11 @@  discard block
 block discarded – undo
1566 1566
 	}
1567 1567
 
1568 1568
 	/**
1569
-	* Gets Country from iso2
1570
-	*
1571
-	* @param String $iso2 ISO2 country code
1572
-	* @return String the countrie
1573
-	*/
1569
+	 * Gets Country from iso2
1570
+	 *
1571
+	 * @param String $iso2 ISO2 country code
1572
+	 * @return String the countrie
1573
+	 */
1574 1574
 	public function getCountryFromISO2($iso2)
1575 1575
 	{
1576 1576
 		global $globalDBdriver, $globalDebug;
@@ -1599,12 +1599,12 @@  discard block
 block discarded – undo
1599 1599
 
1600 1600
 	
1601 1601
 	/**
1602
-	* Gets the short url from bit.ly
1603
-	*
1604
-	* @param String $url the full url
1605
-	* @return String the bit.ly url
1606
-	*
1607
-	*/
1602
+	 * Gets the short url from bit.ly
1603
+	 *
1604
+	 * @param String $url the full url
1605
+	 * @return String the bit.ly url
1606
+	 *
1607
+	 */
1608 1608
 	public function getBitlyURL($url)
1609 1609
 	{
1610 1610
 		global $globalBitlyAccessToken;
Please login to merge, or discard this patch.
require/class.MarineLive.php 1 patch
Indentation   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 
13 13
 
14 14
 	/**
15
-	* Get SQL query part for filter used
16
-	* @param Array $filter the filter
17
-	* @return Array the SQL part
18
-	*/
15
+	 * Get SQL query part for filter used
16
+	 * @param Array $filter the filter
17
+	 * @return Array the SQL part
18
+	 */
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
 	}
87 87
 
88 88
 	/**
89
-	* Gets all the spotter information based on the latest data entry
90
-	*
91
-	* @return Array the spotter information
92
-	*
93
-	*/
89
+	 * Gets all the spotter information based on the latest data entry
90
+	 *
91
+	 * @return Array the spotter information
92
+	 *
93
+	 */
94 94
 	public function getLiveMarineData($limit = '', $sort = '', $filter = array())
95 95
 	{
96 96
 		global $globalDBdriver, $globalLiveInterval;
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 	}
133 133
 
134 134
 	/**
135
-	* Gets Minimal Live Spotter data
136
-	*
137
-	* @return Array the spotter information
138
-	*
139
-	*/
135
+	 * Gets Minimal Live Spotter data
136
+	 *
137
+	 * @return Array the spotter information
138
+	 *
139
+	 */
140 140
 	public function getMinLiveMarineData($filter = array())
141 141
 	{
142 142
 		global $globalDBdriver, $globalLiveInterval;
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
 	}
167 167
 
168 168
 	/**
169
-	* Gets Minimal Live Spotter data since xx seconds
170
-	*
171
-	* @return Array the spotter information
172
-	*
173
-	*/
169
+	 * Gets Minimal Live Spotter data since xx seconds
170
+	 *
171
+	 * @return Array the spotter information
172
+	 *
173
+	 */
174 174
 	public function getMinLastLiveMarineData($filter = array())
175 175
 	{
176 176
 		global $globalDBdriver, $globalLiveInterval;
@@ -183,13 +183,13 @@  discard block
 block discarded – undo
183 183
 			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
184 184
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
185 185
 			ORDER BY marine_live.fammarine_id, marine_live.date";
186
-                } else {
186
+				} else {
187 187
 			$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
188 188
 			FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
189 189
 			ORDER BY marine_live.fammarine_id, marine_live.date";
190 190
 		}
191 191
 
192
-    		try {
192
+			try {
193 193
 			$sth = $this->db->prepare($query);
194 194
 			$sth->execute();
195 195
 		} catch(PDOException $e) {
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
 	}
202 202
 
203 203
 	/**
204
-	* Gets number of latest data entry
205
-	*
206
-	* @return String number of entry
207
-	*
208
-	*/
204
+	 * Gets number of latest data entry
205
+	 *
206
+	 * @return String number of entry
207
+	 *
208
+	 */
209 209
 	public function getLiveMarineCount($filter = array())
210 210
 	{
211 211
 		global $globalDBdriver, $globalLiveInterval;
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
 	}
231 231
 
232 232
 	/**
233
-	* Gets all the spotter information based on the latest data entry and coord
234
-	*
235
-	* @return Array the spotter information
236
-	*
237
-	*/
233
+	 * Gets all the spotter information based on the latest data entry and coord
234
+	 *
235
+	 * @return Array the spotter information
236
+	 *
237
+	 */
238 238
 	public function getLiveMarineDatabyCoord($coord, $filter = array())
239 239
 	{
240 240
 		global $globalDBdriver, $globalLiveInterval;
@@ -258,11 +258,11 @@  discard block
 block discarded – undo
258 258
 	}
259 259
 
260 260
 	/**
261
-	* Gets all the spotter information based on a user's latitude and longitude
262
-	*
263
-	* @return Array the spotter information
264
-	*
265
-	*/
261
+	 * Gets all the spotter information based on a user's latitude and longitude
262
+	 *
263
+	 * @return Array the spotter information
264
+	 *
265
+	 */
266 266
 	public function getLatestMarineForLayar($lat, $lng, $radius, $interval)
267 267
 	{
268 268
 		$Marine = new Marine($this->db);
@@ -275,134 +275,134 @@  discard block
 block discarded – undo
275 275
 		if ($lng != '')
276 276
 		{
277 277
 			if (!is_numeric($lng))
278
-                        {
279
-                                return false;
280
-                        }
281
-                }
282
-
283
-                if ($radius != '')
284
-                {
285
-                        if (!is_numeric($radius))
286
-                        {
287
-                                return false;
288
-                        }
289
-                }
278
+						{
279
+								return false;
280
+						}
281
+				}
282
+
283
+				if ($radius != '')
284
+				{
285
+						if (!is_numeric($radius))
286
+						{
287
+								return false;
288
+						}
289
+				}
290 290
 		$additional_query = '';
291 291
 		if ($interval != '')
292
-                {
293
-                        if (!is_string($interval))
294
-                        {
295
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
296
-			        return false;
297
-                        } else {
298
-                if ($interval == '1m')
299
-                {
300
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
301
-                } else if ($interval == '15m'){
302
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
303
-                } 
304
-            }
305
-                } else {
306
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
307
-        }
308
-
309
-                $query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
292
+				{
293
+						if (!is_string($interval))
294
+						{
295
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
296
+					return false;
297
+						} else {
298
+				if ($interval == '1m')
299
+				{
300
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
301
+				} else if ($interval == '15m'){
302
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
303
+				} 
304
+			}
305
+				} else {
306
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
307
+		}
308
+
309
+				$query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
310 310
                    WHERE marine_live.latitude <> '' 
311 311
                                    AND marine_live.longitude <> '' 
312 312
                    ".$additional_query."
313 313
                    HAVING distance < :radius  
314 314
                                    ORDER BY distance";
315 315
 
316
-                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
316
+				$spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
317 317
 
318
-                return $spotter_array;
319
-        }
318
+				return $spotter_array;
319
+		}
320 320
 
321 321
     
322
-        /**
323
-	* Gets all the spotter information based on a particular callsign
324
-	*
325
-	* @return Array the spotter information
326
-	*
327
-	*/
322
+		/**
323
+		 * Gets all the spotter information based on a particular callsign
324
+		 *
325
+		 * @return Array the spotter information
326
+		 *
327
+		 */
328 328
 	public function getLastLiveMarineDataByIdent($ident)
329 329
 	{
330 330
 		$Marine = new Marine($this->db);
331 331
 		date_default_timezone_set('UTC');
332 332
 
333 333
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
334
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
334
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
335 335
 
336 336
 		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
337 337
 
338 338
 		return $spotter_array;
339 339
 	}
340 340
 
341
-        /**
342
-	* Gets all the spotter information based on a particular callsign
343
-	*
344
-	* @return Array the spotter information
345
-	*
346
-	*/
341
+		/**
342
+		 * Gets all the spotter information based on a particular callsign
343
+		 *
344
+		 * @return Array the spotter information
345
+		 *
346
+		 */
347 347
 	public function getDateLiveMarineDataByIdent($ident,$date)
348 348
 	{
349 349
 		$Marine = new Marine($this->db);
350 350
 		date_default_timezone_set('UTC');
351 351
 
352 352
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
353
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
353
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
354 354
 
355
-                $date = date('c',$date);
355
+				$date = date('c',$date);
356 356
 		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
357 357
 
358 358
 		return $spotter_array;
359 359
 	}
360 360
 
361
-        /**
362
-	* Gets last spotter information based on a particular callsign
363
-	*
364
-	* @return Array the spotter information
365
-	*
366
-	*/
361
+		/**
362
+		 * Gets last spotter information based on a particular callsign
363
+		 *
364
+		 * @return Array the spotter information
365
+		 *
366
+		 */
367 367
 	public function getLastLiveMarineDataById($id)
368 368
 	{
369 369
 		$Marine = new Marine($this->db);
370 370
 		date_default_timezone_set('UTC');
371 371
 
372 372
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
373
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
373
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
374 374
 
375 375
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
376 376
 
377 377
 		return $spotter_array;
378 378
 	}
379 379
 
380
-        /**
381
-	* Gets last spotter information based on a particular callsign
382
-	*
383
-	* @return Array the spotter information
384
-	*
385
-	*/
380
+		/**
381
+		 * Gets last spotter information based on a particular callsign
382
+		 *
383
+		 * @return Array the spotter information
384
+		 *
385
+		 */
386 386
 	public function getDateLiveMarineDataById($id,$date)
387 387
 	{
388 388
 		$Marine = new Marine($this->db);
389 389
 		date_default_timezone_set('UTC');
390 390
 
391 391
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
392
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
393
-                $date = date('c',$date);
392
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
393
+				$date = date('c',$date);
394 394
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
395 395
 
396 396
 		return $spotter_array;
397 397
 	}
398 398
 
399 399
 
400
-        /**
401
-	* Gets all the spotter information based on a particular id
402
-	*
403
-	* @return Array the spotter information
404
-	*
405
-	*/
400
+		/**
401
+		 * Gets all the spotter information based on a particular id
402
+		 *
403
+		 * @return Array the spotter information
404
+		 *
405
+		 */
406 406
 	public function getAllLiveMarineDataById($id,$liveinterval = false)
407 407
 	{
408 408
 		global $globalDBdriver, $globalLiveInterval;
@@ -430,18 +430,18 @@  discard block
 block discarded – undo
430 430
 		return $spotter_array;
431 431
 	}
432 432
 
433
-        /**
434
-	* Gets all the spotter information based on a particular ident
435
-	*
436
-	* @return Array the spotter information
437
-	*
438
-	*/
433
+		/**
434
+		 * Gets all the spotter information based on a particular ident
435
+		 *
436
+		 * @return Array the spotter information
437
+		 *
438
+		 */
439 439
 	public function getAllLiveMarineDataByIdent($ident)
440 440
 	{
441 441
 		date_default_timezone_set('UTC');
442 442
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
443 443
 		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
444
-    		try {
444
+			try {
445 445
 			
446 446
 			$sth = $this->db->prepare($query);
447 447
 			$sth->execute(array(':ident' => $ident));
@@ -455,23 +455,23 @@  discard block
 block discarded – undo
455 455
 
456 456
 
457 457
 	/**
458
-	* Deletes all info in the table
459
-	*
460
-	* @return String success or false
461
-	*
462
-	*/
458
+	 * Deletes all info in the table
459
+	 *
460
+	 * @return String success or false
461
+	 *
462
+	 */
463 463
 	public function deleteLiveMarineData()
464 464
 	{
465 465
 		global $globalDBdriver;
466 466
 		if ($globalDBdriver == 'mysql') {
467 467
 			//$query  = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date";
468 468
 			$query  = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date';
469
-            		//$query  = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";
469
+					//$query  = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";
470 470
 		} else {
471 471
 			$query  = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date";
472 472
 		}
473 473
         
474
-    		try {
474
+			try {
475 475
 			
476 476
 			$sth = $this->db->prepare($query);
477 477
 			$sth->execute();
@@ -483,18 +483,18 @@  discard block
 block discarded – undo
483 483
 	}
484 484
 
485 485
 	/**
486
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
487
-	*
488
-	* @return String success or false
489
-	*
490
-	*/
486
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
487
+	 *
488
+	 * @return String success or false
489
+	 *
490
+	 */
491 491
 	public function deleteLiveMarineDataNotUpdated()
492 492
 	{
493 493
 		global $globalDBdriver, $globalDebug;
494 494
 		if ($globalDBdriver == 'mysql') {
495 495
 			//$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0';
496
-    			$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
497
-    			try {
496
+				$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
497
+				try {
498 498
 				
499 499
 				$sth = $this->db->prepare($query);
500 500
 				$sth->execute();
@@ -502,8 +502,8 @@  discard block
 block discarded – undo
502 502
 				return "error";
503 503
 			}
504 504
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
505
-                        $i = 0;
506
-                        $j =0;
505
+						$i = 0;
506
+						$j =0;
507 507
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
508 508
 			foreach($all as $row)
509 509
 			{
@@ -511,20 +511,20 @@  discard block
 block discarded – undo
511 511
 				$j++;
512 512
 				if ($j == 30) {
513 513
 					if ($globalDebug) echo ".";
514
-				    	try {
514
+						try {
515 515
 						
516 516
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
517 517
 						$sth->execute();
518 518
 					} catch(PDOException $e) {
519 519
 						return "error";
520 520
 					}
521
-                                	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
522
-                                	$j = 0;
521
+									$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
522
+									$j = 0;
523 523
 				}
524 524
 				$query_delete .= "'".$row['fammarine_id']."',";
525 525
 			}
526 526
 			if ($i > 0) {
527
-    				try {
527
+					try {
528 528
 					
529 529
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
530 530
 					$sth->execute();
@@ -535,9 +535,9 @@  discard block
 block discarded – undo
535 535
 			return "success";
536 536
 		} elseif ($globalDBdriver == 'pgsql') {
537 537
 			//$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0";
538
-    			//$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
539
-    			$query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
540
-    			try {
538
+				//$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
539
+				$query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
540
+				try {
541 541
 				
542 542
 				$sth = $this->db->prepare($query);
543 543
 				$sth->execute();
@@ -581,17 +581,17 @@  discard block
 block discarded – undo
581 581
 	}
582 582
 
583 583
 	/**
584
-	* Deletes all info in the table for an ident
585
-	*
586
-	* @return String success or false
587
-	*
588
-	*/
584
+	 * Deletes all info in the table for an ident
585
+	 *
586
+	 * @return String success or false
587
+	 *
588
+	 */
589 589
 	public function deleteLiveMarineDataByIdent($ident)
590 590
 	{
591 591
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
592 592
 		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
593 593
         
594
-    		try {
594
+			try {
595 595
 			
596 596
 			$sth = $this->db->prepare($query);
597 597
 			$sth->execute(array(':ident' => $ident));
@@ -603,17 +603,17 @@  discard block
 block discarded – undo
603 603
 	}
604 604
 
605 605
 	/**
606
-	* Deletes all info in the table for an id
607
-	*
608
-	* @return String success or false
609
-	*
610
-	*/
606
+	 * Deletes all info in the table for an id
607
+	 *
608
+	 * @return String success or false
609
+	 *
610
+	 */
611 611
 	public function deleteLiveMarineDataById($id)
612 612
 	{
613 613
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
614 614
 		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
615 615
         
616
-    		try {
616
+			try {
617 617
 			
618 618
 			$sth = $this->db->prepare($query);
619 619
 			$sth->execute(array(':id' => $id));
@@ -626,11 +626,11 @@  discard block
 block discarded – undo
626 626
 
627 627
 
628 628
 	/**
629
-	* Gets the aircraft ident within the last hour
630
-	*
631
-	* @return String the ident
632
-	*
633
-	*/
629
+	 * Gets the aircraft ident within the last hour
630
+	 *
631
+	 * @return String the ident
632
+	 *
633
+	 */
634 634
 	public function getIdentFromLastHour($ident)
635 635
 	{
636 636
 		global $globalDBdriver, $globalTimezone;
@@ -656,14 +656,14 @@  discard block
 block discarded – undo
656 656
 			$ident_result = $row['ident'];
657 657
 		}
658 658
 		return $ident_result;
659
-        }
659
+		}
660 660
 
661 661
 	/**
662
-	* Check recent aircraft
663
-	*
664
-	* @return String the ident
665
-	*
666
-	*/
662
+	 * Check recent aircraft
663
+	 *
664
+	 * @return String the ident
665
+	 *
666
+	 */
667 667
 	public function checkIdentRecent($ident)
668 668
 	{
669 669
 		global $globalDBdriver, $globalTimezone;
@@ -689,14 +689,14 @@  discard block
 block discarded – undo
689 689
 			$ident_result = $row['fammarine_id'];
690 690
 		}
691 691
 		return $ident_result;
692
-        }
692
+		}
693 693
 
694 694
 	/**
695
-	* Check recent aircraft by id
696
-	*
697
-	* @return String the ident
698
-	*
699
-	*/
695
+	 * Check recent aircraft by id
696
+	 *
697
+	 * @return String the ident
698
+	 *
699
+	 */
700 700
 	public function checkIdRecent($id)
701 701
 	{
702 702
 		global $globalDBdriver, $globalTimezone;
@@ -722,14 +722,14 @@  discard block
 block discarded – undo
722 722
 			$ident_result = $row['fammarine_id'];
723 723
 		}
724 724
 		return $ident_result;
725
-        }
725
+		}
726 726
 
727 727
 	/**
728
-	* Check recent aircraft by mmsi
729
-	*
730
-	* @return String the ident
731
-	*
732
-	*/
728
+	 * Check recent aircraft by mmsi
729
+	 *
730
+	 * @return String the ident
731
+	 *
732
+	 */
733 733
 	public function checkMMSIRecent($mmsi)
734 734
 	{
735 735
 		global $globalDBdriver, $globalTimezone;
@@ -755,19 +755,19 @@  discard block
 block discarded – undo
755 755
 			$ident_result = $row['fammarine_id'];
756 756
 		}
757 757
 		return $ident_result;
758
-        }
758
+		}
759 759
 
760 760
 	/**
761
-	* Adds a new spotter data
762
-	*
763
-	* @param String $fammarine_id the ID from flightaware
764
-	* @param String $ident the flight ident
765
-	* @param String $aircraft_icao the aircraft type
766
-	* @param String $departure_airport_icao the departure airport
767
-	* @param String $arrival_airport_icao the arrival airport
768
-	* @return String success or false
769
-	*
770
-	*/
761
+	 * Adds a new spotter data
762
+	 *
763
+	 * @param String $fammarine_id the ID from flightaware
764
+	 * @param String $ident the flight ident
765
+	 * @param String $aircraft_icao the aircraft type
766
+	 * @param String $departure_airport_icao the departure airport
767
+	 * @param String $arrival_airport_icao the arrival airport
768
+	 * @return String success or false
769
+	 *
770
+	 */
771 771
 	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$imo = '', $callsign = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
772 772
 	{
773 773
 		global $globalURL, $globalArchive, $globalDebug;
@@ -835,8 +835,8 @@  discard block
 block discarded – undo
835 835
 		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
836 836
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
837 837
 
838
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
839
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
838
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
839
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
840 840
             	
841 841
 		$query  = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo) 
842 842
 		VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo)';
@@ -846,9 +846,9 @@  discard block
 block discarded – undo
846 846
 			
847 847
 			$sth = $this->db->prepare($query);
848 848
 			$sth->execute($query_values);
849
-                } catch(PDOException $e) {
850
-                	return "error : ".$e->getMessage();
851
-                }
849
+				} catch(PDOException $e) {
850
+					return "error : ".$e->getMessage();
851
+				}
852 852
 		/*
853 853
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
854 854
 		    if ($globalDebug) echo '(Add to SBS archive : ';
Please login to merge, or discard this patch.
require/class.MarineImport.php 1 patch
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Source.php');
10 10
 
11 11
 class MarineImport {
12
-    private $all_tracked = array();
13
-    private $last_delete_hourly = 0;
14
-    private $last_delete = 0;
15
-    private $stats = array();
16
-    private $tmd = 0;
17
-    private $source_location = array();
18
-    public $db = null;
19
-    public $nb = 0;
12
+	private $all_tracked = array();
13
+	private $last_delete_hourly = 0;
14
+	private $last_delete = 0;
15
+	private $stats = array();
16
+	private $tmd = 0;
17
+	private $source_location = array();
18
+	public $db = null;
19
+	public $nb = 0;
20 20
 
21
-    public function __construct($dbc = null) {
21
+	public function __construct($dbc = null) {
22 22
 	global $globalBeta;
23 23
 	$Connection = new Connection($dbc);
24 24
 	$this->db = $Connection->db();
@@ -40,50 +40,50 @@  discard block
 block discarded – undo
40 40
 	    }
41 41
 	}
42 42
 	*/
43
-    }
43
+	}
44 44
 
45
-    public function checkAll() {
45
+	public function checkAll() {
46 46
 	global $globalDebug;
47 47
 	if ($globalDebug) echo "Update last seen tracked data...\n";
48 48
 	foreach ($this->all_tracked as $key => $flight) {
49
-	    if (isset($this->all_tracked[$key]['id'])) {
49
+		if (isset($this->all_tracked[$key]['id'])) {
50 50
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
51
-    		$Marine = new Marine($this->db);
52
-        	$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
53
-            }
51
+			$Marine = new Marine($this->db);
52
+			$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
53
+			}
54
+	}
54 55
 	}
55
-    }
56 56
 
57
-    public function del() {
57
+	public function del() {
58 58
 	global $globalDebug;
59 59
 	// Delete old infos
60 60
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
61 61
 	foreach ($this->all_tracked as $key => $flight) {
62
-    	    if (isset($flight['lastupdate'])) {
63
-        	if ($flight['lastupdate'] < (time()-3000)) {
64
-            	    if (isset($this->all_tracked[$key]['id'])) {
65
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
62
+			if (isset($flight['lastupdate'])) {
63
+			if ($flight['lastupdate'] < (time()-3000)) {
64
+					if (isset($this->all_tracked[$key]['id'])) {
65
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
66 66
 			/*
67 67
 			$MarineLive = new MarineLive();
68 68
             		$MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
69 69
 			$MarineLive->db = null;
70 70
 			*/
71
-            		//$real_arrival = $this->arrival($key);
72
-            		$Marine = new Marine($this->db);
73
-            		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
71
+					//$real_arrival = $this->arrival($key);
72
+					$Marine = new Marine($this->db);
73
+					if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
74 74
 				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed']);
75 75
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
76 76
 			}
77 77
 			// Put in archive
78 78
 //			$Marine->db = null;
79
-            	    }
80
-            	    unset($this->all_tracked[$key]);
81
-    	        }
82
-	    }
83
-        }
84
-    }
79
+					}
80
+					unset($this->all_tracked[$key]);
81
+				}
82
+		}
83
+		}
84
+	}
85 85
 
86
-    public function add($line) {
86
+	public function add($line) {
87 87
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
88 88
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
89 89
 	date_default_timezone_set('UTC');
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 	
93 93
 	// SBS format is CSV format
94 94
 	if(is_array($line) && isset($line['mmsi'])) {
95
-	    //print_r($line);
96
-  	    if (isset($line['mmsi'])) {
95
+		//print_r($line);
96
+  		if (isset($line['mmsi'])) {
97 97
 
98 98
 		/*
99 99
 		// Increment message number
@@ -109,78 +109,78 @@  discard block
 block discarded – undo
109 109
 		*/
110 110
 		
111 111
 		$Common = new Common();
112
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
113
-	        else $id = trim($line['id']);
112
+			if (!isset($line['id'])) $id = trim($line['mmsi']);
113
+			else $id = trim($line['id']);
114 114
 		
115 115
 		if (!isset($this->all_tracked[$id])) {
116
-		    $this->all_tracked[$id] = array();
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => ''));
119
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
120
-		    if (!isset($line['id'])) {
116
+			$this->all_tracked[$id] = array();
117
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
118
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => ''));
119
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
120
+			if (!isset($line['id'])) {
121 121
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
122 122
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
123
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
124
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
123
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
124
+			if ($globalAllTracked !== FALSE) $dataFound = true;
125 125
 		}
126 126
 		
127 127
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
128
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
129
-		    $Marine = new Marine($this->db);
130
-		    $identity = $Marine->getIdentity($line['mmsi']);
131
-		    if (!empty($identity)) {
128
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
129
+			$Marine = new Marine($this->db);
130
+			$identity = $Marine->getIdentity($line['mmsi']);
131
+			if (!empty($identity)) {
132 132
 			$this->all_tracked[$id]['ident'] = $identity['ship_name'];
133 133
 			$this->all_tracked[$id]['type'] = $identity['type'];
134
-		    }
135
-		    //print_r($identity);
136
-		    unset($Marine);
137
-		    //$dataFound = true;
134
+			}
135
+			//print_r($identity);
136
+			unset($Marine);
137
+			//$dataFound = true;
138 138
 		}
139 139
 		if (isset($line['type']) && $line['type'] != '') {
140
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
140
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
141 141
 		}
142 142
 		if (isset($line['imo']) && $line['imo'] != '') {
143
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
143
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
144 144
 		}
145 145
 		if (isset($line['callsign']) && $line['callsign'] != '') {
146
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
146
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
147 147
 		}
148 148
 
149 149
 
150 150
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
151 151
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
152
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
153
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
152
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
153
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
154 154
 			$timeelapsed = microtime(true);
155
-            		$Marine = new Marine($this->db);
156
-            		$fromsource = NULL;
157
-            		$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
155
+					$Marine = new Marine($this->db);
156
+					$fromsource = NULL;
157
+					$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
158 158
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
159 159
 			$Marine->db = null;
160 160
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
161
-		    }
162
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161
+			}
162
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
163 163
 		}
164 164
 
165 165
 		if (isset($line['speed']) && $line['speed'] != '') {
166
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
167
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
166
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
167
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
168 168
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
169
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
170
-		    if ($distance > 1000 && $distance < 10000) {
169
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
170
+			if ($distance > 1000 && $distance < 10000) {
171 171
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
172 172
 			$speed = $speed*3.6;
173 173
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
174 174
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
175
-		    }
175
+			}
176 176
 		}
177 177
 
178
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
179
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
180
-	    	    else unset($timediff);
181
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
178
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
179
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
180
+				else unset($timediff);
181
+				if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
182 182
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
183
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
183
+				if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
184 184
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
185 185
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
186 186
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -194,76 +194,76 @@  discard block
 block discarded – undo
194 194
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
195 195
 				$this->tmd = 0;
196 196
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
197
-			    }
197
+				}
198 198
 			}
199 199
 
200 200
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
201 201
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
202 202
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
203
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
204
-				    $dataFound = true;
205
-				    $this->all_tracked[$id]['time_last_coord'] = time();
203
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
204
+					$dataFound = true;
205
+					$this->all_tracked[$id]['time_last_coord'] = time();
206 206
 				}
207 207
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
208 208
 			}
209 209
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
210
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
210
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
211 211
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
212 212
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
213
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
214
-				    $dataFound = true;
215
-				    $this->all_tracked[$id]['time_last_coord'] = time();
213
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
214
+					$dataFound = true;
215
+					$this->all_tracked[$id]['time_last_coord'] = time();
216 216
 				}
217 217
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
218 218
 			}
219 219
 
220
-		    } else if ($globalDebug && $timediff > 20) {
220
+			} else if ($globalDebug && $timediff > 20) {
221 221
 			$this->tmd = $this->tmd + 1;
222 222
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
223 223
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
224 224
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
225 225
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
226
-		    }
226
+			}
227 227
 		}
228 228
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
229
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
231 231
 		}
232 232
 		if (isset($line['format_source']) && $line['format_source'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
233
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
234 234
 		}
235 235
 		if (isset($line['source_name']) && $line['source_name'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
236
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
237 237
 		}
238 238
 		if (isset($line['status']) && $line['status'] != '') {
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
239
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
240 240
 		}
241 241
 
242 242
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
243
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
243
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
244 244
 		}
245 245
 		
246 246
 		if (isset($line['heading']) && $line['heading'] != '') {
247
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
248
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
249
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
250
-		    //$dataFound = true;
247
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
248
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
249
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
250
+			//$dataFound = true;
251 251
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
252
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
253
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
254
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
255
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
252
+  			$heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
253
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
254
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
255
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
256 256
   		}
257 257
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
258 258
 
259 259
 		if (isset($line['datetime'])) {
260
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
260
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
261 261
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
262
-		    } else {
262
+			} else {
263 263
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
264 264
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
265 265
 				return '';
266
-		    }
266
+			}
267 267
 		} else {
268 268
 			date_default_timezone_set('UTC');
269 269
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -271,45 +271,45 @@  discard block
 block discarded – undo
271 271
 
272 272
 
273 273
 		if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) {
274
-		    $this->all_tracked[$id]['lastupdate'] = time();
275
-		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
276
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
274
+			$this->all_tracked[$id]['lastupdate'] = time();
275
+			if ($this->all_tracked[$id]['addedMarine'] == 0) {
276
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278 278
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
279 279
 				$timeelapsed = microtime(true);
280 280
 				$MarineLive = new MarineLive($this->db);
281 281
 				if (isset($line['id'])) {
282
-				    $recent_ident = $MarineLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
282
+					$recent_ident = $MarineLive->checkIdRecent($line['id']);
283
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
284 284
 				} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
285
-				    $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
285
+					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
286
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287 287
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
288
-				    $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
289
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
288
+					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
289
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
290 290
 				} else $recent_ident = '';
291 291
 				$MarineLive->db=null;
292 292
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
293 293
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
294
-			    } else {
294
+				} else {
295 295
 				$recent_ident = '';
296 296
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
297
-			    }
298
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
299
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
300
-			    {
297
+				}
298
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
299
+				if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
300
+				{
301 301
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
302 302
 				//adds the spotter data for the archive
303
-				    $highlight = '';
304
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
305
-				    $timeelapsed = microtime(true);
306
-				    $Marine = new Marine($this->db);
307
-				    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
308
-				    $Marine->db = null;
309
-				    if ($globalDebug && isset($result)) echo $result."\n";
310
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
303
+					$highlight = '';
304
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
305
+					$timeelapsed = microtime(true);
306
+					$Marine = new Marine($this->db);
307
+					$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
308
+					$Marine->db = null;
309
+					if ($globalDebug && isset($result)) echo $result."\n";
310
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
311 311
 				    
312
-				    /*
312
+					/*
313 313
 				    // Add source stat in DB
314 314
 				    $Stats = new Stats($this->db);
315 315
 				    if (!empty($this->stats)) {
@@ -336,20 +336,20 @@  discard block
 block discarded – undo
336 336
 				    }
337 337
 				    $Stats->db = null;
338 338
 				    */
339
-				    $this->del();
339
+					$this->del();
340 340
 				//$ignoreImport = false;
341 341
 				$this->all_tracked[$id]['addedMarine'] = 1;
342 342
 				//print_r($this->all_tracked[$id]);
343 343
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
344
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
345
-				    //MarineLive->deleteLiveMarineDataNotUpdated();
346
-				    $MarineLive = new MarineLive($this->db);
347
-				    $MarineLive->deleteLiveMarineData();
348
-				    $MarineLive->db=null;
349
-				    if ($globalDebug) echo " Done\n";
350
-				    $this->last_delete = time();
344
+					if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
345
+					//MarineLive->deleteLiveMarineDataNotUpdated();
346
+					$MarineLive = new MarineLive($this->db);
347
+					$MarineLive->deleteLiveMarineData();
348
+					$MarineLive->db=null;
349
+					if ($globalDebug) echo " Done\n";
350
+					$this->last_delete = time();
351 351
 				}
352
-			    } elseif ($recent_ident != '') {
352
+				} elseif ($recent_ident != '') {
353 353
 				$this->all_tracked[$id]['id'] = $recent_ident;
354 354
 				$this->all_tracked[$id]['addedMarine'] = 1;
355 355
 				if (isset($globalDaemon) && !$globalDaemon) {
@@ -358,16 +358,16 @@  discard block
 block discarded – undo
358 358
 					$Marine->db = null;
359 359
 				}
360 360
 				
361
-			    }
361
+				}
362
+			}
362 363
 			}
363
-		    }
364
-		    //adds the spotter LIVE data
365
-		    if ($globalDebug) {
364
+			//adds the spotter LIVE data
365
+			if ($globalDebug) {
366 366
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
367
-		    }
368
-		    $ignoreImport = false;
367
+			}
368
+			$ignoreImport = false;
369 369
 
370
-		    if (!$ignoreImport) {
370
+			if (!$ignoreImport) {
371 371
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
372 372
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
373 373
 				$timeelapsed = microtime(true);
@@ -439,22 +439,22 @@  discard block
 block discarded – undo
439 439
 			
440 440
 			
441 441
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
442
-			    if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
443
-			    $MarineLive = new MarineLive($this->db);
444
-			    $MarineLive->deleteLiveMarineDataNotUpdated();
445
-			    $MarineLive->db = null;
446
-			    //MarineLive->deleteLiveMarineData();
447
-			    if ($globalDebug) echo " Done\n";
448
-			    $this->last_delete_hourly = time();
442
+				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
443
+				$MarineLive = new MarineLive($this->db);
444
+				$MarineLive->deleteLiveMarineDataNotUpdated();
445
+				$MarineLive->db = null;
446
+				//MarineLive->deleteLiveMarineData();
447
+				if ($globalDebug) echo " Done\n";
448
+				$this->last_delete_hourly = time();
449 449
 			}
450 450
 			
451
-		    }
452
-		    //$ignoreImport = false;
451
+			}
452
+			//$ignoreImport = false;
453 453
 		}
454 454
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
455 455
 		if ($send) return $this->all_tracked[$id];
456
-	    }
456
+		}
457
+	}
457 458
 	}
458
-    }
459 459
 }
460 460
 ?>
Please login to merge, or discard this patch.