Completed
Push — master ( 41b901...22364b )
by Yannick
06:33
created
scripts/daemon-spotter.php 1 patch
Indentation   +836 added lines, -836 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,190 +340,190 @@  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 && $ais_data['mmsi_type'] == 'Ship') $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 && $ais_data['mmsi_type'] == 'Ship') $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['destination'])) $data['arrival_code'] = $ais_data['destination'];
465
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
466
-			    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['destination'])) $data['arrival_code'] = $ais_data['destination'];
465
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
466
+				if (isset($ais_data['timestamp'])) {
467 467
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
468
-			    } else {
468
+				} else {
469 469
 				$data['datetime'] = date('Y-m-d H:i:s');
470
-			    }
471
-			    $data['format_source'] = 'aisnmeahttp';
472
-			    $data['id_source'] = $id_source;
473
-			    if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data);
474
-			    unset($data);
470
+				}
471
+				$data['format_source'] = 'aisnmeahttp';
472
+				$data['id_source'] = $id_source;
473
+				if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data);
474
+				unset($data);
475 475
 			}
476
-		    }
476
+			}
477
+		}
477 478
 		}
478 479
 		}
479
-	    }
480 480
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
481
-	    echo 'download...';
482
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
483
-	    echo 'done !'."\n";
484
-	    if ($buffer != '') $reset = 0;
485
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
486
-	    $buffer = explode('\n',$buffer);
487
-	    foreach ($buffer as $line) {
481
+		echo 'download...';
482
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
483
+		echo 'done !'."\n";
484
+		if ($buffer != '') $reset = 0;
485
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
486
+		$buffer = explode('\n',$buffer);
487
+		foreach ($buffer as $line) {
488 488
 		if ($line != '') {
489
-		    $data = array();
490
-		    $data['mmsi'] = (int)substr($line,0,9);
491
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
492
-		    //$data['status'] = substr($line,21,2);
493
-		    //$data['type'] = substr($line,24,3);
494
-		    $data['latitude'] = substr($line,29,9);
495
-		    $data['longitude'] = substr($line,41,9);
496
-		    $data['speed'] = round(substr($line,51,5));
497
-		    //$data['course'] = substr($line,57,5);
498
-		    $data['heading'] = round(substr($line,63,3));
499
-		    //$data['draft'] = substr($line,67,4);
500
-		    //$data['length'] = substr($line,72,3);
501
-		    //$data['beam'] = substr($line,76,2);
502
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
503
-		    //$data['callsign'] = trim(substr($line,100,7);
504
-		    //$data['dest'] = substr($line,108,20);
505
-		    //$data['etaDate'] = substr($line,129,5);
506
-		    //$data['etaTime'] = substr($line,135,5);
507
-		    $data['format_source'] = 'shipplotter';
508
-    		    $data['id_source'] = $id_source;
509
-		    print_r($data);
510
-		    echo 'Add...'."\n";
511
-		    $MI->add($data);
512
-		    unset($data);
489
+			$data = array();
490
+			$data['mmsi'] = (int)substr($line,0,9);
491
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
492
+			//$data['status'] = substr($line,21,2);
493
+			//$data['type'] = substr($line,24,3);
494
+			$data['latitude'] = substr($line,29,9);
495
+			$data['longitude'] = substr($line,41,9);
496
+			$data['speed'] = round(substr($line,51,5));
497
+			//$data['course'] = substr($line,57,5);
498
+			$data['heading'] = round(substr($line,63,3));
499
+			//$data['draft'] = substr($line,67,4);
500
+			//$data['length'] = substr($line,72,3);
501
+			//$data['beam'] = substr($line,76,2);
502
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
503
+			//$data['callsign'] = trim(substr($line,100,7);
504
+			//$data['dest'] = substr($line,108,20);
505
+			//$data['etaDate'] = substr($line,129,5);
506
+			//$data['etaTime'] = substr($line,135,5);
507
+			$data['format_source'] = 'shipplotter';
508
+				$data['id_source'] = $id_source;
509
+			print_r($data);
510
+			echo 'Add...'."\n";
511
+			$MI->add($data);
512
+			unset($data);
513 513
 		}
514
-    	    }
515
-    	    $last_exec[$id]['last'] = time();
514
+			}
515
+			$last_exec[$id]['last'] = time();
516 516
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
517 517
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
518
-	    //$buffer = $Common->getData($hosts[$id]);
519
-	    $buffer = $Common->getData($value['host']);
520
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
521
-	    $buffer = explode('\n',$buffer);
522
-	    $reset = 0;
523
-	    foreach ($buffer as $line) {
524
-    		if ($line != '') {
525
-    		    $line = explode(':', $line);
526
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
518
+		//$buffer = $Common->getData($hosts[$id]);
519
+		$buffer = $Common->getData($value['host']);
520
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
521
+		$buffer = explode('\n',$buffer);
522
+		$reset = 0;
523
+		foreach ($buffer as $line) {
524
+			if ($line != '') {
525
+				$line = explode(':', $line);
526
+				if (count($line) > 30 && $line[0] != 'callsign') {
527 527
 			$data = array();
528 528
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
529 529
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -536,36 +536,36 @@  discard block
 block discarded – undo
536 536
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
537 537
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
538 538
 			$data['latitude'] = $line[5]; // lat
539
-	        	$data['longitude'] = $line[6]; // long
540
-	        	$data['verticalrate'] = ''; // vertical rate
541
-	        	$data['squawk'] = ''; // squawk
542
-	        	$data['emergency'] = ''; // emergency
543
-	        	$data['waypoints'] = $line[30];
539
+				$data['longitude'] = $line[6]; // long
540
+				$data['verticalrate'] = ''; // vertical rate
541
+				$data['squawk'] = ''; // squawk
542
+				$data['emergency'] = ''; // emergency
543
+				$data['waypoints'] = $line[30];
544 544
 			$data['datetime'] = date('Y-m-d H:i:s');
545 545
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
546 546
 			//if (isset($line[37])) $data['last_update'] = $line[37];
547
-		        $data['departure_airport_icao'] = $line[11];
548
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
549
-		        $data['arrival_airport_icao'] = $line[13];
547
+				$data['departure_airport_icao'] = $line[11];
548
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
549
+				$data['arrival_airport_icao'] = $line[13];
550 550
 			$data['frequency'] = $line[4];
551 551
 			$data['type'] = $line[18];
552 552
 			$data['range'] = $line[19];
553 553
 			if (isset($line[35])) $data['info'] = $line[35];
554
-    			$data['id_source'] = $id_source;
555
-	    		//$data['arrival_airport_time'] = ;
556
-	    		if ($line[9] != '') {
557
-	    		    $aircraft_data = explode('/',$line[9]);
558
-	    		    if (isset($aircraft_data[1])) {
559
-	    			$data['aircraft_icao'] = $aircraft_data[1];
560
-	    		    }
561
-        		}
562
-	    		/*
554
+				$data['id_source'] = $id_source;
555
+				//$data['arrival_airport_time'] = ;
556
+				if ($line[9] != '') {
557
+					$aircraft_data = explode('/',$line[9]);
558
+					if (isset($aircraft_data[1])) {
559
+					$data['aircraft_icao'] = $aircraft_data[1];
560
+					}
561
+				}
562
+				/*
563 563
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
564 564
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
565 565
 	    		*/
566
-	    		$data['format_source'] = $value['format'];
566
+				$data['format_source'] = $value['format'];
567 567
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
568
-    			if ($line[3] == 'PILOT') $SI->add($data);
568
+				if ($line[3] == 'PILOT') $SI->add($data);
569 569
 			elseif ($line[3] == 'ATC') {
570 570
 				//print_r($data);
571 571
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -583,247 +583,247 @@  discard block
 block discarded – undo
583 583
 				if (!isset($data['source_name'])) $data['source_name'] = '';
584 584
 				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']);
585 585
 			}
586
-    			unset($data);
587
-    		    }
588
-    		}
589
-    	    }
590
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
591
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
592
-    	    $last_exec[$id]['last'] = time();
593
-    	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
594
-    	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
595
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
596
-	    if ($buffer != '') {
597
-	    $all_data = json_decode($buffer,true);
598
-	    if (isset($all_data['acList'])) {
586
+				unset($data);
587
+				}
588
+			}
589
+			}
590
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
591
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
592
+			$last_exec[$id]['last'] = time();
593
+		//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
594
+		} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
595
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
596
+		if ($buffer != '') {
597
+		$all_data = json_decode($buffer,true);
598
+		if (isset($all_data['acList'])) {
599 599
 		$reset = 0;
600 600
 		foreach ($all_data['acList'] as $line) {
601
-		    $data = array();
602
-		    $data['hex'] = $line['Icao']; // hex
603
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
604
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
605
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
606
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
607
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
608
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
609
-		    //$data['verticalrate'] = $line['']; // verticale rate
610
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
611
-		    $data['emergency'] = ''; // emergency
612
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
613
-		    /*
601
+			$data = array();
602
+			$data['hex'] = $line['Icao']; // hex
603
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
604
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
605
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
606
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
607
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
608
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
609
+			//$data['verticalrate'] = $line['']; // verticale rate
610
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
611
+			$data['emergency'] = ''; // emergency
612
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
613
+			/*
614 614
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
615 615
 		    else $data['datetime'] = date('Y-m-d H:i:s');
616 616
 		    */
617
-		    $data['datetime'] = date('Y-m-d H:i:s');
618
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
619
-	    	    $data['format_source'] = 'aircraftlistjson';
620
-		    $data['id_source'] = $id_source;
621
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
622
-		    if (isset($data['datetime'])) $SI->add($data);
623
-		    unset($data);
617
+			$data['datetime'] = date('Y-m-d H:i:s');
618
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
619
+				$data['format_source'] = 'aircraftlistjson';
620
+			$data['id_source'] = $id_source;
621
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
622
+			if (isset($data['datetime'])) $SI->add($data);
623
+			unset($data);
624 624
 		}
625
-	    } else {
625
+		} else {
626 626
 		$reset = 0;
627 627
 		foreach ($all_data as $line) {
628
-		    $data = array();
629
-		    $data['hex'] = $line['hex']; // hex
630
-		    $data['ident'] = $line['flight']; // ident
631
-		    $data['altitude'] = $line['altitude']; // altitude
632
-		    $data['speed'] = $line['speed']; // speed
633
-		    $data['heading'] = $line['track']; // heading
634
-		    $data['latitude'] = $line['lat']; // lat
635
-		    $data['longitude'] = $line['lon']; // long
636
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
637
-		    $data['squawk'] = $line['squawk']; // squawk
638
-		    $data['emergency'] = ''; // emergency
639
-		    $data['datetime'] = date('Y-m-d H:i:s');
640
-	    	    $data['format_source'] = 'aircraftlistjson';
641
-    		    $data['id_source'] = $id_source;
642
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
643
-		    $SI->add($data);
644
-		    unset($data);
628
+			$data = array();
629
+			$data['hex'] = $line['hex']; // hex
630
+			$data['ident'] = $line['flight']; // ident
631
+			$data['altitude'] = $line['altitude']; // altitude
632
+			$data['speed'] = $line['speed']; // speed
633
+			$data['heading'] = $line['track']; // heading
634
+			$data['latitude'] = $line['lat']; // lat
635
+			$data['longitude'] = $line['lon']; // long
636
+			$data['verticalrate'] = $line['vrt']; // verticale rate
637
+			$data['squawk'] = $line['squawk']; // squawk
638
+			$data['emergency'] = ''; // emergency
639
+			$data['datetime'] = date('Y-m-d H:i:s');
640
+				$data['format_source'] = 'aircraftlistjson';
641
+				$data['id_source'] = $id_source;
642
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
643
+			$SI->add($data);
644
+			unset($data);
645
+		}
645 646
 		}
646
-	    }
647
-	    }
648
-    	    //$last_exec['aircraftlistjson'] = time();
649
-    	    $last_exec[$id]['last'] = time();
650
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
651
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
652
-	    $buffer = $Common->getData($value['host']);
653
-	    $all_data = json_decode($buffer,true);
654
-	    if (isset($all_data['planes'])) {
647
+		}
648
+			//$last_exec['aircraftlistjson'] = time();
649
+			$last_exec[$id]['last'] = time();
650
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
651
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
652
+		$buffer = $Common->getData($value['host']);
653
+		$all_data = json_decode($buffer,true);
654
+		if (isset($all_data['planes'])) {
655 655
 		$reset = 0;
656 656
 		foreach ($all_data['planes'] as $key => $line) {
657
-		    $data = array();
658
-		    $data['hex'] = $key; // hex
659
-		    $data['ident'] = $line[3]; // ident
660
-		    $data['altitude'] = $line[6]; // altitude
661
-		    $data['speed'] = $line[8]; // speed
662
-		    $data['heading'] = $line[7]; // heading
663
-		    $data['latitude'] = $line[4]; // lat
664
-		    $data['longitude'] = $line[5]; // long
665
-		    //$data['verticalrate'] = $line[]; // verticale rate
666
-		    $data['squawk'] = $line[10]; // squawk
667
-		    $data['emergency'] = ''; // emergency
668
-		    $data['registration'] = $line[2];
669
-		    $data['aircraft_icao'] = $line[0];
670
-		    $deparr = explode('-',$line[1]);
671
-		    if (count($deparr) == 2) {
657
+			$data = array();
658
+			$data['hex'] = $key; // hex
659
+			$data['ident'] = $line[3]; // ident
660
+			$data['altitude'] = $line[6]; // altitude
661
+			$data['speed'] = $line[8]; // speed
662
+			$data['heading'] = $line[7]; // heading
663
+			$data['latitude'] = $line[4]; // lat
664
+			$data['longitude'] = $line[5]; // long
665
+			//$data['verticalrate'] = $line[]; // verticale rate
666
+			$data['squawk'] = $line[10]; // squawk
667
+			$data['emergency'] = ''; // emergency
668
+			$data['registration'] = $line[2];
669
+			$data['aircraft_icao'] = $line[0];
670
+			$deparr = explode('-',$line[1]);
671
+			if (count($deparr) == 2) {
672 672
 			$data['departure_airport_icao'] = $deparr[0];
673 673
 			$data['arrival_airport_icao'] = $deparr[1];
674
-		    }
675
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
676
-	    	    $data['format_source'] = 'planeupdatefaa';
677
-    		    $data['id_source'] = $id_source;
678
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
679
-		    $SI->add($data);
680
-		    unset($data);
674
+			}
675
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
676
+				$data['format_source'] = 'planeupdatefaa';
677
+				$data['id_source'] = $id_source;
678
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
679
+			$SI->add($data);
680
+			unset($data);
681 681
 		}
682
-	    }
683
-    	    //$last_exec['planeupdatefaa'] = time();
684
-    	    $last_exec[$id]['last'] = time();
685
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
686
-	    $buffer = $Common->getData($value['host']);
687
-	    $all_data = json_decode($buffer,true);
688
-	    if (isset($all_data['states'])) {
682
+		}
683
+			//$last_exec['planeupdatefaa'] = time();
684
+			$last_exec[$id]['last'] = time();
685
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
686
+		$buffer = $Common->getData($value['host']);
687
+		$all_data = json_decode($buffer,true);
688
+		if (isset($all_data['states'])) {
689 689
 		$reset = 0;
690 690
 		foreach ($all_data['states'] as $key => $line) {
691
-		    $data = array();
692
-		    $data['hex'] = $line[0]; // hex
693
-		    $data['ident'] = trim($line[1]); // ident
694
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
695
-		    $data['speed'] = round($line[9]*1.94384); // speed
696
-		    $data['heading'] = round($line[10]); // heading
697
-		    $data['latitude'] = $line[5]; // lat
698
-		    $data['longitude'] = $line[6]; // long
699
-		    $data['verticalrate'] = $line[11]; // verticale rate
700
-		    //$data['squawk'] = $line[10]; // squawk
701
-		    //$data['emergency'] = ''; // emergency
702
-		    //$data['registration'] = $line[2];
703
-		    //$data['aircraft_icao'] = $line[0];
704
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
705
-	    	    $data['format_source'] = 'opensky';
706
-    		    $data['id_source'] = $id_source;
707
-		    $SI->add($data);
708
-		    unset($data);
691
+			$data = array();
692
+			$data['hex'] = $line[0]; // hex
693
+			$data['ident'] = trim($line[1]); // ident
694
+			$data['altitude'] = round($line[7]*3.28084); // altitude
695
+			$data['speed'] = round($line[9]*1.94384); // speed
696
+			$data['heading'] = round($line[10]); // heading
697
+			$data['latitude'] = $line[5]; // lat
698
+			$data['longitude'] = $line[6]; // long
699
+			$data['verticalrate'] = $line[11]; // verticale rate
700
+			//$data['squawk'] = $line[10]; // squawk
701
+			//$data['emergency'] = ''; // emergency
702
+			//$data['registration'] = $line[2];
703
+			//$data['aircraft_icao'] = $line[0];
704
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
705
+				$data['format_source'] = 'opensky';
706
+				$data['id_source'] = $id_source;
707
+			$SI->add($data);
708
+			unset($data);
709
+		}
709 710
 		}
710
-	    }
711
-    	    //$last_exec['planeupdatefaa'] = time();
712
-    	    $last_exec[$id]['last'] = time();
713
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
714
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
715
-	    //$buffer = $Common->getData($hosts[$id]);
716
-	    $buffer = $Common->getData($value['host']);
717
-	    $all_data = json_decode($buffer,true);
718
-	    if (!empty($all_data)) $reset = 0;
719
-	    foreach ($all_data as $key => $line) {
711
+			//$last_exec['planeupdatefaa'] = time();
712
+			$last_exec[$id]['last'] = time();
713
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
714
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
715
+		//$buffer = $Common->getData($hosts[$id]);
716
+		$buffer = $Common->getData($value['host']);
717
+		$all_data = json_decode($buffer,true);
718
+		if (!empty($all_data)) $reset = 0;
719
+		foreach ($all_data as $key => $line) {
720 720
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
721
-		    $data = array();
722
-		    $data['hex'] = $line[0];
723
-		    $data['ident'] = $line[16]; //$line[13]
724
-	    	    $data['altitude'] = $line[4]; // altitude
725
-	    	    $data['speed'] = $line[5]; // speed
726
-	    	    $data['heading'] = $line[3]; // heading
727
-	    	    $data['latitude'] = $line[1]; // lat
728
-	    	    $data['longitude'] = $line[2]; // long
729
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
730
-	    	    $data['squawk'] = $line[6]; // squawk
731
-	    	    $data['aircraft_icao'] = $line[8];
732
-	    	    $data['registration'] = $line[9];
733
-		    $data['departure_airport_iata'] = $line[11];
734
-		    $data['arrival_airport_iata'] = $line[12];
735
-	    	    $data['emergency'] = ''; // emergency
736
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
737
-	    	    $data['format_source'] = 'fr24json';
738
-    		    $data['id_source'] = $id_source;
739
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
740
-		    $SI->add($data);
741
-		    unset($data);
721
+			$data = array();
722
+			$data['hex'] = $line[0];
723
+			$data['ident'] = $line[16]; //$line[13]
724
+				$data['altitude'] = $line[4]; // altitude
725
+				$data['speed'] = $line[5]; // speed
726
+				$data['heading'] = $line[3]; // heading
727
+				$data['latitude'] = $line[1]; // lat
728
+				$data['longitude'] = $line[2]; // long
729
+				$data['verticalrate'] = $line[15]; // verticale rate
730
+				$data['squawk'] = $line[6]; // squawk
731
+				$data['aircraft_icao'] = $line[8];
732
+				$data['registration'] = $line[9];
733
+			$data['departure_airport_iata'] = $line[11];
734
+			$data['arrival_airport_iata'] = $line[12];
735
+				$data['emergency'] = ''; // emergency
736
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
737
+				$data['format_source'] = 'fr24json';
738
+				$data['id_source'] = $id_source;
739
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
740
+			$SI->add($data);
741
+			unset($data);
742
+		}
742 743
 		}
743
-	    }
744
-    	    //$last_exec['fr24json'] = time();
745
-    	    $last_exec[$id]['last'] = time();
746
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
747
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
748
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
749
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
750
-	    //echo $buffer;
751
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
752
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
753
-	    $all_data = json_decode($buffer,true);
754
-	    if (json_last_error() != JSON_ERROR_NONE) {
744
+			//$last_exec['fr24json'] = time();
745
+			$last_exec[$id]['last'] = time();
746
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
747
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
748
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
749
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
750
+		//echo $buffer;
751
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
752
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
753
+		$all_data = json_decode($buffer,true);
754
+		if (json_last_error() != JSON_ERROR_NONE) {
755 755
 		die(json_last_error_msg());
756
-	    }
757
-	    if (isset($all_data['mrkrs'])) {
756
+		}
757
+		if (isset($all_data['mrkrs'])) {
758 758
 		$reset = 0;
759 759
 		foreach ($all_data['mrkrs'] as $key => $line) {
760
-		    if (isset($line['inf'])) {
760
+			if (isset($line['inf'])) {
761 761
 			$data = array();
762 762
 			$data['hex'] = $line['inf']['ia'];
763 763
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
764
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
765
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
766
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
767
-	    		$data['latitude'] = $line['pt'][0]; // lat
768
-	    		$data['longitude'] = $line['pt'][1]; // long
769
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
770
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
771
-	    		//$data['aircraft_icao'] = $line[8];
772
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
764
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
765
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
766
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
767
+				$data['latitude'] = $line['pt'][0]; // lat
768
+				$data['longitude'] = $line['pt'][1]; // long
769
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
770
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
771
+				//$data['aircraft_icao'] = $line[8];
772
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
773 773
 			//$data['departure_airport_iata'] = $line[11];
774 774
 			//$data['arrival_airport_iata'] = $line[12];
775
-	    		//$data['emergency'] = ''; // emergency
775
+				//$data['emergency'] = ''; // emergency
776 776
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
777
-	    		$data['format_source'] = 'radarvirtueljson';
778
-    			$data['id_source'] = $id_source;
777
+				$data['format_source'] = 'radarvirtueljson';
778
+				$data['id_source'] = $id_source;
779 779
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
780 780
 			$SI->add($data);
781 781
 			unset($data);
782
-		    }
782
+			}
783 783
 		}
784
-	    }
785
-    	    //$last_exec['radarvirtueljson'] = time();
786
-    	    $last_exec[$id]['last'] = time();
787
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
788
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
789
-	    //$buffer = $Common->getData($hosts[$id]);
790
-	    $buffer = $Common->getData($value['host'].'?'.time());
791
-	    $all_data = json_decode(utf8_encode($buffer),true);
784
+		}
785
+			//$last_exec['radarvirtueljson'] = time();
786
+			$last_exec[$id]['last'] = time();
787
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
788
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
789
+		//$buffer = $Common->getData($hosts[$id]);
790
+		$buffer = $Common->getData($value['host'].'?'.time());
791
+		$all_data = json_decode(utf8_encode($buffer),true);
792 792
 	    
793
-	    if (isset($all_data['pireps'])) {
793
+		if (isset($all_data['pireps'])) {
794 794
 		$reset = 0;
795
-	        foreach ($all_data['pireps'] as $line) {
796
-		    $data = array();
797
-		    $data['id'] = $line['id'];
798
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
799
-		    $data['ident'] = $line['callsign']; // ident
800
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
801
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
802
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
803
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
804
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
805
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
806
-		    $data['latitude'] = $line['lat']; // lat
807
-		    $data['longitude'] = $line['lon']; // long
808
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
809
-		    //$data['squawk'] = $line['squawk']; // squawk
810
-		    //$data['emergency'] = ''; // emergency
811
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
812
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
813
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
814
-		    //$data['arrival_airport_time'] = $line['arrtime'];
815
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
816
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
817
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
818
-		    else $data['info'] = '';
819
-		    $data['format_source'] = 'pireps';
820
-    		    $data['id_source'] = $id_source;
821
-		    $data['datetime'] = date('Y-m-d H:i:s');
822
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
823
-		    if ($line['icon'] == 'plane') {
795
+			foreach ($all_data['pireps'] as $line) {
796
+			$data = array();
797
+			$data['id'] = $line['id'];
798
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
799
+			$data['ident'] = $line['callsign']; // ident
800
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
801
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
802
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
803
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
804
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
805
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
806
+			$data['latitude'] = $line['lat']; // lat
807
+			$data['longitude'] = $line['lon']; // long
808
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
809
+			//$data['squawk'] = $line['squawk']; // squawk
810
+			//$data['emergency'] = ''; // emergency
811
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
812
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
813
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
814
+			//$data['arrival_airport_time'] = $line['arrtime'];
815
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
816
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
817
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
818
+			else $data['info'] = '';
819
+			$data['format_source'] = 'pireps';
820
+				$data['id_source'] = $id_source;
821
+			$data['datetime'] = date('Y-m-d H:i:s');
822
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
823
+			if ($line['icon'] == 'plane') {
824 824
 			$SI->add($data);
825
-		    //    print_r($data);
826
-    		    } elseif ($line['icon'] == 'ct') {
825
+			//    print_r($data);
826
+				} elseif ($line['icon'] == 'ct') {
827 827
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
828 828
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
829 829
 			$typec = substr($data['ident'],-3);
@@ -838,188 +838,188 @@  discard block
 block discarded – undo
838 838
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
839 839
 			else $data['type'] = 'Observer';
840 840
 			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']);
841
-		    }
842
-		    unset($data);
841
+			}
842
+			unset($data);
843 843
 		}
844
-	    }
845
-    	    //$last_exec['pirepsjson'] = time();
846
-    	    $last_exec[$id]['last'] = time();
847
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
848
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
849
-	    //$buffer = $Common->getData($hosts[$id]);
850
-	    if ($globalDebug) echo 'Get Data...'."\n";
851
-	    $buffer = $Common->getData($value['host']);
852
-	    $all_data = json_decode($buffer,true);
853
-	    if ($buffer != '' && is_array($all_data)) {
844
+		}
845
+			//$last_exec['pirepsjson'] = time();
846
+			$last_exec[$id]['last'] = time();
847
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
848
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
849
+		//$buffer = $Common->getData($hosts[$id]);
850
+		if ($globalDebug) echo 'Get Data...'."\n";
851
+		$buffer = $Common->getData($value['host']);
852
+		$all_data = json_decode($buffer,true);
853
+		if ($buffer != '' && is_array($all_data)) {
854 854
 		$reset = 0;
855 855
 		foreach ($all_data as $line) {
856
-	    	    $data = array();
857
-	    	    //$data['id'] = $line['id']; // id not usable
858
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
859
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
860
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
861
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
862
-	    	    $data['ident'] = $line['flightnum']; // ident
863
-	    	    $data['altitude'] = $line['alt']; // altitude
864
-	    	    $data['speed'] = $line['gs']; // speed
865
-	    	    $data['heading'] = $line['heading']; // heading
866
-	    	    $data['latitude'] = $line['lat']; // lat
867
-	    	    $data['longitude'] = $line['lng']; // long
868
-	    	    $data['verticalrate'] = ''; // verticale rate
869
-	    	    $data['squawk'] = ''; // squawk
870
-	    	    $data['emergency'] = ''; // emergency
871
-	    	    //$data['datetime'] = $line['lastupdate'];
872
-	    	    $data['last_update'] = $line['lastupdate'];
873
-		    $data['datetime'] = date('Y-m-d H:i:s');
874
-	    	    $data['departure_airport_icao'] = $line['depicao'];
875
-	    	    $data['departure_airport_time'] = $line['deptime'];
876
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
877
-    		    $data['arrival_airport_time'] = $line['arrtime'];
878
-    		    $data['registration'] = $line['aircraft'];
879
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
880
-		    if (isset($line['aircraftname'])) {
856
+				$data = array();
857
+				//$data['id'] = $line['id']; // id not usable
858
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
859
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
860
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
861
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
862
+				$data['ident'] = $line['flightnum']; // ident
863
+				$data['altitude'] = $line['alt']; // altitude
864
+				$data['speed'] = $line['gs']; // speed
865
+				$data['heading'] = $line['heading']; // heading
866
+				$data['latitude'] = $line['lat']; // lat
867
+				$data['longitude'] = $line['lng']; // long
868
+				$data['verticalrate'] = ''; // verticale rate
869
+				$data['squawk'] = ''; // squawk
870
+				$data['emergency'] = ''; // emergency
871
+				//$data['datetime'] = $line['lastupdate'];
872
+				$data['last_update'] = $line['lastupdate'];
873
+			$data['datetime'] = date('Y-m-d H:i:s');
874
+				$data['departure_airport_icao'] = $line['depicao'];
875
+				$data['departure_airport_time'] = $line['deptime'];
876
+				$data['arrival_airport_icao'] = $line['arricao'];
877
+				$data['arrival_airport_time'] = $line['arrtime'];
878
+				$data['registration'] = $line['aircraft'];
879
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
880
+			if (isset($line['aircraftname'])) {
881 881
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
882 882
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
883
-	    		$aircraft_data = explode('-',$line['aircraftname']);
884
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
885
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
886
-	    		else {
887
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
888
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
889
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
890
-	    		}
891
-	    	    }
892
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
893
-    		    $data['id_source'] = $id_source;
894
-	    	    $data['format_source'] = 'phpvmacars';
895
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
896
-		    $SI->add($data);
897
-		    unset($data);
883
+				$aircraft_data = explode('-',$line['aircraftname']);
884
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
885
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
886
+				else {
887
+					$aircraft_data = explode(' ',$line['aircraftname']);
888
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
889
+					else $data['aircraft_icao'] = $line['aircraftname'];
890
+				}
891
+				}
892
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
893
+				$data['id_source'] = $id_source;
894
+				$data['format_source'] = 'phpvmacars';
895
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
896
+			$SI->add($data);
897
+			unset($data);
898 898
 		}
899 899
 		if ($globalDebug) echo 'No more data...'."\n";
900 900
 		unset($buffer);
901 901
 		unset($all_data);
902
-	    }
903
-    	    //$last_exec['phpvmacars'] = time();
904
-    	    $last_exec[$id]['last'] = time();
905
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
906
-	    //$buffer = $Common->getData($hosts[$id]);
907
-	    if ($globalDebug) echo 'Get Data...'."\n";
908
-	    $buffer = $Common->getData($value['host']);
909
-	    $all_data = json_decode($buffer,true);
910
-	    if ($buffer != '' && is_array($all_data)) {
902
+		}
903
+			//$last_exec['phpvmacars'] = time();
904
+			$last_exec[$id]['last'] = time();
905
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
906
+		//$buffer = $Common->getData($hosts[$id]);
907
+		if ($globalDebug) echo 'Get Data...'."\n";
908
+		$buffer = $Common->getData($value['host']);
909
+		$all_data = json_decode($buffer,true);
910
+		if ($buffer != '' && is_array($all_data)) {
911 911
 		$reset = 0;
912 912
 		foreach ($all_data as $line) {
913
-	    	    $data = array();
914
-	    	    //$data['id'] = $line['id']; // id not usable
915
-	    	    $data['id'] = trim($line['flight_id']);
916
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
917
-	    	    $data['pilot_name'] = $line['pilot_name'];
918
-	    	    $data['pilot_id'] = $line['pilot_id'];
919
-	    	    $data['ident'] = trim($line['callsign']); // ident
920
-	    	    $data['altitude'] = $line['altitude']; // altitude
921
-	    	    $data['speed'] = $line['gs']; // speed
922
-	    	    $data['heading'] = $line['heading']; // heading
923
-	    	    $data['latitude'] = $line['latitude']; // lat
924
-	    	    $data['longitude'] = $line['longitude']; // long
925
-	    	    $data['verticalrate'] = ''; // verticale rate
926
-	    	    $data['squawk'] = ''; // squawk
927
-	    	    $data['emergency'] = ''; // emergency
928
-	    	    //$data['datetime'] = $line['lastupdate'];
929
-	    	    $data['last_update'] = $line['last_update'];
930
-		    $data['datetime'] = date('Y-m-d H:i:s');
931
-	    	    $data['departure_airport_icao'] = $line['departure'];
932
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
933
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
934
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
935
-    		    //$data['registration'] = $line['aircraft'];
936
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
937
-	    	    $data['aircraft_icao'] = $line['plane_type'];
938
-    		    $data['id_source'] = $id_source;
939
-	    	    $data['format_source'] = 'vam';
940
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
941
-		    $SI->add($data);
942
-		    unset($data);
913
+				$data = array();
914
+				//$data['id'] = $line['id']; // id not usable
915
+				$data['id'] = trim($line['flight_id']);
916
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
917
+				$data['pilot_name'] = $line['pilot_name'];
918
+				$data['pilot_id'] = $line['pilot_id'];
919
+				$data['ident'] = trim($line['callsign']); // ident
920
+				$data['altitude'] = $line['altitude']; // altitude
921
+				$data['speed'] = $line['gs']; // speed
922
+				$data['heading'] = $line['heading']; // heading
923
+				$data['latitude'] = $line['latitude']; // lat
924
+				$data['longitude'] = $line['longitude']; // long
925
+				$data['verticalrate'] = ''; // verticale rate
926
+				$data['squawk'] = ''; // squawk
927
+				$data['emergency'] = ''; // emergency
928
+				//$data['datetime'] = $line['lastupdate'];
929
+				$data['last_update'] = $line['last_update'];
930
+			$data['datetime'] = date('Y-m-d H:i:s');
931
+				$data['departure_airport_icao'] = $line['departure'];
932
+				//$data['departure_airport_time'] = $line['departure_time'];
933
+				$data['arrival_airport_icao'] = $line['arrival'];
934
+				//$data['arrival_airport_time'] = $line['arrival_time'];
935
+				//$data['registration'] = $line['aircraft'];
936
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
937
+				$data['aircraft_icao'] = $line['plane_type'];
938
+				$data['id_source'] = $id_source;
939
+				$data['format_source'] = 'vam';
940
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
941
+			$SI->add($data);
942
+			unset($data);
943 943
 		}
944 944
 		if ($globalDebug) echo 'No more data...'."\n";
945 945
 		unset($buffer);
946 946
 		unset($all_data);
947
-	    }
948
-    	    //$last_exec['phpvmacars'] = time();
949
-    	    $last_exec[$id]['last'] = time();
947
+		}
948
+			//$last_exec['phpvmacars'] = time();
949
+			$last_exec[$id]['last'] = time();
950 950
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
951 951
 	} 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') {
952
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
953
-    	    //$last_exec[$id]['last'] = time();
952
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
953
+			//$last_exec[$id]['last'] = time();
954 954
 
955
-	    //$read = array( $sockets[$id] );
956
-	    $read = $sockets;
957
-	    $write = NULL;
958
-	    $e = NULL;
959
-	    $n = socket_select($read, $write, $e, $timeout);
960
-	    if ($e != NULL) var_dump($e);
961
-	    if ($n > 0) {
955
+		//$read = array( $sockets[$id] );
956
+		$read = $sockets;
957
+		$write = NULL;
958
+		$e = NULL;
959
+		$n = socket_select($read, $write, $e, $timeout);
960
+		if ($e != NULL) var_dump($e);
961
+		if ($n > 0) {
962 962
 		$reset = 0;
963 963
 		foreach ($read as $nb => $r) {
964
-		    //$value = $formats[$nb];
965
-		    $format = $globalSources[$nb]['format'];
966
-        	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
967
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
968
-        	    } else {
969
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
970
-	    	    }
971
-        	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
972
-        	    //echo $buffer."\n";
973
-		    // lets play nice and handle signals such as ctrl-c/kill properly
974
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
975
-		    $error = false;
976
-		    //$SI::del();
977
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
978
-		    // SBS format is CSV format
979
-		    if ($buffer != '') {
964
+			//$value = $formats[$nb];
965
+			$format = $globalSources[$nb]['format'];
966
+				if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
967
+				$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
968
+				} else {
969
+					$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
970
+				}
971
+				//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
972
+				//echo $buffer."\n";
973
+			// lets play nice and handle signals such as ctrl-c/kill properly
974
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
975
+			$error = false;
976
+			//$SI::del();
977
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
978
+			// SBS format is CSV format
979
+			if ($buffer != '') {
980 980
 			$tt[$format] = 0;
981 981
 			if ($format == 'acarssbs3') {
982
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
983
-			    $ACARS->add(trim($buffer));
984
-			    $ACARS->deleteLiveAcarsData();
982
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
983
+				$ACARS->add(trim($buffer));
984
+				$ACARS->deleteLiveAcarsData();
985 985
 			} elseif ($format == 'raw') {
986
-			    // AVR format
987
-			    $data = $SBS->parse($buffer);
988
-			    if (is_array($data)) {
986
+				// AVR format
987
+				$data = $SBS->parse($buffer);
988
+				if (is_array($data)) {
989 989
 				$data['datetime'] = date('Y-m-d H:i:s');
990 990
 				$data['format_source'] = 'raw';
991 991
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
992
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
993
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
994
-                            }
995
-                        } elseif ($format == 'ais') {
996
-			    $ais_data = $AIS->parse_line(trim($buffer));
997
-			    $data = array();
998
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
999
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1000
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1001
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1002
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1003
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1004
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1005
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1006
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1007
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1008
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1009
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
992
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
993
+								if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
994
+							}
995
+						} elseif ($format == 'ais') {
996
+				$ais_data = $AIS->parse_line(trim($buffer));
997
+				$data = array();
998
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
999
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1000
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1001
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1002
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1003
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1004
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1005
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1006
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1007
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1008
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1009
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1010 1010
 
1011
-			    if (isset($ais_data['timestamp'])) {
1011
+				if (isset($ais_data['timestamp'])) {
1012 1012
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1013
-			    } else {
1013
+				} else {
1014 1014
 				$data['datetime'] = date('Y-m-d H:i:s');
1015
-			    }
1016
-			    $data['format_source'] = 'aisnmea';
1017
-    			    $data['id_source'] = $id_source;
1018
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1019
-			    unset($data);
1020
-                        } elseif ($format == 'flightgearsp') {
1021
-                    	    //echo $buffer."\n";
1022
-                    	    if (strlen($buffer) > 5) {
1015
+				}
1016
+				$data['format_source'] = 'aisnmea';
1017
+					$data['id_source'] = $id_source;
1018
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1019
+				unset($data);
1020
+						} elseif ($format == 'flightgearsp') {
1021
+							//echo $buffer."\n";
1022
+							if (strlen($buffer) > 5) {
1023 1023
 				$line = explode(',',$buffer);
1024 1024
 				$data = array();
1025 1025
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1035,120 +1035,120 @@  discard block
 block discarded – undo
1035 1035
 				$data['format_source'] = 'flightgearsp';
1036 1036
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1037 1037
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1038
-			    }
1039
-                        } elseif ($format == 'acars') {
1040
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1041
-			    $ACARS->add(trim($buffer));
1042
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1043
-			    $ACARS->deleteLiveAcarsData();
1038
+				}
1039
+						} elseif ($format == 'acars') {
1040
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1041
+				$ACARS->add(trim($buffer));
1042
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1043
+				$ACARS->deleteLiveAcarsData();
1044 1044
 			} elseif ($format == 'flightgearmp') {
1045
-			    if (substr($buffer,0,1) != '#') {
1045
+				if (substr($buffer,0,1) != '#') {
1046 1046
 				$data = array();
1047 1047
 				//echo $buffer."\n";
1048 1048
 				$line = explode(' ',$buffer);
1049 1049
 				if (count($line) == 11) {
1050
-				    $userserver = explode('@',$line[0]);
1051
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1052
-				    $data['ident'] = $userserver[0];
1053
-				    $data['registration'] = $userserver[0];
1054
-				    $data['latitude'] = $line[4];
1055
-				    $data['longitude'] = $line[5];
1056
-				    $data['altitude'] = $line[6];
1057
-				    $data['datetime'] = date('Y-m-d H:i:s');
1058
-				    $aircraft_type = $line[10];
1059
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1060
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1061
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1050
+					$userserver = explode('@',$line[0]);
1051
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1052
+					$data['ident'] = $userserver[0];
1053
+					$data['registration'] = $userserver[0];
1054
+					$data['latitude'] = $line[4];
1055
+					$data['longitude'] = $line[5];
1056
+					$data['altitude'] = $line[6];
1057
+					$data['datetime'] = date('Y-m-d H:i:s');
1058
+					$aircraft_type = $line[10];
1059
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1060
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1061
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1062
+				}
1062 1063
 				}
1063
-			    }
1064 1064
 			} elseif ($format == 'beast') {
1065
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1066
-			    die;
1065
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1066
+				die;
1067 1067
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1068
-			    $line = explode("\t", $buffer);
1069
-			    for($k = 0; $k < count($line); $k=$k+2) {
1068
+				$line = explode("\t", $buffer);
1069
+				for($k = 0; $k < count($line); $k=$k+2) {
1070 1070
 				$key = $line[$k];
1071
-			        $lined[$key] = $line[$k+1];
1072
-			    }
1073
-    			    if (count($lined) > 3) {
1074
-    				$data['hex'] = $lined['hexid'];
1075
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1076
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1077
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1078
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1079
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1080
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1081
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1082
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1083
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1084
-    				$data['id_source'] = $id_source;
1085
-    				$data['format_source'] = 'tsv';
1086
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1087
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1088
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1089
-    				unset($lined);
1090
-    				unset($data);
1091
-    			    } else $error = true;
1071
+					$lined[$key] = $line[$k+1];
1072
+				}
1073
+					if (count($lined) > 3) {
1074
+					$data['hex'] = $lined['hexid'];
1075
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1076
+					$data['datetime'] = date('Y-m-d H:i:s');;
1077
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1078
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1079
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1080
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1081
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1082
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1083
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1084
+					$data['id_source'] = $id_source;
1085
+					$data['format_source'] = 'tsv';
1086
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1087
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1088
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1089
+					unset($lined);
1090
+					unset($data);
1091
+					} else $error = true;
1092 1092
 			} elseif ($format == 'aprs' && $use_aprs) {
1093
-			    if ($aprs_connect == 0) {
1093
+				if ($aprs_connect == 0) {
1094 1094
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1095 1095
 				$aprs_connect = 1;
1096
-			    }
1096
+				}
1097 1097
 			    
1098
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1098
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1099 1099
 				$aprs_last_tx = time();
1100 1100
 				$data_aprs = "# Keep alive";
1101 1101
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1102
-			    }
1102
+				}
1103 1103
 			    
1104
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1105
-			    $buffer = str_replace('APRS <- ','',$buffer);
1106
-			    $buffer = str_replace('APRS -> ','',$buffer);
1107
-			    //echo $buffer."\n";
1108
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1104
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1105
+				$buffer = str_replace('APRS <- ','',$buffer);
1106
+				$buffer = str_replace('APRS -> ','',$buffer);
1107
+				//echo $buffer."\n";
1108
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1109 1109
 				$line = $APRS->parse($buffer);
1110 1110
 				//print_r($line);
1111 1111
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1112 1112
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && isset($line['ident'])) {
1113
-				    $aprs_last_tx = time();
1114
-				    $data = array();
1115
-				    //print_r($line);
1116
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1117
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1118
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1119
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1120
-				    $data['ident'] = $line['ident'];
1121
-				    $data['latitude'] = $line['latitude'];
1122
-				    $data['longitude'] = $line['longitude'];
1123
-				    //$data['verticalrate'] = $line[16];
1124
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1125
-				    else $data['speed'] = 0;
1126
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1127
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1128
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1129
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1130
-				    //else $data['heading'] = 0;
1131
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1132
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1133
-    				    $data['id_source'] = $id_source;
1134
-				    $data['format_source'] = 'aprs';
1135
-				    $data['source_name'] = $line['source'];
1136
-				    $data['source_type'] = 'flarm';
1137
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1138
-				    $currentdate = date('Y-m-d H:i:s');
1139
-				    $aprsdate = strtotime($data['datetime']);
1140
-				    // Accept data if time <= system time + 20s
1141
-				    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'])))) {
1113
+					$aprs_last_tx = time();
1114
+					$data = array();
1115
+					//print_r($line);
1116
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1117
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1118
+					else $data['datetime'] = date('Y-m-d H:i:s');
1119
+					//$data['datetime'] = date('Y-m-d H:i:s');
1120
+					$data['ident'] = $line['ident'];
1121
+					$data['latitude'] = $line['latitude'];
1122
+					$data['longitude'] = $line['longitude'];
1123
+					//$data['verticalrate'] = $line[16];
1124
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1125
+					else $data['speed'] = 0;
1126
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1127
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1128
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1129
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
1130
+					//else $data['heading'] = 0;
1131
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1132
+					if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1133
+						$data['id_source'] = $id_source;
1134
+					$data['format_source'] = 'aprs';
1135
+					$data['source_name'] = $line['source'];
1136
+					$data['source_type'] = 'flarm';
1137
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1138
+					$currentdate = date('Y-m-d H:i:s');
1139
+					$aprsdate = strtotime($data['datetime']);
1140
+					// Accept data if time <= system time + 20s
1141
+					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'])))) {
1142 1142
 					$send = $SI->add($data);
1143
-				    } elseif (isset($line['stealth'])) {
1143
+					} elseif (isset($line['stealth'])) {
1144 1144
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1145 1145
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1146
-				    //} 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')) {
1147
-				    } 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') {
1146
+					//} 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')) {
1147
+					} 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') {
1148 1148
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1149 1149
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1150
-				    }
1151
-				    unset($data);
1150
+					}
1151
+					unset($data);
1152 1152
 				} 
1153 1153
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1154 1154
 					echo '!! Weather Station not yet supported'."\n";
@@ -1158,12 +1158,12 @@  discard block
 block discarded – undo
1158 1158
 				}
1159 1159
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1160 1160
 				//elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1161
-			    }
1161
+				}
1162 1162
 			} else {
1163
-			    $line = explode(',', $buffer);
1164
-    			    if (count($line) > 20) {
1165
-    			    	$data['hex'] = $line[4];
1166
-    				/*
1163
+				$line = explode(',', $buffer);
1164
+					if (count($line) > 20) {
1165
+						$data['hex'] = $line[4];
1166
+					/*
1167 1167
     				$data['datetime'] = $line[6].' '.$line[7];
1168 1168
     					date_default_timezone_set($globalTimezone);
1169 1169
     					$datetime = new DateTime($data['datetime']);
@@ -1171,29 +1171,29 @@  discard block
 block discarded – undo
1171 1171
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1172 1172
     					date_default_timezone_set('UTC');
1173 1173
     				*/
1174
-    				// Force datetime to current UTC datetime
1175
-    				date_default_timezone_set('UTC');
1176
-    				$data['datetime'] = date('Y-m-d H:i:s');
1177
-    				$data['ident'] = trim($line[10]);
1178
-    				$data['latitude'] = $line[14];
1179
-    				$data['longitude'] = $line[15];
1180
-    				$data['verticalrate'] = $line[16];
1181
-    				$data['emergency'] = $line[20];
1182
-    				$data['speed'] = $line[12];
1183
-    				$data['squawk'] = $line[17];
1184
-    				$data['altitude'] = $line[11];
1185
-    				$data['heading'] = $line[13];
1186
-    				$data['ground'] = $line[21];
1187
-    				$data['emergency'] = $line[19];
1188
-    				$data['format_source'] = 'sbs';
1174
+					// Force datetime to current UTC datetime
1175
+					date_default_timezone_set('UTC');
1176
+					$data['datetime'] = date('Y-m-d H:i:s');
1177
+					$data['ident'] = trim($line[10]);
1178
+					$data['latitude'] = $line[14];
1179
+					$data['longitude'] = $line[15];
1180
+					$data['verticalrate'] = $line[16];
1181
+					$data['emergency'] = $line[20];
1182
+					$data['speed'] = $line[12];
1183
+					$data['squawk'] = $line[17];
1184
+					$data['altitude'] = $line[11];
1185
+					$data['heading'] = $line[13];
1186
+					$data['ground'] = $line[21];
1187
+					$data['emergency'] = $line[19];
1188
+					$data['format_source'] = 'sbs';
1189 1189
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1190
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1191
-    				$data['id_source'] = $id_source;
1192
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1193
-    				else $error = true;
1194
-    				unset($data);
1195
-    			    } else $error = true;
1196
-			    if ($error) {
1190
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1191
+					$data['id_source'] = $id_source;
1192
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1193
+					else $error = true;
1194
+					unset($data);
1195
+					} else $error = true;
1196
+				if ($error) {
1197 1197
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1198 1198
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1199 1199
 				} else {
@@ -1209,13 +1209,13 @@  discard block
 block discarded – undo
1209 1209
 					connect_all($sourceer);
1210 1210
 					$sourceer = array();
1211 1211
 				}
1212
-			    }
1212
+				}
1213 1213
 			}
1214 1214
 			// Sleep for xxx microseconds
1215 1215
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1216
-		    } else {
1216
+			} else {
1217 1217
 			if ($format == 'flightgearmp') {
1218
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1218
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1219 1219
 				//@socket_close($r);
1220 1220
 				sleep($globalMinFetch);
1221 1221
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1224,9 +1224,9 @@  discard block
 block discarded – undo
1224 1224
 				break;
1225 1225
 				
1226 1226
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1227
-			    if (isset($tt[$format])) $tt[$format]++;
1228
-			    else $tt[$format] = 0;
1229
-			    if ($tt[$format] > 30) {
1227
+				if (isset($tt[$format])) $tt[$format]++;
1228
+				else $tt[$format] = 0;
1229
+				if ($tt[$format] > 30) {
1230 1230
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1231 1231
 				//@socket_close($r);
1232 1232
 				sleep(2);
@@ -1237,23 +1237,23 @@  discard block
 block discarded – undo
1237 1237
 				//connect_all($globalSources);
1238 1238
 				$tt[$format]=0;
1239 1239
 				break;
1240
-			    }
1240
+				}
1241
+			}
1241 1242
 			}
1242
-		    }
1243 1243
 		}
1244
-	    } else {
1244
+		} else {
1245 1245
 		$error = socket_strerror(socket_last_error());
1246 1246
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1247 1247
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1248 1248
 			if (isset($globalDebug)) echo "Restarting...\n";
1249 1249
 			// Restart the script if possible
1250 1250
 			if (is_array($sockets)) {
1251
-			    if ($globalDebug) echo "Shutdown all sockets...";
1251
+				if ($globalDebug) echo "Shutdown all sockets...";
1252 1252
 			    
1253
-			    foreach ($sockets as $sock) {
1253
+				foreach ($sockets as $sock) {
1254 1254
 				@socket_shutdown($sock,2);
1255 1255
 				@socket_close($sock);
1256
-			    }
1256
+				}
1257 1257
 			    
1258 1258
 			}
1259 1259
 			if ($globalDebug) echo "Restart all connections...";
@@ -1264,13 +1264,13 @@  discard block
 block discarded – undo
1264 1264
 			if ($reset > 40) exit('Too many attempts...');
1265 1265
 			connect_all($globalSources);
1266 1266
 		}
1267
-	    }
1267
+		}
1268 1268
 	}
1269 1269
 	if ($globalDaemon === false) {
1270
-	    if ($globalDebug) echo 'Check all...'."\n";
1271
-	    $SI->checkAll();
1270
+		if ($globalDebug) echo 'Check all...'."\n";
1271
+		$SI->checkAll();
1272
+	}
1272 1273
 	}
1273
-    }
1274 1274
 }
1275 1275
 
1276 1276
 ?>
Please login to merge, or discard this patch.
require/class.MarineLive.php 1 patch
Indentation   +187 added lines, -187 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 = '',$arrival_code = '',$arrival_date = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
772 772
 	{
773 773
 		global $globalURL, $globalArchive, $globalDebug;
@@ -838,9 +838,9 @@  discard block
 block discarded – undo
838 838
 		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
839 839
 		
840 840
 
841
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
842
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
843
-            	if ($arrival_date == '') $arrival_date = NULL;
841
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
842
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
843
+				if ($arrival_date == '') $arrival_date = NULL;
844 844
 		$query  = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
845 845
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)';
846 846
 
@@ -849,9 +849,9 @@  discard block
 block discarded – undo
849 849
 			
850 850
 			$sth = $this->db->prepare($query);
851 851
 			$sth->execute($query_values);
852
-                } catch(PDOException $e) {
853
-                	return "error : ".$e->getMessage();
854
-                }
852
+				} catch(PDOException $e) {
853
+					return "error : ".$e->getMessage();
854
+				}
855 855
 		/*
856 856
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
857 857
 		    if ($globalDebug) echo '(Add to SBS archive : ';
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Indentation   +196 added lines, -196 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 = '',$arrival_code = '',$arrival_date = '',$status = '',$format_source = '', $source_name = '')
576 576
 	{
577 577
 		global $globalURL;
@@ -659,13 +659,13 @@  discard block
 block discarded – undo
659 659
 		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
660 660
 		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
661 661
 	
662
-                if ($latitude == '' && $longitude == '') {
663
-            		$latitude = 0;
664
-            		$longitude = 0;
665
-            	}
666
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
667
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
668
-                if ($arrival_date == '') $arrival_date = NULL;
662
+				if ($latitude == '' && $longitude == '') {
663
+					$latitude = 0;
664
+					$longitude = 0;
665
+				}
666
+				if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
667
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
668
+				if ($arrival_date == '') $arrival_date = NULL;
669 669
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
670 670
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
671 671
 
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 			$sth->execute($query_values);
677 677
 			$this->db = null;
678 678
 		} catch (PDOException $e) {
679
-		    return "error : ".$e->getMessage();
679
+			return "error : ".$e->getMessage();
680 680
 		}
681 681
 		
682 682
 		return "success";
@@ -685,11 +685,11 @@  discard block
 block discarded – undo
685 685
 	
686 686
   
687 687
 	/**
688
-	* Gets the aircraft ident within the last hour
689
-	*
690
-	* @return String the ident
691
-	*
692
-	*/
688
+	 * Gets the aircraft ident within the last hour
689
+	 *
690
+	 * @return String the ident
691
+	 *
692
+	 */
693 693
 	public function getIdentFromLastHour($ident)
694 694
 	{
695 695
 		global $globalDBdriver, $globalTimezone;
@@ -705,11 +705,11 @@  discard block
 block discarded – undo
705 705
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
706 706
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
707 707
 			$query_data = array(':ident' => $ident);
708
-    		}
708
+			}
709 709
 		
710 710
 		$sth = $this->db->prepare($query);
711 711
 		$sth->execute($query_data);
712
-    		$ident_result='';
712
+			$ident_result='';
713 713
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
714 714
 		{
715 715
 			$ident_result = $row['ident'];
@@ -720,11 +720,11 @@  discard block
 block discarded – undo
720 720
 	
721 721
 	
722 722
 	/**
723
-	* Gets the aircraft data from the last 20 seconds
724
-	*
725
-	* @return Array the spotter data
726
-	*
727
-	*/
723
+	 * Gets the aircraft data from the last 20 seconds
724
+	 *
725
+	 * @return Array the spotter data
726
+	 *
727
+	 */
728 728
 	public function getRealTimeData($q = '')
729 729
 	{
730 730
 		global $globalDBdriver;
@@ -762,11 +762,11 @@  discard block
 block discarded – undo
762 762
 	
763 763
 
764 764
 	/**
765
-	* Gets all number of flight over countries
766
-	*
767
-	* @return Array the airline country list
768
-	*
769
-	*/
765
+	 * Gets all number of flight over countries
766
+	 *
767
+	 * @return Array the airline country list
768
+	 *
769
+	 */
770 770
 /*
771 771
 	public function countAllTrackedOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
772 772
 	{
@@ -817,11 +817,11 @@  discard block
 block discarded – undo
817 817
 	
818 818
 	
819 819
 	/**
820
-	* Gets all callsigns that have flown over
821
-	*
822
-	* @return Array the callsign list
823
-	*
824
-	*/
820
+	 * Gets all callsigns that have flown over
821
+	 *
822
+	 * @return Array the callsign list
823
+	 *
824
+	 */
825 825
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
826 826
 	{
827 827
 		global $globalDBdriver;
@@ -888,11 +888,11 @@  discard block
 block discarded – undo
888 888
 
889 889
 
890 890
 	/**
891
-	* Counts all dates
892
-	*
893
-	* @return Array the date list
894
-	*
895
-	*/
891
+	 * Counts all dates
892
+	 *
893
+	 * @return Array the date list
894
+	 *
895
+	 */
896 896
 	public function countAllDates($filters = array())
897 897
 	{
898 898
 		global $globalTimezone, $globalDBdriver;
@@ -938,11 +938,11 @@  discard block
 block discarded – undo
938 938
 	
939 939
 	
940 940
 	/**
941
-	* Counts all dates during the last 7 days
942
-	*
943
-	* @return Array the date list
944
-	*
945
-	*/
941
+	 * Counts all dates during the last 7 days
942
+	 *
943
+	 * @return Array the date list
944
+	 *
945
+	 */
946 946
 	public function countAllDatesLast7Days($filters = array())
947 947
 	{
948 948
 		global $globalTimezone, $globalDBdriver;
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 			$query .= " GROUP BY date_name 
965 965
 								ORDER BY date_name ASC";
966 966
 			$query_data = array(':offset' => $offset);
967
-    		}
967
+			}
968 968
 		
969 969
 		$sth = $this->db->prepare($query);
970 970
 		$sth->execute($query_data);
@@ -984,11 +984,11 @@  discard block
 block discarded – undo
984 984
 	}
985 985
 
986 986
 	/**
987
-	* Counts all dates during the last month
988
-	*
989
-	* @return Array the date list
990
-	*
991
-	*/
987
+	 * Counts all dates during the last month
988
+	 *
989
+	 * @return Array the date list
990
+	 *
991
+	 */
992 992
 	public function countAllDatesLastMonth($filters = array())
993 993
 	{
994 994
 		global $globalTimezone, $globalDBdriver;
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
 			$query .= " GROUP BY date_name 
1011 1011
 								ORDER BY date_name ASC";
1012 1012
 			$query_data = array(':offset' => $offset);
1013
-    		}
1013
+			}
1014 1014
 		
1015 1015
 		$sth = $this->db->prepare($query);
1016 1016
 		$sth->execute($query_data);
@@ -1032,11 +1032,11 @@  discard block
 block discarded – undo
1032 1032
 
1033 1033
 
1034 1034
 	/**
1035
-	* Counts all month
1036
-	*
1037
-	* @return Array the month list
1038
-	*
1039
-	*/
1035
+	 * Counts all month
1036
+	 *
1037
+	 * @return Array the month list
1038
+	 *
1039
+	 */
1040 1040
 	public function countAllMonths($filters = array())
1041 1041
 	{
1042 1042
 		global $globalTimezone, $globalDBdriver;
@@ -1081,11 +1081,11 @@  discard block
 block discarded – undo
1081 1081
 	
1082 1082
 
1083 1083
 	/**
1084
-	* Counts all dates during the last year
1085
-	*
1086
-	* @return Array the date list
1087
-	*
1088
-	*/
1084
+	 * Counts all dates during the last year
1085
+	 *
1086
+	 * @return Array the date list
1087
+	 *
1088
+	 */
1089 1089
 	public function countAllMonthsLastYear($filters)
1090 1090
 	{
1091 1091
 		global $globalTimezone, $globalDBdriver;
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
 			$query .= " GROUP BY year_name, month_name
1108 1108
 								ORDER BY year_name, month_name ASC";
1109 1109
 			$query_data = array(':offset' => $offset);
1110
-    		}
1110
+			}
1111 1111
 		
1112 1112
 		$sth = $this->db->prepare($query);
1113 1113
 		$sth->execute($query_data);
@@ -1130,11 +1130,11 @@  discard block
 block discarded – undo
1130 1130
 	
1131 1131
 	
1132 1132
 	/**
1133
-	* Counts all hours
1134
-	*
1135
-	* @return Array the hour list
1136
-	*
1137
-	*/
1133
+	 * Counts all hours
1134
+	 *
1135
+	 * @return Array the hour list
1136
+	 *
1137
+	 */
1138 1138
 	public function countAllHours($orderby,$filters = array())
1139 1139
 	{
1140 1140
 		global $globalTimezone, $globalDBdriver;
@@ -1197,11 +1197,11 @@  discard block
 block discarded – undo
1197 1197
 	
1198 1198
 	
1199 1199
 	/**
1200
-	* Counts all hours by date
1201
-	*
1202
-	* @return Array the hour list
1203
-	*
1204
-	*/
1200
+	 * Counts all hours by date
1201
+	 *
1202
+	 * @return Array the hour list
1203
+	 *
1204
+	 */
1205 1205
 	public function countAllHoursByDate($date, $filters = array())
1206 1206
 	{
1207 1207
 		global $globalTimezone, $globalDBdriver;
@@ -1245,11 +1245,11 @@  discard block
 block discarded – undo
1245 1245
 	
1246 1246
 	
1247 1247
 	/**
1248
-	* Counts all hours by a ident/callsign
1249
-	*
1250
-	* @return Array the hour list
1251
-	*
1252
-	*/
1248
+	 * Counts all hours by a ident/callsign
1249
+	 *
1250
+	 * @return Array the hour list
1251
+	 *
1252
+	 */
1253 1253
 	public function countAllHoursByIdent($ident, $filters = array())
1254 1254
 	{
1255 1255
 		global $globalTimezone, $globalDBdriver;
@@ -1294,11 +1294,11 @@  discard block
 block discarded – undo
1294 1294
 	
1295 1295
 	
1296 1296
 	/**
1297
-	* Counts all flights that have flown over
1298
-	*
1299
-	* @return Integer the number of flights
1300
-	*
1301
-	*/
1297
+	 * Counts all flights that have flown over
1298
+	 *
1299
+	 * @return Integer the number of flights
1300
+	 *
1301
+	 */
1302 1302
 	public function countOverallTracked($filters = array(),$year = '',$month = '')
1303 1303
 	{
1304 1304
 		global $globalDBdriver;
@@ -1333,11 +1333,11 @@  discard block
 block discarded – undo
1333 1333
 	
1334 1334
   
1335 1335
 	/**
1336
-	* Counts all hours of today
1337
-	*
1338
-	* @return Array the hour list
1339
-	*
1340
-	*/
1336
+	 * Counts all hours of today
1337
+	 *
1338
+	 * @return Array the hour list
1339
+	 *
1340
+	 */
1341 1341
 	public function countAllHoursFromToday($filters = array())
1342 1342
 	{
1343 1343
 		global $globalTimezone, $globalDBdriver;
@@ -1377,12 +1377,12 @@  discard block
 block discarded – undo
1377 1377
 	}
1378 1378
     
1379 1379
     
1380
-     /**
1381
-	* Gets the Barrie Spotter ID based on the FlightAware ID
1382
-	*
1383
-	* @return Integer the Barrie Spotter ID
1380
+	 /**
1381
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
1382
+	  *
1383
+	  * @return Integer the Barrie Spotter ID
1384 1384
 q	*
1385
-	*/
1385
+	  */
1386 1386
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1387 1387
 	{
1388 1388
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -1403,13 +1403,13 @@  discard block
 block discarded – undo
1403 1403
   
1404 1404
  
1405 1405
 	/**
1406
-	* Parses a date string
1407
-	*
1408
-	* @param String $dateString the date string
1409
-	* @param String $timezone the timezone of a user
1410
-	* @return Array the time information
1411
-	*
1412
-	*/
1406
+	 * Parses a date string
1407
+	 *
1408
+	 * @param String $dateString the date string
1409
+	 * @param String $timezone the timezone of a user
1410
+	 * @return Array the time information
1411
+	 *
1412
+	 */
1413 1413
 	public function parseDateString($dateString, $timezone = '')
1414 1414
 	{
1415 1415
 		$time_array = array();
@@ -1442,12 +1442,12 @@  discard block
 block discarded – undo
1442 1442
 	}
1443 1443
 	
1444 1444
 	/**
1445
-	* Parses the direction degrees to working
1446
-	*
1447
-	* @param Float $direction the direction in degrees
1448
-	* @return Array the direction information
1449
-	*
1450
-	*/
1445
+	 * Parses the direction degrees to working
1446
+	 *
1447
+	 * @param Float $direction the direction in degrees
1448
+	 * @return Array the direction information
1449
+	 *
1450
+	 */
1451 1451
 	public function parseDirection($direction = 0)
1452 1452
 	{
1453 1453
 		if ($direction == '') $direction = 0;
@@ -1526,12 +1526,12 @@  discard block
 block discarded – undo
1526 1526
 	
1527 1527
 	
1528 1528
 	/**
1529
-	* Gets Country from latitude/longitude
1530
-	*
1531
-	* @param Float $latitude latitute of the flight
1532
-	* @param Float $longitude longitute of the flight
1533
-	* @return String the countrie
1534
-	*/
1529
+	 * Gets Country from latitude/longitude
1530
+	 *
1531
+	 * @param Float $latitude latitute of the flight
1532
+	 * @param Float $longitude longitute of the flight
1533
+	 * @return String the countrie
1534
+	 */
1535 1535
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1536 1536
 	{
1537 1537
 		global $globalDBdriver, $globalDebug;
@@ -1568,11 +1568,11 @@  discard block
 block discarded – undo
1568 1568
 	}
1569 1569
 
1570 1570
 	/**
1571
-	* Gets Country from iso2
1572
-	*
1573
-	* @param String $iso2 ISO2 country code
1574
-	* @return String the countrie
1575
-	*/
1571
+	 * Gets Country from iso2
1572
+	 *
1573
+	 * @param String $iso2 ISO2 country code
1574
+	 * @return String the countrie
1575
+	 */
1576 1576
 	public function getCountryFromISO2($iso2)
1577 1577
 	{
1578 1578
 		global $globalDBdriver, $globalDebug;
@@ -1601,12 +1601,12 @@  discard block
 block discarded – undo
1601 1601
 
1602 1602
 	
1603 1603
 	/**
1604
-	* Gets the short url from bit.ly
1605
-	*
1606
-	* @param String $url the full url
1607
-	* @return String the bit.ly url
1608
-	*
1609
-	*/
1604
+	 * Gets the short url from bit.ly
1605
+	 *
1606
+	 * @param String $url the full url
1607
+	 * @return String the bit.ly url
1608
+	 *
1609
+	 */
1610 1610
 	public function getBitlyURL($url)
1611 1611
 	{
1612 1612
 		global $globalBitlyAccessToken;
Please login to merge, or discard this patch.
require/class.MarineImport.php 1 patch
Indentation   +150 added lines, -150 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,84 +109,84 @@  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' => '','arrival_code' => '','arrival_date' => ''));
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' => '','arrival_code' => '','arrival_date' => ''));
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
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
149
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
149
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
150 150
 		}
151 151
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
152
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
152
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
153 153
 		}
154 154
 
155 155
 
156 156
 		//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'])) {
157 157
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
158
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
159
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
158
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
159
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
160 160
 			$timeelapsed = microtime(true);
161
-            		$Marine = new Marine($this->db);
162
-            		$fromsource = NULL;
163
-            		$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
161
+					$Marine = new Marine($this->db);
162
+					$fromsource = NULL;
163
+					$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
164 164
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
165 165
 			$Marine->db = null;
166 166
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
167
-		    }
168
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
167
+			}
168
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
169 169
 		}
170 170
 
171 171
 		if (isset($line['speed']) && $line['speed'] != '') {
172
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
173
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
172
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
173
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
174 174
 		} 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'])) {
175
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
176
-		    if ($distance > 1000 && $distance < 10000) {
175
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
176
+			if ($distance > 1000 && $distance < 10000) {
177 177
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
178 178
 			$speed = $speed*3.6;
179 179
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
180 180
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
181
-		    }
181
+			}
182 182
 		}
183 183
 
184
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
185
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
186
-	    	    else unset($timediff);
187
-	    	    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')))) {
184
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
185
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
186
+				else unset($timediff);
187
+				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')))) {
188 188
 			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'])) {
189
-			    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'])) {
189
+				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'])) {
190 190
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
191 191
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
192 192
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -200,76 +200,76 @@  discard block
 block discarded – undo
200 200
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
201 201
 				$this->tmd = 0;
202 202
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
203
-			    }
203
+				}
204 204
 			}
205 205
 
206 206
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
207 207
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
208 208
 				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') {
209
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
210
-				    $dataFound = true;
211
-				    $this->all_tracked[$id]['time_last_coord'] = time();
209
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
210
+					$dataFound = true;
211
+					$this->all_tracked[$id]['time_last_coord'] = time();
212 212
 				}
213 213
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
214 214
 			}
215 215
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
216
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
216
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
217 217
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
218 218
 				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') {
219
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
220
-				    $dataFound = true;
221
-				    $this->all_tracked[$id]['time_last_coord'] = time();
219
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
220
+					$dataFound = true;
221
+					$this->all_tracked[$id]['time_last_coord'] = time();
222 222
 				}
223 223
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
224 224
 			}
225 225
 
226
-		    } else if ($globalDebug && $timediff > 20) {
226
+			} else if ($globalDebug && $timediff > 20) {
227 227
 			$this->tmd = $this->tmd + 1;
228 228
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
229 229
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
230 230
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
231 231
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
232
-		    }
232
+			}
233 233
 		}
234 234
 		if (isset($line['last_update']) && $line['last_update'] != '') {
235
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
235
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
236
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
237 237
 		}
238 238
 		if (isset($line['format_source']) && $line['format_source'] != '') {
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
239
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
240 240
 		}
241 241
 		if (isset($line['source_name']) && $line['source_name'] != '') {
242
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
242
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
243 243
 		}
244 244
 		if (isset($line['status']) && $line['status'] != '') {
245
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
245
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
246 246
 		}
247 247
 
248 248
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
249
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
249
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
250 250
 		}
251 251
 		
252 252
 		if (isset($line['heading']) && $line['heading'] != '') {
253
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
254
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
255
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
256
-		    //$dataFound = true;
253
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
254
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
255
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
256
+			//$dataFound = true;
257 257
   		} 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']) {
258
-  		    $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']);
259
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
260
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
261
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
258
+  			$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']);
259
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
260
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
261
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
262 262
   		}
263 263
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
264 264
 
265 265
 		if (isset($line['datetime'])) {
266
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
266
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
267 267
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
268
-		    } else {
268
+			} else {
269 269
 				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";
270 270
 				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";
271 271
 				return '';
272
-		    }
272
+			}
273 273
 		} else {
274 274
 			date_default_timezone_set('UTC');
275 275
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -277,45 +277,45 @@  discard block
 block discarded – undo
277 277
 
278 278
 
279 279
 		if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) {
280
-		    $this->all_tracked[$id]['lastupdate'] = time();
281
-		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
282
-		        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'])) {
283
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
280
+			$this->all_tracked[$id]['lastupdate'] = time();
281
+			if ($this->all_tracked[$id]['addedMarine'] == 0) {
282
+				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'])) {
283
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
284 284
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
285 285
 				$timeelapsed = microtime(true);
286 286
 				$MarineLive = new MarineLive($this->db);
287 287
 				if (isset($line['id'])) {
288
-				    $recent_ident = $MarineLive->checkIdRecent($line['id']);
289
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
288
+					$recent_ident = $MarineLive->checkIdRecent($line['id']);
289
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
290 290
 				} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
291
-				    $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
292
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
291
+					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
292
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
293 293
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
294
-				    $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
295
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
294
+					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
295
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
296 296
 				} else $recent_ident = '';
297 297
 				$MarineLive->db=null;
298 298
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
299 299
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
300
-			    } else {
300
+				} else {
301 301
 				$recent_ident = '';
302 302
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
303
-			    }
304
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
305
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
306
-			    {
303
+				}
304
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
305
+				if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
306
+				{
307 307
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
308 308
 				//adds the spotter data for the archive
309
-				    $highlight = '';
310
-				    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')));
311
-				    $timeelapsed = microtime(true);
312
-				    $Marine = new Marine($this->db);
313
-				    $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]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
314
-				    $Marine->db = null;
315
-				    if ($globalDebug && isset($result)) echo $result."\n";
316
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
309
+					$highlight = '';
310
+					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')));
311
+					$timeelapsed = microtime(true);
312
+					$Marine = new Marine($this->db);
313
+					$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]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
314
+					$Marine->db = null;
315
+					if ($globalDebug && isset($result)) echo $result."\n";
316
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
317 317
 				    
318
-				    /*
318
+					/*
319 319
 				    // Add source stat in DB
320 320
 				    $Stats = new Stats($this->db);
321 321
 				    if (!empty($this->stats)) {
@@ -342,20 +342,20 @@  discard block
 block discarded – undo
342 342
 				    }
343 343
 				    $Stats->db = null;
344 344
 				    */
345
-				    $this->del();
345
+					$this->del();
346 346
 				//$ignoreImport = false;
347 347
 				$this->all_tracked[$id]['addedMarine'] = 1;
348 348
 				//print_r($this->all_tracked[$id]);
349 349
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
350
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
351
-				    //MarineLive->deleteLiveMarineDataNotUpdated();
352
-				    $MarineLive = new MarineLive($this->db);
353
-				    $MarineLive->deleteLiveMarineData();
354
-				    $MarineLive->db=null;
355
-				    if ($globalDebug) echo " Done\n";
356
-				    $this->last_delete = time();
350
+					if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
351
+					//MarineLive->deleteLiveMarineDataNotUpdated();
352
+					$MarineLive = new MarineLive($this->db);
353
+					$MarineLive->deleteLiveMarineData();
354
+					$MarineLive->db=null;
355
+					if ($globalDebug) echo " Done\n";
356
+					$this->last_delete = time();
357 357
 				}
358
-			    } elseif ($recent_ident != '') {
358
+				} elseif ($recent_ident != '') {
359 359
 				$this->all_tracked[$id]['id'] = $recent_ident;
360 360
 				$this->all_tracked[$id]['addedMarine'] = 1;
361 361
 				if (isset($globalDaemon) && !$globalDaemon) {
@@ -364,16 +364,16 @@  discard block
 block discarded – undo
364 364
 					$Marine->db = null;
365 365
 				}
366 366
 				
367
-			    }
367
+				}
368
+			}
368 369
 			}
369
-		    }
370
-		    //adds the spotter LIVE data
371
-		    if ($globalDebug) {
370
+			//adds the spotter LIVE data
371
+			if ($globalDebug) {
372 372
 			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";
373
-		    }
374
-		    $ignoreImport = false;
373
+			}
374
+			$ignoreImport = false;
375 375
 
376
-		    if (!$ignoreImport) {
376
+			if (!$ignoreImport) {
377 377
 			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'])) {
378 378
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
379 379
 				$timeelapsed = microtime(true);
@@ -445,22 +445,22 @@  discard block
 block discarded – undo
445 445
 			
446 446
 			
447 447
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
448
-			    if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
449
-			    $MarineLive = new MarineLive($this->db);
450
-			    $MarineLive->deleteLiveMarineDataNotUpdated();
451
-			    $MarineLive->db = null;
452
-			    //MarineLive->deleteLiveMarineData();
453
-			    if ($globalDebug) echo " Done\n";
454
-			    $this->last_delete_hourly = time();
448
+				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
449
+				$MarineLive = new MarineLive($this->db);
450
+				$MarineLive->deleteLiveMarineDataNotUpdated();
451
+				$MarineLive->db = null;
452
+				//MarineLive->deleteLiveMarineData();
453
+				if ($globalDebug) echo " Done\n";
454
+				$this->last_delete_hourly = time();
455 455
 			}
456 456
 			
457
-		    }
458
-		    //$ignoreImport = false;
457
+			}
458
+			//$ignoreImport = false;
459 459
 		}
460 460
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
461 461
 		if ($send) return $this->all_tracked[$id];
462
-	    }
462
+		}
463
+	}
463 464
 	}
464
-    }
465 465
 }
466 466
 ?>
Please login to merge, or discard this patch.
require/class.AIS.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		return ($dec);
58 58
 	}
59 59
 	
60
-    /*
60
+	/*
61 61
     $ais_map64 = array(
62 62
        '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', // 48
63 63
        ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C',
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
 		//  ' ' --- '?', // 0x20 - 0x3F
98 98
 		//  '@' --- '_', // 0x40 - 0x5F
99 99
 		$ais_chars = array(
100
-		    '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
101
-		    'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
102
-		    'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']',
103
-		    '^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'',
104
-		    '(', ')', '*', '+', ',', '-', '.', '/', '0', '1',
105
-		    '2', '3', '4', '5', '6', '7', '8', '9', ':', ';',
106
-		    '<', '=', '>', '?'
100
+			'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
101
+			'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
102
+			'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']',
103
+			'^', '_', ' ', '!', '\"', '#', '$', '%', '&', '\'',
104
+			'(', ')', '*', '+', ',', '-', '.', '/', '0', '1',
105
+			'2', '3', '4', '5', '6', '7', '8', '9', ':', ';',
106
+			'<', '=', '>', '?'
107 107
 		);
108 108
 		// "
109 109
 		$rv = '';
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
 				}
420 420
 				if ($num_seq > 1) { // for multipart messages
421 421
 					if ($cmsg_sid != $msg_sid // different msg_sid
422
-					    || $msg_sid == -1 // invalid initial msg_sid
423
-					    || ($seq - $pseq) != 1 // not insequence
422
+						|| $msg_sid == -1 // invalid initial msg_sid
423
+						|| ($seq - $pseq) != 1 // not insequence
424 424
 					) {  // invalid for multipart message
425 425
 						$msg_sid = -1;
426 426
 						$cmsg_sid = -1;
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 				$itu = $itu.$pcs[5]; // get itu message
434 434
 				$filler += (int)$pcs[6][0]; // get filler
435 435
 				if ($num_seq == 1 // valid single message
436
-				    || $num_seq == $pseq // valid multi-part message
436
+					|| $num_seq == $pseq // valid multi-part message
437 437
 				) {
438 438
 					if ($num_seq != 1) { // test
439 439
 						//echo $rawdata;
@@ -516,13 +516,13 @@  discard block
 block discarded – undo
516 516
 		else $pad = '';
517 517
 		$rv = '';
518 518
 		$ais_chars = array(
519
-		    '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
520
-		    'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19,
521
-		    'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29,
522
-		    '^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39,
523
-		    '('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49,
524
-		    '2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59,
525
-		    '<'=>60, '='=>61, '>'=>62, '?'=>63
519
+			'@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
520
+			'J'=>10, 'K'=>11, 'L'=>12, 'M'=>13, 'N'=>14, 'O'=>15, 'P'=>16, 'Q'=>17, 'R'=>18, 'S'=>19,
521
+			'T'=>20, 'U'=>21, 'V'=>22, 'W'=>23, 'X'=>24, 'Y'=>25, 'Z'=>26, '['=>27, '\\'=>28, ']'=>29,
522
+			'^'=>30, '_'=>31, ' '=>32, '!'=>33, '\"'=>34, '#'=>35, '$'=>36, '%'=>37, '&'=>38, '\''=>39,
523
+			'('=>40, ')'=>41, '*'=>42, '+'=>43, ','=>44, '-'=>45, '.'=>46, '/'=>47, '0'=>48, '1'=>49,
524
+			'2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57, ':'=>58, ';'=>59,
525
+			'<'=>60, '='=>61, '>'=>62, '?'=>63
526 526
 		);
527 527
 		// "
528 528
 		$_a = str_split($name);
Please login to merge, or discard this patch.