Completed
Push — master ( 157d06...e82944 )
by Yannick
08:43
created
scripts/daemon-spotter.php 3 patches
Indentation   +904 added lines, -904 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,42 +25,42 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->latest() === false) {
28
-    echo "You MUST update to latest schema. Run install/index.php";
29
-    exit();
28
+	echo "You MUST update to latest schema. Run install/index.php";
29
+	exit();
30 30
 }
31 31
 if (PHP_SAPI != 'cli') {
32
-    echo "This script MUST be called from console, not a web browser.";
32
+	echo "This script MUST be called from console, not a web browser.";
33 33
 //    exit();
34 34
 }
35 35
 
36 36
 // This is to be compatible with old version of settings.php
37 37
 if (!isset($globalSources)) {
38
-    if (isset($globalSBS1Hosts)) {
39
-        //$hosts = $globalSBS1Hosts;
40
-        foreach ($globalSBS1Hosts as $host) {
41
-	    $globalSources[] = array('host' => $host);
42
-    	}
43
-    } else {
44
-        if (!isset($globalSBS1Host)) {
45
-	    echo '$globalSources MUST be defined !';
46
-	    die;
38
+	if (isset($globalSBS1Hosts)) {
39
+		//$hosts = $globalSBS1Hosts;
40
+		foreach ($globalSBS1Hosts as $host) {
41
+		$globalSources[] = array('host' => $host);
42
+		}
43
+	} else {
44
+		if (!isset($globalSBS1Host)) {
45
+		echo '$globalSources MUST be defined !';
46
+		die;
47 47
 	}
48 48
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
49 49
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
50
-    }
50
+	}
51 51
 }
52 52
 
53 53
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
54 54
 //if (isset($options['s'])) $hosts = array($options['s']);
55 55
 //elseif (isset($options['source'])) $hosts = array($options['source']);
56 56
 if (isset($options['s'])) {
57
-    $globalSources = array();
58
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
59
-    else $globalSources[] = array('host' => $options['s']);
57
+	$globalSources = array();
58
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
59
+	else $globalSources[] = array('host' => $options['s']);
60 60
 } elseif (isset($options['source'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['source']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['source']);
64 64
 }
65 65
 if (isset($options['aprsserverhost'])) {
66 66
 	$globalServerAPRS = TRUE;
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 if (isset($options['idsource'])) $id_source = $options['idsource'];
76 76
 else $id_source = 1;
77 77
 if (isset($globalServer) && $globalServer) {
78
-    if ($globalDebug) echo "Using Server Mode\n";
79
-    $SI=new SpotterServer();
78
+	if ($globalDebug) echo "Using Server Mode\n";
79
+	$SI=new SpotterServer();
80 80
 /*
81 81
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
82 82
     $SI = new adsb2aprs();
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 } else $SI=new SpotterImport($Connection->db);
86 86
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
87 87
 if (isset($globalMarine) && $globalMarine) {
88
-    $AIS = new AIS();
89
-    $MI = new MarineImport($Connection->db);
88
+	$AIS = new AIS();
89
+	$MI = new MarineImport($Connection->db);
90 90
 }
91 91
 //$APRS=new APRS($Connection->db);
92 92
 $SBS=new SBS();
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 //$servertz = system('date +%Z');
98 98
 // signal handler - playing nice with sockets and dump1090
99 99
 if (function_exists('pcntl_fork')) {
100
-    pcntl_signal(SIGINT,  function() {
101
-        global $sockets;
102
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
103
-        die("Bye!\n");
104
-    });
105
-    pcntl_signal_dispatch();
100
+	pcntl_signal(SIGINT,  function() {
101
+		global $sockets;
102
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
103
+		die("Bye!\n");
104
+	});
105
+	pcntl_signal_dispatch();
106 106
 }
107 107
 
108 108
 // let's try and connect
@@ -112,36 +112,36 @@  discard block
 block discarded – undo
112 112
 $reset = 0;
113 113
 
114 114
 function connect_all($hosts) {
115
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
117
-    $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
119
-    foreach ($hosts as $id => $value) {
115
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
117
+	$reset++;
118
+	if ($globalDebug) echo 'Connect to all...'."\n";
119
+	foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123 123
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
125
-        	//$formats[$id] = 'deltadbtxt';
126
-        	$globalSources[$id]['format'] = 'deltadbtxt';
127
-        	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
-        	//$formats[$id] = 'vatsimtxt';
131
-        	$globalSources[$id]['format'] = 'vatsimtxt';
132
-        	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135
-        	//$formats[$id] = 'aircraftlistjson';
136
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
137
-        	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
140
-        	//$formats[$id] = 'aircraftlistjson';
141
-        	$globalSources[$id]['format'] = 'opensky';
142
-        	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
-    	    /*
124
+			if (preg_match('/deltadb.txt$/i',$host)) {
125
+			//$formats[$id] = 'deltadbtxt';
126
+			$globalSources[$id]['format'] = 'deltadbtxt';
127
+			//$last_exec['deltadbtxt'] = 0;
128
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
130
+			//$formats[$id] = 'vatsimtxt';
131
+			$globalSources[$id]['format'] = 'vatsimtxt';
132
+			//$last_exec['vatsimtxt'] = 0;
133
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
135
+			//$formats[$id] = 'aircraftlistjson';
136
+			$globalSources[$id]['format'] = 'aircraftlistjson';
137
+			//$last_exec['aircraftlistjson'] = 0;
138
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
+			} else if (preg_match('/opensky/i',$host)) {
140
+			//$formats[$id] = 'aircraftlistjson';
141
+			$globalSources[$id]['format'] = 'opensky';
142
+			//$last_exec['aircraftlistjson'] = 0;
143
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
144
+			/*
145 145
     	    // Disabled for now, site change source format
146 146
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
147 147
         	//$formats[$id] = 'radarvirtueljson';
@@ -153,118 +153,118 @@  discard block
 block discarded – undo
153 153
         	    exit(0);
154 154
         	}
155 155
     	    */
156
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
157
-        	//$formats[$id] = 'planeupdatefaa';
158
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
159
-        	//$last_exec['planeupdatefaa'] = 0;
160
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
161
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
162
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163
-        	    exit(0);
164
-        	}
165
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
166
-        	//$formats[$id] = 'phpvmacars';
167
-        	$globalSources[$id]['format'] = 'phpvmacars';
168
-        	//$last_exec['phpvmacars'] = 0;
169
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
170
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
171
-        	//$formats[$id] = 'phpvmacars';
172
-        	$globalSources[$id]['format'] = 'vam';
173
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
174
-            } else if (preg_match('/whazzup/i',$host)) {
175
-        	//$formats[$id] = 'whazzup';
176
-        	$globalSources[$id]['format'] = 'whazzup';
177
-        	//$last_exec['whazzup'] = 0;
178
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
179
-            } else if (preg_match('/airwhere/i',$host)) {
180
-        	$globalSources[$id]['format'] = 'airwhere';
181
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
182
-            } else if (preg_match('/recentpireps/i',$host)) {
183
-        	//$formats[$id] = 'pirepsjson';
184
-        	$globalSources[$id]['format'] = 'pirepsjson';
185
-        	//$last_exec['pirepsjson'] = 0;
186
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
187
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
188
-        	//$formats[$id] = 'fr24json';
189
-        	$globalSources[$id]['format'] = 'fr24json';
190
-        	//$last_exec['fr24json'] = 0;
191
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
192
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
193
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
194
-        	    exit(0);
195
-        	}
196
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
197
-        	//$formats[$id] = 'fr24json';
198
-        	$globalSources[$id]['format'] = 'myshiptracking';
199
-        	//$last_exec['fr24json'] = 0;
200
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
201
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
202
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
203
-        	    exit(0);
204
-        	}
205
-            //} else if (preg_match('/10001/',$host)) {
206
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
207
-        	//$formats[$id] = 'tsv';
208
-        	$globalSources[$id]['format'] = 'tsv';
209
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
210
-            }
211
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
212
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
213
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
214
-    		    if ($idf !== false) {
215
-    			$httpfeeds[$id] = $idf;
216
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
217
-    		    }
218
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
219
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
220
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
221
-	    $hostport = explode(':',$host);
222
-	    if (isset($hostport[1])) {
156
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
157
+			//$formats[$id] = 'planeupdatefaa';
158
+			$globalSources[$id]['format'] = 'planeupdatefaa';
159
+			//$last_exec['planeupdatefaa'] = 0;
160
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
161
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
162
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163
+				exit(0);
164
+			}
165
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
166
+			//$formats[$id] = 'phpvmacars';
167
+			$globalSources[$id]['format'] = 'phpvmacars';
168
+			//$last_exec['phpvmacars'] = 0;
169
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
170
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
171
+			//$formats[$id] = 'phpvmacars';
172
+			$globalSources[$id]['format'] = 'vam';
173
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
174
+			} else if (preg_match('/whazzup/i',$host)) {
175
+			//$formats[$id] = 'whazzup';
176
+			$globalSources[$id]['format'] = 'whazzup';
177
+			//$last_exec['whazzup'] = 0;
178
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
179
+			} else if (preg_match('/airwhere/i',$host)) {
180
+			$globalSources[$id]['format'] = 'airwhere';
181
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
182
+			} else if (preg_match('/recentpireps/i',$host)) {
183
+			//$formats[$id] = 'pirepsjson';
184
+			$globalSources[$id]['format'] = 'pirepsjson';
185
+			//$last_exec['pirepsjson'] = 0;
186
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
187
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
188
+			//$formats[$id] = 'fr24json';
189
+			$globalSources[$id]['format'] = 'fr24json';
190
+			//$last_exec['fr24json'] = 0;
191
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
192
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
193
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
194
+				exit(0);
195
+			}
196
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
197
+			//$formats[$id] = 'fr24json';
198
+			$globalSources[$id]['format'] = 'myshiptracking';
199
+			//$last_exec['fr24json'] = 0;
200
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
201
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
202
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
203
+				exit(0);
204
+			}
205
+			//} else if (preg_match('/10001/',$host)) {
206
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
207
+			//$formats[$id] = 'tsv';
208
+			$globalSources[$id]['format'] = 'tsv';
209
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
210
+			}
211
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
212
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
213
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
214
+				if ($idf !== false) {
215
+				$httpfeeds[$id] = $idf;
216
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
217
+				}
218
+				elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
219
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
220
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
221
+		$hostport = explode(':',$host);
222
+		if (isset($hostport[1])) {
223 223
 		$port = $hostport[1];
224 224
 		$hostn = $hostport[0];
225
-	    } else {
225
+		} else {
226 226
 		$port = $globalSources[$id]['port'];
227 227
 		$hostn = $globalSources[$id]['host'];
228
-	    }
229
-	    $Common = new Common();
230
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
231
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
232
-    	    } else {
233
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
234
-	    }
235
-	    if ($s) {
236
-    	        $sockets[$id] = $s;
237
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
238
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
228
+		}
229
+		$Common = new Common();
230
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
231
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
232
+			} else {
233
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
234
+		}
235
+		if ($s) {
236
+				$sockets[$id] = $s;
237
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
238
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
239 239
 			//$formats[$id] = 'aprs';
240 240
 			$globalSources[$id]['format'] = 'aprs';
241 241
 			//$aprs_connect = 0;
242 242
 			//$use_aprs = true;
243
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
243
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
244 244
 			$globalSources[$id]['format'] = 'vrstcp';
245
-    		    } elseif ($port == '10001') {
246
-        		//$formats[$id] = 'tsv';
247
-        		$globalSources[$id]['format'] = 'tsv';
248
-		    } elseif ($port == '30002') {
249
-        		//$formats[$id] = 'raw';
250
-        		$globalSources[$id]['format'] = 'raw';
251
-		    } elseif ($port == '5001') {
252
-        		//$formats[$id] = 'raw';
253
-        		$globalSources[$id]['format'] = 'flightgearmp';
254
-		    } elseif ($port == '30005') {
245
+				} elseif ($port == '10001') {
246
+				//$formats[$id] = 'tsv';
247
+				$globalSources[$id]['format'] = 'tsv';
248
+			} elseif ($port == '30002') {
249
+				//$formats[$id] = 'raw';
250
+				$globalSources[$id]['format'] = 'raw';
251
+			} elseif ($port == '5001') {
252
+				//$formats[$id] = 'raw';
253
+				$globalSources[$id]['format'] = 'flightgearmp';
254
+			} elseif ($port == '30005') {
255 255
 			// Not yet supported
256
-        		//$formats[$id] = 'beast';
257
-        		$globalSources[$id]['format'] = 'beast';
258
-		    //} else $formats[$id] = 'sbs';
259
-		    } else $globalSources[$id]['format'] = 'sbs';
260
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
256
+				//$formats[$id] = 'beast';
257
+				$globalSources[$id]['format'] = 'beast';
258
+			//} else $formats[$id] = 'sbs';
259
+			} else $globalSources[$id]['format'] = 'sbs';
260
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
261 261
 		}
262 262
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
263
-            } else {
263
+			} else {
264 264
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
265
-    	    }
266
-        }
267
-    }
265
+			}
266
+		}
267
+	}
268 268
 }
269 269
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
270 270
 
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 //connect_all($globalSources);
288 288
 
289 289
 if (isset($globalProxy) && $globalProxy) {
290
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
290
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
291 291
 } else {
292
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
292
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
293 293
 }
294 294
 
295 295
 // APRS Configuration
@@ -298,18 +298,18 @@  discard block
 block discarded – undo
298 298
 	die;
299 299
 }
300 300
 foreach ($globalSources as $key => $source) {
301
-    if (!isset($source['format'])) {
302
-        $globalSources[$key]['format'] = 'auto';
303
-    }
301
+	if (!isset($source['format'])) {
302
+		$globalSources[$key]['format'] = 'auto';
303
+	}
304 304
 }
305 305
 connect_all($globalSources);
306 306
 foreach ($globalSources as $key => $source) {
307
-    if (isset($source['format']) && $source['format'] == 'aprs') {
307
+	if (isset($source['format']) && $source['format'] == 'aprs') {
308 308
 	$aprs_connect = 0;
309 309
 	$use_aprs = true;
310 310
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
311 311
 	break;
312
-    }
312
+	}
313 313
 }
314 314
 
315 315
 if ($use_aprs) {
@@ -350,115 +350,115 @@  discard block
 block discarded – undo
350 350
 
351 351
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
352 352
 while ($i > 0) {
353
-    if (!$globalDaemon) $i = $endtime-time();
354
-    // Delete old ATC
355
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
353
+	if (!$globalDaemon) $i = $endtime-time();
354
+	// Delete old ATC
355
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
356 356
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
357
-        $ATC->deleteOldATC();
358
-    }
357
+		$ATC->deleteOldATC();
358
+	}
359 359
     
360
-    if (count($last_exec) == count($globalSources)) {
360
+	if (count($last_exec) == count($globalSources)) {
361 361
 	$max = $globalMinFetch;
362 362
 	foreach ($last_exec as $last) {
363
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
363
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
364 364
 	}
365 365
 	if ($max != $globalMinFetch) {
366
-	    if ($globalDebug) echo 'Sleeping...'."\n";
367
-	    sleep($globalMinFetch-$max+2);
366
+		if ($globalDebug) echo 'Sleeping...'."\n";
367
+		sleep($globalMinFetch-$max+2);
368
+	}
368 369
 	}
369
-    }
370 370
 
371 371
     
372
-    //foreach ($formats as $id => $value) {
373
-    foreach ($globalSources as $id => $value) {
372
+	//foreach ($formats as $id => $value) {
373
+	foreach ($globalSources as $id => $value) {
374 374
 	date_default_timezone_set('UTC');
375 375
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
376 376
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
377
-	    //$buffer = $Common->getData($hosts[$id]);
378
-	    $buffer = $Common->getData($value['host']);
379
-	    if ($buffer != '') $reset = 0;
380
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
381
-	    $buffer = explode('\n',$buffer);
382
-	    foreach ($buffer as $line) {
383
-    		if ($line != '' && count($line) > 7) {
384
-    		    $line = explode(',', $line);
385
-	            $data = array();
386
-	            $data['hex'] = $line[1]; // hex
387
-	            $data['ident'] = $line[2]; // ident
388
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
389
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
390
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
391
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
392
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
393
-	            $data['verticalrate'] = ''; // vertical rate
394
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
395
-	            $data['emergency'] = ''; // emergency
396
-		    $data['datetime'] = date('Y-m-d H:i:s');
397
-		    $data['format_source'] = 'deltadbtxt';
398
-    		    $data['id_source'] = $id_source;
399
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
400
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
401
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
402
-    		    $SI->add($data);
403
-		    unset($data);
404
-    		}
405
-    	    }
406
-    	    $last_exec[$id]['last'] = time();
377
+		//$buffer = $Common->getData($hosts[$id]);
378
+		$buffer = $Common->getData($value['host']);
379
+		if ($buffer != '') $reset = 0;
380
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
381
+		$buffer = explode('\n',$buffer);
382
+		foreach ($buffer as $line) {
383
+			if ($line != '' && count($line) > 7) {
384
+				$line = explode(',', $line);
385
+				$data = array();
386
+				$data['hex'] = $line[1]; // hex
387
+				$data['ident'] = $line[2]; // ident
388
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
389
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
390
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
391
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
392
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
393
+				$data['verticalrate'] = ''; // vertical rate
394
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
395
+				$data['emergency'] = ''; // emergency
396
+			$data['datetime'] = date('Y-m-d H:i:s');
397
+			$data['format_source'] = 'deltadbtxt';
398
+				$data['id_source'] = $id_source;
399
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
400
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
401
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
402
+				$SI->add($data);
403
+			unset($data);
404
+			}
405
+			}
406
+			$last_exec[$id]['last'] = time();
407 407
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
408
-	    date_default_timezone_set('CET');
409
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
410
-	    date_default_timezone_set('UTC');
411
-	    if ($buffer != '') $reset = 0;
412
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
413
-	    $buffer = explode('\n',$buffer);
414
-	    foreach ($buffer as $line) {
408
+		date_default_timezone_set('CET');
409
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
410
+		date_default_timezone_set('UTC');
411
+		if ($buffer != '') $reset = 0;
412
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
413
+		$buffer = explode('\n',$buffer);
414
+		foreach ($buffer as $line) {
415 415
 		if ($line != '') {
416
-		    //echo "'".$line."'\n";
417
-		    $add = false;
418
-		    $ais_data = $AIS->parse_line(trim($line));
419
-		    $data = array();
420
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
421
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
422
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
423
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
424
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
425
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
426
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
427
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
428
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
429
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
430
-		    if (isset($ais_data['timestamp'])) {
416
+			//echo "'".$line."'\n";
417
+			$add = false;
418
+			$ais_data = $AIS->parse_line(trim($line));
419
+			$data = array();
420
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
421
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
422
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
423
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
424
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
425
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
426
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
427
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
428
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
429
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
430
+			if (isset($ais_data['timestamp'])) {
431 431
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
432 432
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
433
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
434
-			    $add = true;
433
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
434
+				$add = true;
435 435
 			}
436
-		    } else {
436
+			} else {
437 437
 			$data['datetime'] = date('Y-m-d H:i:s');
438 438
 			$add = true;
439
-		    }
440
-		    $data['format_source'] = 'aisnmeatxt';
441
-    		    $data['id_source'] = $id_source;
442
-		    //print_r($data);
443
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
444
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
445
-		    unset($data);
439
+			}
440
+			$data['format_source'] = 'aisnmeatxt';
441
+				$data['id_source'] = $id_source;
442
+			//print_r($data);
443
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
444
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
445
+			unset($data);
446 446
 		}
447
-    	    }
448
-    	    $last_exec[$id]['last'] = time();
447
+			}
448
+			$last_exec[$id]['last'] = time();
449 449
 	} elseif ($value['format'] == 'aisnmeahttp') {
450
-	    $arr = $httpfeeds;
451
-	    $w = $e = null;
450
+		$arr = $httpfeeds;
451
+		$w = $e = null;
452 452
 	    
453
-	    if (isset($arr[$id])) {
453
+		if (isset($arr[$id])) {
454 454
 		$nn = stream_select($arr,$w,$e,$timeout);
455 455
 		if ($nn > 0) {
456
-		    foreach ($httpfeeds as $feed) {
456
+			foreach ($httpfeeds as $feed) {
457 457
 			$buffer = stream_get_line($feed,2000,"\n");
458 458
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
459 459
 			$buffer = explode('\n',$buffer);
460 460
 			foreach ($buffer as $line) {
461
-			    if ($line != '') {
461
+				if ($line != '') {
462 462
 				$ais_data = $AIS->parse_line(trim($line));
463 463
 				$data = array();
464 464
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -476,96 +476,96 @@  discard block
 block discarded – undo
476 476
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
477 477
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
478 478
 				if (isset($ais_data['timestamp'])) {
479
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
479
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
480 480
 				} else {
481
-				    $data['datetime'] = date('Y-m-d H:i:s');
481
+					$data['datetime'] = date('Y-m-d H:i:s');
482 482
 				}
483 483
 				$data['format_source'] = 'aisnmeahttp';
484 484
 				$data['id_source'] = $id_source;
485 485
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
486 486
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
487 487
 				unset($data);
488
-			    }
488
+				}
489
+			}
489 490
 			}
490
-		    }
491 491
 		} else {
492
-		    $format = $value['format'];
493
-		    if (isset($tt[$format])) $tt[$format]++;
494
-		    else $tt[$format] = 0;
495
-		    if ($tt[$format] > 30) {
492
+			$format = $value['format'];
493
+			if (isset($tt[$format])) $tt[$format]++;
494
+			else $tt[$format] = 0;
495
+			if ($tt[$format] > 30) {
496 496
 			if ($globalDebug) echo 'Reconnect...'."\n";
497 497
 			sleep(2);
498 498
 			$sourceeen[] = $value;
499 499
 			connect_all($sourceeen);
500 500
 			$sourceeen = array();
501
-		    }
501
+			}
502
+		}
502 503
 		}
503
-	    }
504 504
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
505
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
506
-	    if ($buffer != '') {
505
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
506
+		if ($buffer != '') {
507 507
 		//echo $buffer;
508 508
 		$all_data = json_decode($buffer,true);
509 509
 		//print_r($all_data);
510 510
 		if (isset($all_data[0]['DATA'])) {
511
-		    foreach ($all_data[0]['DATA'] as $line) {
511
+			foreach ($all_data[0]['DATA'] as $line) {
512 512
 			if ($line != '') {
513
-			    $data = array();
514
-			    $data['ident'] = $line['NAME'];
515
-			    $data['mmsi'] = $line['MMSI'];
516
-			    $data['speed'] = $line['SOG'];
517
-			    $data['heading'] = $line['COG'];
518
-			    $data['latitude'] = $line['LAT'];
519
-			    $data['longitude'] = $line['LNG'];
520
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
521
-			    $data['imo'] = $line['IMO'];
522
-			    //$data['arrival_code'] = $ais_data['destination'];
523
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
524
-			    $data['format_source'] = 'myshiptracking';
525
-			    $data['id_source'] = $id_source;
526
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
527
-			    $MI->add($data);
528
-			    unset($data);
513
+				$data = array();
514
+				$data['ident'] = $line['NAME'];
515
+				$data['mmsi'] = $line['MMSI'];
516
+				$data['speed'] = $line['SOG'];
517
+				$data['heading'] = $line['COG'];
518
+				$data['latitude'] = $line['LAT'];
519
+				$data['longitude'] = $line['LNG'];
520
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
521
+				$data['imo'] = $line['IMO'];
522
+				//$data['arrival_code'] = $ais_data['destination'];
523
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
524
+				$data['format_source'] = 'myshiptracking';
525
+				$data['id_source'] = $id_source;
526
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
527
+				$MI->add($data);
528
+				unset($data);
529
+			}
529 530
 			}
530
-		    }
531 531
 		}
532
-	    }
533
-	    $last_exec[$id]['last'] = time();
532
+		}
533
+		$last_exec[$id]['last'] = time();
534 534
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
535
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
536
-	    if ($buffer != '') {
535
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
536
+		if ($buffer != '') {
537 537
 		$all_data = json_decode($buffer,true);
538 538
 		if (isset($all_data[0]['mmsi'])) {
539
-		    foreach ($all_data as $line) {
539
+			foreach ($all_data as $line) {
540 540
 			if ($line != '') {
541
-			    $data = array();
542
-			    $data['ident'] = $line['shipname'];
543
-			    $data['callsign'] = $line['callsign'];
544
-			    $data['mmsi'] = $line['mmsi'];
545
-			    $data['speed'] = $line['sog'];
546
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
547
-			    $data['latitude'] = $line['latitude'];
548
-			    $data['longitude'] = $line['longitude'];
549
-			    $data['type_id'] = $line['shiptype'];
550
-			    $data['arrival_code'] = $line['destination'];
551
-			    $data['datetime'] = $line['time'];
552
-			    $data['format_source'] = 'boatbeaconapp';
553
-			    $data['id_source'] = $id_source;
554
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
555
-			    $MI->add($data);
556
-			    unset($data);
541
+				$data = array();
542
+				$data['ident'] = $line['shipname'];
543
+				$data['callsign'] = $line['callsign'];
544
+				$data['mmsi'] = $line['mmsi'];
545
+				$data['speed'] = $line['sog'];
546
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
547
+				$data['latitude'] = $line['latitude'];
548
+				$data['longitude'] = $line['longitude'];
549
+				$data['type_id'] = $line['shiptype'];
550
+				$data['arrival_code'] = $line['destination'];
551
+				$data['datetime'] = $line['time'];
552
+				$data['format_source'] = 'boatbeaconapp';
553
+				$data['id_source'] = $id_source;
554
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
555
+				$MI->add($data);
556
+				unset($data);
557
+			}
557 558
 			}
558
-		    }
559 559
 		}
560 560
 		
561
-	    }
562
-    	    $last_exec[$id]['last'] = time();
561
+		}
562
+			$last_exec[$id]['last'] = time();
563 563
 	} elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
564
-	    $buffer = $Common->getData($value['host']);
565
-	    if ($buffer != '') {
564
+		$buffer = $Common->getData($value['host']);
565
+		if ($buffer != '') {
566 566
 		$all_data = json_decode($buffer,true);
567 567
 		if (isset($all_data['features'][0]['id'])) {
568
-		    foreach ($all_data['features'] as $line) {
568
+			foreach ($all_data['features'] as $line) {
569 569
 			$data = array();
570 570
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
571 571
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
@@ -584,59 +584,59 @@  discard block
 block discarded – undo
584 584
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
585 585
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
586 586
 			unset($data);
587
-		    }
587
+			}
588 588
 		}
589 589
 		
590
-	    }
591
-    	    $last_exec[$id]['last'] = time();
590
+		}
591
+			$last_exec[$id]['last'] = time();
592 592
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
593
-	    echo 'download...';
594
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
595
-	    echo 'done !'."\n";
596
-	    if ($buffer != '') $reset = 0;
597
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
598
-	    $buffer = explode('\n',$buffer);
599
-	    foreach ($buffer as $line) {
593
+		echo 'download...';
594
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
595
+		echo 'done !'."\n";
596
+		if ($buffer != '') $reset = 0;
597
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
598
+		$buffer = explode('\n',$buffer);
599
+		foreach ($buffer as $line) {
600 600
 		if ($line != '') {
601
-		    $data = array();
602
-		    $data['mmsi'] = (int)substr($line,0,9);
603
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
604
-		    //$data['status'] = substr($line,21,2);
605
-		    //$data['type'] = substr($line,24,3);
606
-		    $data['latitude'] = substr($line,29,9);
607
-		    $data['longitude'] = substr($line,41,9);
608
-		    $data['speed'] = round(substr($line,51,5));
609
-		    //$data['course'] = substr($line,57,5);
610
-		    $data['heading'] = round(substr($line,63,3));
611
-		    //$data['draft'] = substr($line,67,4);
612
-		    //$data['length'] = substr($line,72,3);
613
-		    //$data['beam'] = substr($line,76,2);
614
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
615
-		    //$data['callsign'] = trim(substr($line,100,7);
616
-		    //$data['dest'] = substr($line,108,20);
617
-		    //$data['etaDate'] = substr($line,129,5);
618
-		    //$data['etaTime'] = substr($line,135,5);
619
-		    $data['format_source'] = 'shipplotter';
620
-    		    $data['id_source'] = $id_source;
621
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
622
-		    //print_r($data);
623
-		    echo 'Add...'."\n";
624
-		    $MI->add($data);
625
-		    unset($data);
601
+			$data = array();
602
+			$data['mmsi'] = (int)substr($line,0,9);
603
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
604
+			//$data['status'] = substr($line,21,2);
605
+			//$data['type'] = substr($line,24,3);
606
+			$data['latitude'] = substr($line,29,9);
607
+			$data['longitude'] = substr($line,41,9);
608
+			$data['speed'] = round(substr($line,51,5));
609
+			//$data['course'] = substr($line,57,5);
610
+			$data['heading'] = round(substr($line,63,3));
611
+			//$data['draft'] = substr($line,67,4);
612
+			//$data['length'] = substr($line,72,3);
613
+			//$data['beam'] = substr($line,76,2);
614
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
615
+			//$data['callsign'] = trim(substr($line,100,7);
616
+			//$data['dest'] = substr($line,108,20);
617
+			//$data['etaDate'] = substr($line,129,5);
618
+			//$data['etaTime'] = substr($line,135,5);
619
+			$data['format_source'] = 'shipplotter';
620
+				$data['id_source'] = $id_source;
621
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
622
+			//print_r($data);
623
+			echo 'Add...'."\n";
624
+			$MI->add($data);
625
+			unset($data);
626 626
 		}
627
-    	    }
628
-    	    $last_exec[$id]['last'] = time();
627
+			}
628
+			$last_exec[$id]['last'] = time();
629 629
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
630 630
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
631
-	    //$buffer = $Common->getData($hosts[$id]);
632
-	    $buffer = $Common->getData($value['host']);
633
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
634
-	    $buffer = explode('\n',$buffer);
635
-	    $reset = 0;
636
-	    foreach ($buffer as $line) {
637
-    		if ($line != '') {
638
-    		    $line = explode(':', $line);
639
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
631
+		//$buffer = $Common->getData($hosts[$id]);
632
+		$buffer = $Common->getData($value['host']);
633
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
634
+		$buffer = explode('\n',$buffer);
635
+		$reset = 0;
636
+		foreach ($buffer as $line) {
637
+			if ($line != '') {
638
+				$line = explode(':', $line);
639
+				if (count($line) > 30 && $line[0] != 'callsign') {
640 640
 			$data = array();
641 641
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
642 642
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -649,37 +649,37 @@  discard block
 block discarded – undo
649 649
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
650 650
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
651 651
 			$data['latitude'] = $line[5]; // lat
652
-	        	$data['longitude'] = $line[6]; // long
653
-	        	$data['verticalrate'] = ''; // vertical rate
654
-	        	$data['squawk'] = ''; // squawk
655
-	        	$data['emergency'] = ''; // emergency
656
-	        	$data['waypoints'] = $line[30];
652
+				$data['longitude'] = $line[6]; // long
653
+				$data['verticalrate'] = ''; // vertical rate
654
+				$data['squawk'] = ''; // squawk
655
+				$data['emergency'] = ''; // emergency
656
+				$data['waypoints'] = $line[30];
657 657
 			$data['datetime'] = date('Y-m-d H:i:s');
658 658
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
659 659
 			//if (isset($line[37])) $data['last_update'] = $line[37];
660
-		        $data['departure_airport_icao'] = $line[11];
661
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
662
-		        $data['arrival_airport_icao'] = $line[13];
660
+				$data['departure_airport_icao'] = $line[11];
661
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
662
+				$data['arrival_airport_icao'] = $line[13];
663 663
 			$data['frequency'] = $line[4];
664 664
 			$data['type'] = $line[18];
665 665
 			$data['range'] = $line[19];
666 666
 			if (isset($line[35])) $data['info'] = $line[35];
667
-    			$data['id_source'] = $id_source;
668
-	    		//$data['arrival_airport_time'] = ;
669
-	    		if ($line[9] != '') {
670
-	    		    $aircraft_data = explode('/',$line[9]);
671
-	    		    if (isset($aircraft_data[1])) {
672
-	    			$data['aircraft_icao'] = $aircraft_data[1];
673
-	    		    }
674
-        		}
675
-	    		/*
667
+				$data['id_source'] = $id_source;
668
+				//$data['arrival_airport_time'] = ;
669
+				if ($line[9] != '') {
670
+					$aircraft_data = explode('/',$line[9]);
671
+					if (isset($aircraft_data[1])) {
672
+					$data['aircraft_icao'] = $aircraft_data[1];
673
+					}
674
+				}
675
+				/*
676 676
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
677 677
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
678 678
 	    		*/
679
-	    		$data['format_source'] = $value['format'];
679
+				$data['format_source'] = $value['format'];
680 680
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
681 681
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
682
-    			if ($line[3] == 'PILOT') $SI->add($data);
682
+				if ($line[3] == 'PILOT') $SI->add($data);
683 683
 			elseif ($line[3] == 'ATC') {
684 684
 				//print_r($data);
685 685
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -700,16 +700,16 @@  discard block
 block discarded – undo
700 700
 					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
701 701
 				}
702 702
 			}
703
-    			unset($data);
704
-    		    }
705
-    		}
706
-    	    }
707
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
708
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
709
-    	    $last_exec[$id]['last'] = time();
710
-    	} elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
711
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
712
-	    if ($buffer != '') {
703
+				unset($data);
704
+				}
705
+			}
706
+			}
707
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
708
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
709
+			$last_exec[$id]['last'] = time();
710
+		} elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
711
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
712
+		if ($buffer != '') {
713 713
 		$all_data = simplexml_load_string($buffer);
714 714
 		foreach($all_data->children() as $childdata) {
715 715
 			$data = array();
@@ -731,10 +731,10 @@  discard block
 block discarded – undo
731 731
 			$SI->add($data);
732 732
 			unset($data);
733 733
 		}
734
-	    }
735
-	    $Source->deleteOldLocationByType('gs');
736
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
737
-	    if ($buffer != '') {
734
+		}
735
+		$Source->deleteOldLocationByType('gs');
736
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
737
+		if ($buffer != '') {
738 738
 		$all_data = simplexml_load_string($buffer);
739 739
 		foreach($all_data->children() as $childdata) {
740 740
 			$data = array();
@@ -752,249 +752,249 @@  discard block
 block discarded – undo
752 752
 			}
753 753
 			unset($data);
754 754
 		}
755
-	    }
756
-	    $last_exec[$id]['last'] = time();
755
+		}
756
+		$last_exec[$id]['last'] = time();
757 757
 	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
758
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
759
-	    if ($buffer != '') {
760
-	    $all_data = json_decode($buffer,true);
761
-	    if (isset($all_data['acList'])) {
758
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
759
+		if ($buffer != '') {
760
+		$all_data = json_decode($buffer,true);
761
+		if (isset($all_data['acList'])) {
762 762
 		$reset = 0;
763 763
 		foreach ($all_data['acList'] as $line) {
764
-		    $data = array();
765
-		    $data['hex'] = $line['Icao']; // hex
766
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
767
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
768
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
769
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
770
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
771
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
772
-		    //$data['verticalrate'] = $line['']; // verticale rate
773
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
774
-		    $data['emergency'] = ''; // emergency
775
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
764
+			$data = array();
765
+			$data['hex'] = $line['Icao']; // hex
766
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
767
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
768
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
769
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
770
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
771
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
772
+			//$data['verticalrate'] = $line['']; // verticale rate
773
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
774
+			$data['emergency'] = ''; // emergency
775
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
776 776
 		    
777
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
778
-		    else $data['datetime'] = date('Y-m-d H:i:s');
777
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
778
+			else $data['datetime'] = date('Y-m-d H:i:s');
779 779
 		    
780
-		    //$data['datetime'] = date('Y-m-d H:i:s');
781
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
782
-	    	    $data['format_source'] = 'aircraftlistjson';
783
-		    $data['id_source'] = $id_source;
784
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
785
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
786
-		    if (isset($data['latitude'])) $SI->add($data);
787
-		    unset($data);
780
+			//$data['datetime'] = date('Y-m-d H:i:s');
781
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
782
+				$data['format_source'] = 'aircraftlistjson';
783
+			$data['id_source'] = $id_source;
784
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
785
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
786
+			if (isset($data['latitude'])) $SI->add($data);
787
+			unset($data);
788 788
 		}
789
-	    } elseif (is_array($all_data)) {
789
+		} elseif (is_array($all_data)) {
790 790
 		$reset = 0;
791 791
 		foreach ($all_data as $line) {
792
-		    $data = array();
793
-		    $data['hex'] = $line['hex']; // hex
794
-		    $data['ident'] = $line['flight']; // ident
795
-		    $data['altitude'] = $line['altitude']; // altitude
796
-		    $data['speed'] = $line['speed']; // speed
797
-		    $data['heading'] = $line['track']; // heading
798
-		    $data['latitude'] = $line['lat']; // lat
799
-		    $data['longitude'] = $line['lon']; // long
800
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
801
-		    $data['squawk'] = $line['squawk']; // squawk
802
-		    $data['emergency'] = ''; // emergency
803
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
804
-		    else $data['datetime'] = date('Y-m-d H:i:s');
805
-	    	    $data['format_source'] = 'aircraftlistjson';
806
-    		    $data['id_source'] = $id_source;
807
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
808
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
809
-		    $SI->add($data);
810
-		    unset($data);
792
+			$data = array();
793
+			$data['hex'] = $line['hex']; // hex
794
+			$data['ident'] = $line['flight']; // ident
795
+			$data['altitude'] = $line['altitude']; // altitude
796
+			$data['speed'] = $line['speed']; // speed
797
+			$data['heading'] = $line['track']; // heading
798
+			$data['latitude'] = $line['lat']; // lat
799
+			$data['longitude'] = $line['lon']; // long
800
+			$data['verticalrate'] = $line['vrt']; // verticale rate
801
+			$data['squawk'] = $line['squawk']; // squawk
802
+			$data['emergency'] = ''; // emergency
803
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
804
+			else $data['datetime'] = date('Y-m-d H:i:s');
805
+				$data['format_source'] = 'aircraftlistjson';
806
+				$data['id_source'] = $id_source;
807
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
808
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
809
+			$SI->add($data);
810
+			unset($data);
811
+		}
811 812
 		}
812
-	    }
813
-	    }
814
-    	    //$last_exec['aircraftlistjson'] = time();
815
-    	    $last_exec[$id]['last'] = time();
816
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
817
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
818
-	    $buffer = $Common->getData($value['host']);
819
-	    $all_data = json_decode($buffer,true);
820
-	    if (isset($all_data['planes'])) {
813
+		}
814
+			//$last_exec['aircraftlistjson'] = time();
815
+			$last_exec[$id]['last'] = time();
816
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
817
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
818
+		$buffer = $Common->getData($value['host']);
819
+		$all_data = json_decode($buffer,true);
820
+		if (isset($all_data['planes'])) {
821 821
 		$reset = 0;
822 822
 		foreach ($all_data['planes'] as $key => $line) {
823
-		    $data = array();
824
-		    $data['hex'] = $key; // hex
825
-		    $data['ident'] = $line[3]; // ident
826
-		    $data['altitude'] = $line[6]; // altitude
827
-		    $data['speed'] = $line[8]; // speed
828
-		    $data['heading'] = $line[7]; // heading
829
-		    $data['latitude'] = $line[4]; // lat
830
-		    $data['longitude'] = $line[5]; // long
831
-		    //$data['verticalrate'] = $line[]; // verticale rate
832
-		    $data['squawk'] = $line[10]; // squawk
833
-		    $data['emergency'] = ''; // emergency
834
-		    $data['registration'] = $line[2];
835
-		    $data['aircraft_icao'] = $line[0];
836
-		    $deparr = explode('-',$line[1]);
837
-		    if (count($deparr) == 2) {
823
+			$data = array();
824
+			$data['hex'] = $key; // hex
825
+			$data['ident'] = $line[3]; // ident
826
+			$data['altitude'] = $line[6]; // altitude
827
+			$data['speed'] = $line[8]; // speed
828
+			$data['heading'] = $line[7]; // heading
829
+			$data['latitude'] = $line[4]; // lat
830
+			$data['longitude'] = $line[5]; // long
831
+			//$data['verticalrate'] = $line[]; // verticale rate
832
+			$data['squawk'] = $line[10]; // squawk
833
+			$data['emergency'] = ''; // emergency
834
+			$data['registration'] = $line[2];
835
+			$data['aircraft_icao'] = $line[0];
836
+			$deparr = explode('-',$line[1]);
837
+			if (count($deparr) == 2) {
838 838
 			$data['departure_airport_icao'] = $deparr[0];
839 839
 			$data['arrival_airport_icao'] = $deparr[1];
840
-		    }
841
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
842
-	    	    $data['format_source'] = 'planeupdatefaa';
843
-    		    $data['id_source'] = $id_source;
844
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
845
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
846
-		    $SI->add($data);
847
-		    unset($data);
840
+			}
841
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
842
+				$data['format_source'] = 'planeupdatefaa';
843
+				$data['id_source'] = $id_source;
844
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
845
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
846
+			$SI->add($data);
847
+			unset($data);
848 848
 		}
849
-	    }
850
-    	    //$last_exec['planeupdatefaa'] = time();
851
-    	    $last_exec[$id]['last'] = time();
852
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
853
-	    $buffer = $Common->getData($value['host']);
854
-	    $all_data = json_decode($buffer,true);
855
-	    if (isset($all_data['states'])) {
849
+		}
850
+			//$last_exec['planeupdatefaa'] = time();
851
+			$last_exec[$id]['last'] = time();
852
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
853
+		$buffer = $Common->getData($value['host']);
854
+		$all_data = json_decode($buffer,true);
855
+		if (isset($all_data['states'])) {
856 856
 		$reset = 0;
857 857
 		foreach ($all_data['states'] as $key => $line) {
858
-		    $data = array();
859
-		    $data['hex'] = $line[0]; // hex
860
-		    $data['ident'] = trim($line[1]); // ident
861
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
862
-		    $data['speed'] = round($line[9]*1.94384); // speed
863
-		    $data['heading'] = round($line[10]); // heading
864
-		    $data['latitude'] = $line[6]; // lat
865
-		    $data['longitude'] = $line[5]; // long
866
-		    $data['verticalrate'] = $line[11]; // verticale rate
867
-		    //$data['squawk'] = $line[10]; // squawk
868
-		    //$data['emergency'] = ''; // emergency
869
-		    //$data['registration'] = $line[2];
870
-		    //$data['aircraft_icao'] = $line[0];
871
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
872
-	    	    $data['format_source'] = 'opensky';
873
-    		    $data['id_source'] = $id_source;
874
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
875
-		    $SI->add($data);
876
-		    unset($data);
858
+			$data = array();
859
+			$data['hex'] = $line[0]; // hex
860
+			$data['ident'] = trim($line[1]); // ident
861
+			$data['altitude'] = round($line[7]*3.28084); // altitude
862
+			$data['speed'] = round($line[9]*1.94384); // speed
863
+			$data['heading'] = round($line[10]); // heading
864
+			$data['latitude'] = $line[6]; // lat
865
+			$data['longitude'] = $line[5]; // long
866
+			$data['verticalrate'] = $line[11]; // verticale rate
867
+			//$data['squawk'] = $line[10]; // squawk
868
+			//$data['emergency'] = ''; // emergency
869
+			//$data['registration'] = $line[2];
870
+			//$data['aircraft_icao'] = $line[0];
871
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
872
+				$data['format_source'] = 'opensky';
873
+				$data['id_source'] = $id_source;
874
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
875
+			$SI->add($data);
876
+			unset($data);
877
+		}
877 878
 		}
878
-	    }
879
-    	    //$last_exec['planeupdatefaa'] = time();
880
-    	    $last_exec[$id]['last'] = time();
881
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
882
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
883
-	    //$buffer = $Common->getData($hosts[$id]);
884
-	    $buffer = $Common->getData($value['host']);
885
-	    $all_data = json_decode($buffer,true);
886
-	    if (!empty($all_data)) $reset = 0;
887
-	    foreach ($all_data as $key => $line) {
879
+			//$last_exec['planeupdatefaa'] = time();
880
+			$last_exec[$id]['last'] = time();
881
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
882
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
883
+		//$buffer = $Common->getData($hosts[$id]);
884
+		$buffer = $Common->getData($value['host']);
885
+		$all_data = json_decode($buffer,true);
886
+		if (!empty($all_data)) $reset = 0;
887
+		foreach ($all_data as $key => $line) {
888 888
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
889
-		    $data = array();
890
-		    $data['hex'] = $line[0];
891
-		    $data['ident'] = $line[16]; //$line[13]
892
-	    	    $data['altitude'] = $line[4]; // altitude
893
-	    	    $data['speed'] = $line[5]; // speed
894
-	    	    $data['heading'] = $line[3]; // heading
895
-	    	    $data['latitude'] = $line[1]; // lat
896
-	    	    $data['longitude'] = $line[2]; // long
897
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
898
-	    	    $data['squawk'] = $line[6]; // squawk
899
-	    	    $data['aircraft_icao'] = $line[8];
900
-	    	    $data['registration'] = $line[9];
901
-		    $data['departure_airport_iata'] = $line[11];
902
-		    $data['arrival_airport_iata'] = $line[12];
903
-	    	    $data['emergency'] = ''; // emergency
904
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
905
-	    	    $data['format_source'] = 'fr24json';
906
-    		    $data['id_source'] = $id_source;
907
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
908
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
909
-		    $SI->add($data);
910
-		    unset($data);
889
+			$data = array();
890
+			$data['hex'] = $line[0];
891
+			$data['ident'] = $line[16]; //$line[13]
892
+				$data['altitude'] = $line[4]; // altitude
893
+				$data['speed'] = $line[5]; // speed
894
+				$data['heading'] = $line[3]; // heading
895
+				$data['latitude'] = $line[1]; // lat
896
+				$data['longitude'] = $line[2]; // long
897
+				$data['verticalrate'] = $line[15]; // verticale rate
898
+				$data['squawk'] = $line[6]; // squawk
899
+				$data['aircraft_icao'] = $line[8];
900
+				$data['registration'] = $line[9];
901
+			$data['departure_airport_iata'] = $line[11];
902
+			$data['arrival_airport_iata'] = $line[12];
903
+				$data['emergency'] = ''; // emergency
904
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
905
+				$data['format_source'] = 'fr24json';
906
+				$data['id_source'] = $id_source;
907
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
908
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
909
+			$SI->add($data);
910
+			unset($data);
911 911
 		}
912
-	    }
913
-    	    //$last_exec['fr24json'] = time();
914
-    	    $last_exec[$id]['last'] = time();
915
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
916
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
917
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
918
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
919
-	    //echo $buffer;
920
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
921
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
922
-	    $all_data = json_decode($buffer,true);
923
-	    if (json_last_error() != JSON_ERROR_NONE) {
912
+		}
913
+			//$last_exec['fr24json'] = time();
914
+			$last_exec[$id]['last'] = time();
915
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
916
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
917
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
918
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
919
+		//echo $buffer;
920
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
921
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
922
+		$all_data = json_decode($buffer,true);
923
+		if (json_last_error() != JSON_ERROR_NONE) {
924 924
 		die(json_last_error_msg());
925
-	    }
926
-	    if (isset($all_data['mrkrs'])) {
925
+		}
926
+		if (isset($all_data['mrkrs'])) {
927 927
 		$reset = 0;
928 928
 		foreach ($all_data['mrkrs'] as $key => $line) {
929
-		    if (isset($line['inf'])) {
929
+			if (isset($line['inf'])) {
930 930
 			$data = array();
931 931
 			$data['hex'] = $line['inf']['ia'];
932 932
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
933
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
934
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
935
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
936
-	    		$data['latitude'] = $line['pt'][0]; // lat
937
-	    		$data['longitude'] = $line['pt'][1]; // long
938
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
939
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
940
-	    		//$data['aircraft_icao'] = $line[8];
941
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
933
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
934
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
935
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
936
+				$data['latitude'] = $line['pt'][0]; // lat
937
+				$data['longitude'] = $line['pt'][1]; // long
938
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
939
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
940
+				//$data['aircraft_icao'] = $line[8];
941
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
942 942
 			//$data['departure_airport_iata'] = $line[11];
943 943
 			//$data['arrival_airport_iata'] = $line[12];
944
-	    		//$data['emergency'] = ''; // emergency
944
+				//$data['emergency'] = ''; // emergency
945 945
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
946
-	    		$data['format_source'] = 'radarvirtueljson';
947
-    			$data['id_source'] = $id_source;
946
+				$data['format_source'] = 'radarvirtueljson';
947
+				$data['id_source'] = $id_source;
948 948
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
949 949
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
950 950
 			$SI->add($data);
951 951
 			unset($data);
952
-		    }
952
+			}
953
+		}
953 954
 		}
954
-	    }
955
-    	    //$last_exec['radarvirtueljson'] = time();
956
-    	    $last_exec[$id]['last'] = time();
957
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
958
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
959
-	    //$buffer = $Common->getData($hosts[$id]);
960
-	    $buffer = $Common->getData($value['host'].'?'.time());
961
-	    $all_data = json_decode(utf8_encode($buffer),true);
955
+			//$last_exec['radarvirtueljson'] = time();
956
+			$last_exec[$id]['last'] = time();
957
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
958
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
959
+		//$buffer = $Common->getData($hosts[$id]);
960
+		$buffer = $Common->getData($value['host'].'?'.time());
961
+		$all_data = json_decode(utf8_encode($buffer),true);
962 962
 	    
963
-	    if (isset($all_data['pireps'])) {
963
+		if (isset($all_data['pireps'])) {
964 964
 		$reset = 0;
965
-	        foreach ($all_data['pireps'] as $line) {
966
-		    $data = array();
967
-		    $data['id'] = $line['id'];
968
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
969
-		    $data['ident'] = $line['callsign']; // ident
970
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
971
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
972
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
973
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
974
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
975
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
976
-		    $data['latitude'] = $line['lat']; // lat
977
-		    $data['longitude'] = $line['lon']; // long
978
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
979
-		    //$data['squawk'] = $line['squawk']; // squawk
980
-		    //$data['emergency'] = ''; // emergency
981
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
982
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
983
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
984
-		    //$data['arrival_airport_time'] = $line['arrtime'];
985
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
986
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
987
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
988
-		    else $data['info'] = '';
989
-		    $data['format_source'] = 'pireps';
990
-    		    $data['id_source'] = $id_source;
991
-		    $data['datetime'] = date('Y-m-d H:i:s');
992
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
993
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
994
-		    if ($line['icon'] == 'plane') {
965
+			foreach ($all_data['pireps'] as $line) {
966
+			$data = array();
967
+			$data['id'] = $line['id'];
968
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
969
+			$data['ident'] = $line['callsign']; // ident
970
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
971
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
972
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
973
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
974
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
975
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
976
+			$data['latitude'] = $line['lat']; // lat
977
+			$data['longitude'] = $line['lon']; // long
978
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
979
+			//$data['squawk'] = $line['squawk']; // squawk
980
+			//$data['emergency'] = ''; // emergency
981
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
982
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
983
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
984
+			//$data['arrival_airport_time'] = $line['arrtime'];
985
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
986
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
987
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
988
+			else $data['info'] = '';
989
+			$data['format_source'] = 'pireps';
990
+				$data['id_source'] = $id_source;
991
+			$data['datetime'] = date('Y-m-d H:i:s');
992
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
993
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
994
+			if ($line['icon'] == 'plane') {
995 995
 			$SI->add($data);
996
-		    //    print_r($data);
997
-    		    } elseif ($line['icon'] == 'ct') {
996
+			//    print_r($data);
997
+				} elseif ($line['icon'] == 'ct') {
998 998
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
999 999
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1000 1000
 			$typec = substr($data['ident'],-3);
@@ -1009,203 +1009,203 @@  discard block
 block discarded – undo
1009 1009
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1010 1010
 			else $data['type'] = 'Observer';
1011 1011
 			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']);
1012
-		    }
1013
-		    unset($data);
1012
+			}
1013
+			unset($data);
1014
+		}
1014 1015
 		}
1015
-	    }
1016
-    	    //$last_exec['pirepsjson'] = time();
1017
-    	    $last_exec[$id]['last'] = time();
1018
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1019
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1020
-	    //$buffer = $Common->getData($hosts[$id]);
1021
-	    if ($globalDebug) echo 'Get Data...'."\n";
1022
-	    $buffer = $Common->getData($value['host']);
1023
-	    $all_data = json_decode($buffer,true);
1024
-	    if ($buffer != '' && is_array($all_data)) {
1016
+			//$last_exec['pirepsjson'] = time();
1017
+			$last_exec[$id]['last'] = time();
1018
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1019
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1020
+		//$buffer = $Common->getData($hosts[$id]);
1021
+		if ($globalDebug) echo 'Get Data...'."\n";
1022
+		$buffer = $Common->getData($value['host']);
1023
+		$all_data = json_decode($buffer,true);
1024
+		if ($buffer != '' && is_array($all_data)) {
1025 1025
 		$reset = 0;
1026 1026
 		foreach ($all_data as $line) {
1027
-	    	    $data = array();
1028
-	    	    //$data['id'] = $line['id']; // id not usable
1029
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1030
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1031
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1032
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1033
-	    	    $data['ident'] = $line['flightnum']; // ident
1034
-	    	    $data['altitude'] = $line['alt']; // altitude
1035
-	    	    $data['speed'] = $line['gs']; // speed
1036
-	    	    $data['heading'] = $line['heading']; // heading
1037
-	    	    $data['latitude'] = $line['lat']; // lat
1038
-	    	    $data['longitude'] = $line['lng']; // long
1039
-	    	    $data['verticalrate'] = ''; // verticale rate
1040
-	    	    $data['squawk'] = ''; // squawk
1041
-	    	    $data['emergency'] = ''; // emergency
1042
-	    	    //$data['datetime'] = $line['lastupdate'];
1043
-	    	    //$data['last_update'] = $line['lastupdate'];
1044
-	    	    if (isset($value['timezone'])) {
1045
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1046
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1047
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1048
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1049
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1050
-	    	    $data['departure_airport_time'] = $line['deptime'];
1051
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1052
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1053
-    		    $data['registration'] = $line['aircraft'];
1054
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1055
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1056
-		    if (isset($line['aircraftname'])) {
1027
+				$data = array();
1028
+				//$data['id'] = $line['id']; // id not usable
1029
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1030
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1031
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1032
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1033
+				$data['ident'] = $line['flightnum']; // ident
1034
+				$data['altitude'] = $line['alt']; // altitude
1035
+				$data['speed'] = $line['gs']; // speed
1036
+				$data['heading'] = $line['heading']; // heading
1037
+				$data['latitude'] = $line['lat']; // lat
1038
+				$data['longitude'] = $line['lng']; // long
1039
+				$data['verticalrate'] = ''; // verticale rate
1040
+				$data['squawk'] = ''; // squawk
1041
+				$data['emergency'] = ''; // emergency
1042
+				//$data['datetime'] = $line['lastupdate'];
1043
+				//$data['last_update'] = $line['lastupdate'];
1044
+				if (isset($value['timezone'])) {
1045
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1046
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1047
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1048
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1049
+				$data['departure_airport_icao'] = $line['depicao'];
1050
+				$data['departure_airport_time'] = $line['deptime'];
1051
+				$data['arrival_airport_icao'] = $line['arricao'];
1052
+				$data['arrival_airport_time'] = $line['arrtime'];
1053
+				$data['registration'] = $line['aircraft'];
1054
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1055
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1056
+			if (isset($line['aircraftname'])) {
1057 1057
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1058 1058
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1059
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1060
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1061
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1062
-	    		else {
1063
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1064
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1065
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1066
-	    		}
1067
-	    	    }
1068
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1069
-    		    $data['id_source'] = $id_source;
1070
-	    	    $data['format_source'] = 'phpvmacars';
1071
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1072
-		    $SI->add($data);
1073
-		    unset($data);
1059
+				$aircraft_data = explode('-',$line['aircraftname']);
1060
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1061
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1062
+				else {
1063
+					$aircraft_data = explode(' ',$line['aircraftname']);
1064
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1065
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1066
+				}
1067
+				}
1068
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1069
+				$data['id_source'] = $id_source;
1070
+				$data['format_source'] = 'phpvmacars';
1071
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1072
+			$SI->add($data);
1073
+			unset($data);
1074 1074
 		}
1075 1075
 		if ($globalDebug) echo 'No more data...'."\n";
1076 1076
 		unset($buffer);
1077 1077
 		unset($all_data);
1078
-	    }
1079
-    	    //$last_exec['phpvmacars'] = time();
1080
-    	    $last_exec[$id]['last'] = time();
1081
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1082
-	    //$buffer = $Common->getData($hosts[$id]);
1083
-	    if ($globalDebug) echo 'Get Data...'."\n";
1084
-	    $buffer = $Common->getData($value['host']);
1085
-	    $all_data = json_decode($buffer,true);
1086
-	    if ($buffer != '' && is_array($all_data)) {
1078
+		}
1079
+			//$last_exec['phpvmacars'] = time();
1080
+			$last_exec[$id]['last'] = time();
1081
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1082
+		//$buffer = $Common->getData($hosts[$id]);
1083
+		if ($globalDebug) echo 'Get Data...'."\n";
1084
+		$buffer = $Common->getData($value['host']);
1085
+		$all_data = json_decode($buffer,true);
1086
+		if ($buffer != '' && is_array($all_data)) {
1087 1087
 		$reset = 0;
1088 1088
 		foreach ($all_data as $line) {
1089
-	    	    $data = array();
1090
-	    	    //$data['id'] = $line['id']; // id not usable
1091
-	    	    $data['id'] = trim($line['flight_id']);
1092
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1093
-	    	    $data['pilot_name'] = $line['pilot_name'];
1094
-	    	    $data['pilot_id'] = $line['pilot_id'];
1095
-	    	    $data['ident'] = trim($line['callsign']); // ident
1096
-	    	    $data['altitude'] = $line['altitude']; // altitude
1097
-	    	    $data['speed'] = $line['gs']; // speed
1098
-	    	    $data['heading'] = $line['heading']; // heading
1099
-	    	    $data['latitude'] = $line['latitude']; // lat
1100
-	    	    $data['longitude'] = $line['longitude']; // long
1101
-	    	    $data['verticalrate'] = ''; // verticale rate
1102
-	    	    $data['squawk'] = ''; // squawk
1103
-	    	    $data['emergency'] = ''; // emergency
1104
-	    	    //$data['datetime'] = $line['lastupdate'];
1105
-	    	    $data['last_update'] = $line['last_update'];
1106
-		    $data['datetime'] = date('Y-m-d H:i:s');
1107
-	    	    $data['departure_airport_icao'] = $line['departure'];
1108
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1109
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1110
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1111
-    		    //$data['registration'] = $line['aircraft'];
1112
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1113
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1114
-    		    $data['id_source'] = $id_source;
1115
-	    	    $data['format_source'] = 'vam';
1116
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1117
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1118
-		    $SI->add($data);
1119
-		    unset($data);
1089
+				$data = array();
1090
+				//$data['id'] = $line['id']; // id not usable
1091
+				$data['id'] = trim($line['flight_id']);
1092
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1093
+				$data['pilot_name'] = $line['pilot_name'];
1094
+				$data['pilot_id'] = $line['pilot_id'];
1095
+				$data['ident'] = trim($line['callsign']); // ident
1096
+				$data['altitude'] = $line['altitude']; // altitude
1097
+				$data['speed'] = $line['gs']; // speed
1098
+				$data['heading'] = $line['heading']; // heading
1099
+				$data['latitude'] = $line['latitude']; // lat
1100
+				$data['longitude'] = $line['longitude']; // long
1101
+				$data['verticalrate'] = ''; // verticale rate
1102
+				$data['squawk'] = ''; // squawk
1103
+				$data['emergency'] = ''; // emergency
1104
+				//$data['datetime'] = $line['lastupdate'];
1105
+				$data['last_update'] = $line['last_update'];
1106
+			$data['datetime'] = date('Y-m-d H:i:s');
1107
+				$data['departure_airport_icao'] = $line['departure'];
1108
+				//$data['departure_airport_time'] = $line['departure_time'];
1109
+				$data['arrival_airport_icao'] = $line['arrival'];
1110
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1111
+				//$data['registration'] = $line['aircraft'];
1112
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1113
+				$data['aircraft_icao'] = $line['plane_type'];
1114
+				$data['id_source'] = $id_source;
1115
+				$data['format_source'] = 'vam';
1116
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1117
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1118
+			$SI->add($data);
1119
+			unset($data);
1120 1120
 		}
1121 1121
 		if ($globalDebug) echo 'No more data...'."\n";
1122 1122
 		unset($buffer);
1123 1123
 		unset($all_data);
1124
-	    }
1125
-    	    //$last_exec['phpvmacars'] = time();
1126
-    	    $last_exec[$id]['last'] = time();
1124
+		}
1125
+			//$last_exec['phpvmacars'] = time();
1126
+			$last_exec[$id]['last'] = time();
1127 1127
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1128 1128
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1129
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1130
-    	    //$last_exec[$id]['last'] = time();
1129
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1130
+			//$last_exec[$id]['last'] = time();
1131 1131
 
1132
-	    //$read = array( $sockets[$id] );
1133
-	    $read = $sockets;
1134
-	    $write = NULL;
1135
-	    $e = NULL;
1136
-	    $n = socket_select($read, $write, $e, $timeout);
1137
-	    if ($e != NULL) var_dump($e);
1138
-	    if ($n > 0) {
1132
+		//$read = array( $sockets[$id] );
1133
+		$read = $sockets;
1134
+		$write = NULL;
1135
+		$e = NULL;
1136
+		$n = socket_select($read, $write, $e, $timeout);
1137
+		if ($e != NULL) var_dump($e);
1138
+		if ($n > 0) {
1139 1139
 		$reset = 0;
1140 1140
 		foreach ($read as $nb => $r) {
1141
-		    //$value = $formats[$nb];
1142
-		    $format = $globalSources[$nb]['format'];
1143
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1141
+			//$value = $formats[$nb];
1142
+			$format = $globalSources[$nb]['format'];
1143
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1144 1144
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1145
-		    } elseif ($format == 'vrstcp') {
1145
+			} elseif ($format == 'vrstcp') {
1146 1146
 			$buffer = @socket_read($r, 6000);
1147
-		    } else {
1147
+			} else {
1148 1148
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1149
-		    }
1150
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1151
-		    //echo $buffer."\n";
1152
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1153
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1154
-		    $error = false;
1155
-		    //$SI::del();
1156
-		    if ($format == 'vrstcp') {
1149
+			}
1150
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1151
+			//echo $buffer."\n";
1152
+			// lets play nice and handle signals such as ctrl-c/kill properly
1153
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1154
+			$error = false;
1155
+			//$SI::del();
1156
+			if ($format == 'vrstcp') {
1157 1157
 			$buffer = explode('},{',$buffer);
1158
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1159
-		    // SBS format is CSV format
1160
-		    if ($buffer !== FALSE && $buffer != '') {
1158
+			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1159
+			// SBS format is CSV format
1160
+			if ($buffer !== FALSE && $buffer != '') {
1161 1161
 			$tt[$format] = 0;
1162 1162
 			if ($format == 'acarssbs3') {
1163
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1164
-			    $ACARS->add(trim($buffer));
1165
-			    $ACARS->deleteLiveAcarsData();
1163
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1164
+				$ACARS->add(trim($buffer));
1165
+				$ACARS->deleteLiveAcarsData();
1166 1166
 			} elseif ($format == 'raw') {
1167
-			    // AVR format
1168
-			    $data = $SBS->parse($buffer);
1169
-			    if (is_array($data)) {
1167
+				// AVR format
1168
+				$data = $SBS->parse($buffer);
1169
+				if (is_array($data)) {
1170 1170
 				$data['datetime'] = date('Y-m-d H:i:s');
1171 1171
 				$data['format_source'] = 'raw';
1172 1172
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1173 1173
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1174 1174
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1175 1175
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1176
-			    }
1176
+				}
1177 1177
 			} elseif ($format == 'ais') {
1178
-			    $ais_data = $AIS->parse_line(trim($buffer));
1179
-			    $data = array();
1180
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1181
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1182
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1183
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1184
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1185
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1186
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1187
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1188
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1189
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1190
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1191
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1192
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1193
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1194
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1195
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1178
+				$ais_data = $AIS->parse_line(trim($buffer));
1179
+				$data = array();
1180
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1181
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1182
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1183
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1184
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1185
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1186
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1187
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1188
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1189
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1190
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1191
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1192
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1193
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1194
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1195
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1196 1196
 
1197
-			    if (isset($ais_data['timestamp'])) {
1197
+				if (isset($ais_data['timestamp'])) {
1198 1198
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1199
-			    } else {
1199
+				} else {
1200 1200
 				$data['datetime'] = date('Y-m-d H:i:s');
1201
-			    }
1202
-			    $data['format_source'] = 'aisnmea';
1203
-    			    $data['id_source'] = $id_source;
1204
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1205
-			    unset($data);
1206
-                        } elseif ($format == 'flightgearsp') {
1207
-                    	    //echo $buffer."\n";
1208
-                    	    if (strlen($buffer) > 5) {
1201
+				}
1202
+				$data['format_source'] = 'aisnmea';
1203
+					$data['id_source'] = $id_source;
1204
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1205
+				unset($data);
1206
+						} elseif ($format == 'flightgearsp') {
1207
+							//echo $buffer."\n";
1208
+							if (strlen($buffer) > 5) {
1209 1209
 				$line = explode(',',$buffer);
1210 1210
 				$data = array();
1211 1211
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1222,38 +1222,38 @@  discard block
 block discarded – undo
1222 1222
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1223 1223
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1224 1224
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1225
-			    }
1226
-                        } elseif ($format == 'acars') {
1227
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1228
-			    $ACARS->add(trim($buffer));
1229
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1230
-			    $ACARS->deleteLiveAcarsData();
1225
+				}
1226
+						} elseif ($format == 'acars') {
1227
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1228
+				$ACARS->add(trim($buffer));
1229
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1230
+				$ACARS->deleteLiveAcarsData();
1231 1231
 			} elseif ($format == 'flightgearmp') {
1232
-			    if (substr($buffer,0,1) != '#') {
1232
+				if (substr($buffer,0,1) != '#') {
1233 1233
 				$data = array();
1234 1234
 				//echo $buffer."\n";
1235 1235
 				$line = explode(' ',$buffer);
1236 1236
 				if (count($line) == 11) {
1237
-				    $userserver = explode('@',$line[0]);
1238
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1239
-				    $data['ident'] = $userserver[0];
1240
-				    $data['registration'] = $userserver[0];
1241
-				    $data['latitude'] = $line[4];
1242
-				    $data['longitude'] = $line[5];
1243
-				    $data['altitude'] = $line[6];
1244
-				    $data['datetime'] = date('Y-m-d H:i:s');
1245
-				    $aircraft_type = $line[10];
1246
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1247
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1248
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1249
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1237
+					$userserver = explode('@',$line[0]);
1238
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1239
+					$data['ident'] = $userserver[0];
1240
+					$data['registration'] = $userserver[0];
1241
+					$data['latitude'] = $line[4];
1242
+					$data['longitude'] = $line[5];
1243
+					$data['altitude'] = $line[6];
1244
+					$data['datetime'] = date('Y-m-d H:i:s');
1245
+					$aircraft_type = $line[10];
1246
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1247
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1248
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1249
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1250
+				}
1250 1251
 				}
1251
-			    }
1252 1252
 			} elseif ($format == 'beast') {
1253
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1254
-			    die;
1253
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1254
+				die;
1255 1255
 			} elseif ($format == 'vrstcp') {
1256
-			    foreach($buffer as $all_data) {
1256
+				foreach($buffer as $all_data) {
1257 1257
 				$line = json_decode('{'.$all_data.'}',true);
1258 1258
 				$data = array();
1259 1259
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1273,116 +1273,116 @@  discard block
 block discarded – undo
1273 1273
 				*/
1274 1274
 				$data['datetime'] = date('Y-m-d H:i:s');
1275 1275
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1276
-		    		$data['format_source'] = 'vrstcp';
1276
+					$data['format_source'] = 'vrstcp';
1277 1277
 				$data['id_source'] = $id_source;
1278 1278
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1279 1279
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1280 1280
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1281 1281
 				unset($data);
1282
-			    }
1282
+				}
1283 1283
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1284
-			    $line = explode("\t", $buffer);
1285
-			    for($k = 0; $k < count($line); $k=$k+2) {
1284
+				$line = explode("\t", $buffer);
1285
+				for($k = 0; $k < count($line); $k=$k+2) {
1286 1286
 				$key = $line[$k];
1287
-			        $lined[$key] = $line[$k+1];
1288
-			    }
1289
-    			    if (count($lined) > 3) {
1290
-    				$data['hex'] = $lined['hexid'];
1291
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1292
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1293
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1294
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1295
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1296
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1297
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1298
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1299
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1300
-    				$data['id_source'] = $id_source;
1301
-    				$data['format_source'] = 'tsv';
1302
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1303
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1287
+					$lined[$key] = $line[$k+1];
1288
+				}
1289
+					if (count($lined) > 3) {
1290
+					$data['hex'] = $lined['hexid'];
1291
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1292
+					$data['datetime'] = date('Y-m-d H:i:s');;
1293
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1294
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1295
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1296
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1297
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1298
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1299
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1300
+					$data['id_source'] = $id_source;
1301
+					$data['format_source'] = 'tsv';
1302
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1303
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1304 1304
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1305
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1306
-    				unset($lined);
1307
-    				unset($data);
1308
-    			    } else $error = true;
1305
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1306
+					unset($lined);
1307
+					unset($data);
1308
+					} else $error = true;
1309 1309
 			} elseif ($format == 'aprs' && $use_aprs) {
1310
-			    if ($aprs_connect == 0) {
1310
+				if ($aprs_connect == 0) {
1311 1311
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1312 1312
 				$aprs_connect = 1;
1313
-			    }
1313
+				}
1314 1314
 			    
1315
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1315
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1316 1316
 				$aprs_last_tx = time();
1317 1317
 				$data_aprs = "# Keep alive";
1318 1318
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1319
-			    }
1319
+				}
1320 1320
 			    
1321
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1322
-			    //echo 'APRS data : '.$buffer."\n";
1323
-			    $buffer = str_replace('APRS <- ','',$buffer);
1324
-			    $buffer = str_replace('APRS -> ','',$buffer);
1325
-			    //echo $buffer."\n";
1326
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1321
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1322
+				//echo 'APRS data : '.$buffer."\n";
1323
+				$buffer = str_replace('APRS <- ','',$buffer);
1324
+				$buffer = str_replace('APRS -> ','',$buffer);
1325
+				//echo $buffer."\n";
1326
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1327 1327
 				$line = $APRS->parse($buffer);
1328 1328
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1329 1329
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1330
-				    $aprs_last_tx = time();
1331
-				    $data = array();
1332
-				    //print_r($line);
1333
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1334
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1335
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1336
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1337
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1338
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1339
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1340
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1341
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1342
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1343
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1344
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1345
-				    $data['latitude'] = $line['latitude'];
1346
-				    $data['longitude'] = $line['longitude'];
1347
-				    //$data['verticalrate'] = $line[16];
1348
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1349
-				    //else $data['speed'] = 0;
1350
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1351
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1352
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1353
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1354
-				    //else $data['heading'] = 0;
1355
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1356
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1357
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1358
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1359
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1360
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1361
-    				    $data['id_source'] = $id_source;
1362
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1363
-				    else $data['format_source'] = 'aprs';
1364
-				    $data['source_name'] = $line['source'];
1365
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1366
-				    else $data['source_type'] = 'flarm';
1367
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1368
-				    $currentdate = date('Y-m-d H:i:s');
1369
-				    $aprsdate = strtotime($data['datetime']);
1370
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1371
-				    // Accept data if time <= system time + 20s
1372
-				    //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1373
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1330
+					$aprs_last_tx = time();
1331
+					$data = array();
1332
+					//print_r($line);
1333
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1334
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1335
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1336
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1337
+					if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1338
+					if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1339
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1340
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1341
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1342
+					else $data['datetime'] = date('Y-m-d H:i:s');
1343
+					//$data['datetime'] = date('Y-m-d H:i:s');
1344
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1345
+					$data['latitude'] = $line['latitude'];
1346
+					$data['longitude'] = $line['longitude'];
1347
+					//$data['verticalrate'] = $line[16];
1348
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1349
+					//else $data['speed'] = 0;
1350
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1351
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1352
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1353
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
1354
+					//else $data['heading'] = 0;
1355
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1356
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1357
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1358
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1359
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1360
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1361
+						$data['id_source'] = $id_source;
1362
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1363
+					else $data['format_source'] = 'aprs';
1364
+					$data['source_name'] = $line['source'];
1365
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1366
+					else $data['source_type'] = 'flarm';
1367
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1368
+					$currentdate = date('Y-m-d H:i:s');
1369
+					$aprsdate = strtotime($data['datetime']);
1370
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1371
+					// Accept data if time <= system time + 20s
1372
+					//if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1373
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1374 1374
 					$send = $SI->add($data);
1375
-				    } elseif ($data['source_type'] == 'ais') {
1375
+					} elseif ($data['source_type'] == 'ais') {
1376 1376
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1377
-				    } elseif (isset($line['stealth'])) {
1377
+					} elseif (isset($line['stealth'])) {
1378 1378
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1379 1379
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1380
-				    //} 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')) {
1381
-				    //} 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') {
1382
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1380
+					//} 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')) {
1381
+					//} 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') {
1382
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1383 1383
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1384 1384
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1385
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1385
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1386 1386
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1387 1387
 					$Source->deleteOldLocationByType('gs');
1388 1388
 					if (count($Source->getLocationInfoByName($data['ident'])) > 0) {
@@ -1390,11 +1390,11 @@  discard block
 block discarded – undo
1390 1390
 					} else {
1391 1391
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1392 1392
 					}
1393
-				    } else {
1394
-				    	echo '/!\ Not added: '.$buffer."\n";
1395
-				    	print_r($line);
1396
-				    }
1397
-				    unset($data);
1393
+					} else {
1394
+						echo '/!\ Not added: '.$buffer."\n";
1395
+						print_r($line);
1396
+					}
1397
+					unset($data);
1398 1398
 				} 
1399 1399
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1400 1400
 					echo '!! Weather Station not yet supported'."\n";
@@ -1410,12 +1410,12 @@  discard block
 block discarded – undo
1410 1410
 				*/
1411 1411
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1412 1412
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1413
-			    }
1413
+				}
1414 1414
 			} else {
1415
-			    $line = explode(',', $buffer);
1416
-    			    if (count($line) > 20) {
1417
-    			    	$data['hex'] = $line[4];
1418
-    				/*
1415
+				$line = explode(',', $buffer);
1416
+					if (count($line) > 20) {
1417
+						$data['hex'] = $line[4];
1418
+					/*
1419 1419
     				$data['datetime'] = $line[6].' '.$line[7];
1420 1420
     					date_default_timezone_set($globalTimezone);
1421 1421
     					$datetime = new DateTime($data['datetime']);
@@ -1423,30 +1423,30 @@  discard block
 block discarded – undo
1423 1423
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1424 1424
     					date_default_timezone_set('UTC');
1425 1425
     				*/
1426
-    				// Force datetime to current UTC datetime
1427
-    				date_default_timezone_set('UTC');
1428
-    				$data['datetime'] = date('Y-m-d H:i:s');
1429
-    				$data['ident'] = trim($line[10]);
1430
-    				$data['latitude'] = $line[14];
1431
-    				$data['longitude'] = $line[15];
1432
-    				$data['verticalrate'] = $line[16];
1433
-    				$data['emergency'] = $line[20];
1434
-    				$data['speed'] = $line[12];
1435
-    				$data['squawk'] = $line[17];
1436
-    				$data['altitude'] = $line[11];
1437
-    				$data['heading'] = $line[13];
1438
-    				$data['ground'] = $line[21];
1439
-    				$data['emergency'] = $line[19];
1440
-    				$data['format_source'] = 'sbs';
1426
+					// Force datetime to current UTC datetime
1427
+					date_default_timezone_set('UTC');
1428
+					$data['datetime'] = date('Y-m-d H:i:s');
1429
+					$data['ident'] = trim($line[10]);
1430
+					$data['latitude'] = $line[14];
1431
+					$data['longitude'] = $line[15];
1432
+					$data['verticalrate'] = $line[16];
1433
+					$data['emergency'] = $line[20];
1434
+					$data['speed'] = $line[12];
1435
+					$data['squawk'] = $line[17];
1436
+					$data['altitude'] = $line[11];
1437
+					$data['heading'] = $line[13];
1438
+					$data['ground'] = $line[21];
1439
+					$data['emergency'] = $line[19];
1440
+					$data['format_source'] = 'sbs';
1441 1441
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1442
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1442
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1443 1443
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1444
-    				$data['id_source'] = $id_source;
1445
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1446
-    				else $error = true;
1447
-    				unset($data);
1448
-    			    } else $error = true;
1449
-			    if ($error) {
1444
+					$data['id_source'] = $id_source;
1445
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1446
+					else $error = true;
1447
+					unset($data);
1448
+					} else $error = true;
1449
+				if ($error) {
1450 1450
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1451 1451
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1452 1452
 				} else {
@@ -1462,13 +1462,13 @@  discard block
 block discarded – undo
1462 1462
 					connect_all($sourceer);
1463 1463
 					$sourceer = array();
1464 1464
 				}
1465
-			    }
1465
+				}
1466 1466
 			}
1467 1467
 			// Sleep for xxx microseconds
1468 1468
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1469
-		    } else {
1469
+			} else {
1470 1470
 			if ($format == 'flightgearmp') {
1471
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1471
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1472 1472
 				//@socket_close($r);
1473 1473
 				sleep($globalMinFetch);
1474 1474
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1477,9 +1477,9 @@  discard block
 block discarded – undo
1477 1477
 				break;
1478 1478
 				
1479 1479
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1480
-			    if (isset($tt[$format])) $tt[$format]++;
1481
-			    else $tt[$format] = 0;
1482
-			    if ($tt[$format] > 30) {
1480
+				if (isset($tt[$format])) $tt[$format]++;
1481
+				else $tt[$format] = 0;
1482
+				if ($tt[$format] > 30) {
1483 1483
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1484 1484
 				//@socket_close($r);
1485 1485
 				sleep(2);
@@ -1490,23 +1490,23 @@  discard block
 block discarded – undo
1490 1490
 				//connect_all($globalSources);
1491 1491
 				$tt[$format]=0;
1492 1492
 				break;
1493
-			    }
1493
+				}
1494
+			}
1494 1495
 			}
1495
-		    }
1496 1496
 		}
1497
-	    } else {
1497
+		} else {
1498 1498
 		$error = socket_strerror(socket_last_error());
1499 1499
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1500 1500
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1501 1501
 			if (isset($globalDebug)) echo "Restarting...\n";
1502 1502
 			// Restart the script if possible
1503 1503
 			if (is_array($sockets)) {
1504
-			    if ($globalDebug) echo "Shutdown all sockets...";
1504
+				if ($globalDebug) echo "Shutdown all sockets...";
1505 1505
 			    
1506
-			    foreach ($sockets as $sock) {
1506
+				foreach ($sockets as $sock) {
1507 1507
 				@socket_shutdown($sock,2);
1508 1508
 				@socket_close($sock);
1509
-			    }
1509
+				}
1510 1510
 			    
1511 1511
 			}
1512 1512
 			if ($globalDebug) echo "Waiting...";
@@ -1521,13 +1521,13 @@  discard block
 block discarded – undo
1521 1521
 			if ($globalDebug) echo "Restart all connections...";
1522 1522
 			connect_all($globalSources);
1523 1523
 		}
1524
-	    }
1524
+		}
1525 1525
 	}
1526 1526
 	if ($globalDaemon === false) {
1527
-	    if ($globalDebug) echo 'Check all...'."\n";
1528
-	    $SI->checkAll();
1527
+		if ($globalDebug) echo 'Check all...'."\n";
1528
+		$SI->checkAll();
1529
+	}
1529 1530
 	}
1530
-    }
1531 1531
 }
1532 1532
 
1533 1533
 ?>
Please login to merge, or discard this patch.
Spacing   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -46,20 +46,20 @@  discard block
 block discarded – undo
46 46
 	    die;
47 47
 	}
48 48
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
49
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
49
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
50 50
     }
51 51
 }
52 52
 
53
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
53
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver'));
54 54
 //if (isset($options['s'])) $hosts = array($options['s']);
55 55
 //elseif (isset($options['source'])) $hosts = array($options['source']);
56 56
 if (isset($options['s'])) {
57 57
     $globalSources = array();
58
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
59 59
     else $globalSources[] = array('host' => $options['s']);
60 60
 } elseif (isset($options['source'])) {
61 61
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
63 63
     else $globalSources[] = array('host' => $options['source']);
64 64
 }
65 65
 if (isset($options['aprsserverhost'])) {
@@ -76,28 +76,28 @@  discard block
 block discarded – undo
76 76
 else $id_source = 1;
77 77
 if (isset($globalServer) && $globalServer) {
78 78
     if ($globalDebug) echo "Using Server Mode\n";
79
-    $SI=new SpotterServer();
79
+    $SI = new SpotterServer();
80 80
 /*
81 81
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
82 82
     $SI = new adsb2aprs();
83 83
     $SI->connect();
84 84
 */
85
-} else $SI=new SpotterImport($Connection->db);
85
+} else $SI = new SpotterImport($Connection->db);
86 86
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
87 87
 if (isset($globalMarine) && $globalMarine) {
88 88
     $AIS = new AIS();
89 89
     $MI = new MarineImport($Connection->db);
90 90
 }
91 91
 //$APRS=new APRS($Connection->db);
92
-$SBS=new SBS();
93
-$ACARS=new ACARS($Connection->db);
94
-$Source=new Source($Connection->db);
95
-$Common=new Common();
92
+$SBS = new SBS();
93
+$ACARS = new ACARS($Connection->db);
94
+$Source = new Source($Connection->db);
95
+$Common = new Common();
96 96
 date_default_timezone_set('UTC');
97 97
 //$servertz = system('date +%Z');
98 98
 // signal handler - playing nice with sockets and dump1090
99 99
 if (function_exists('pcntl_fork')) {
100
-    pcntl_signal(SIGINT,  function() {
100
+    pcntl_signal(SIGINT, function() {
101 101
         global $sockets;
102 102
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
103 103
         die("Bye!\n");
@@ -113,30 +113,30 @@  discard block
 block discarded – undo
113 113
 
114 114
 function connect_all($hosts) {
115 115
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
116
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
117 117
     $reset++;
118 118
     if ($globalDebug) echo 'Connect to all...'."\n";
119 119
     foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
123
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
+            if (preg_match('/deltadb.txt$/i', $host)) {
125 125
         	//$formats[$id] = 'deltadbtxt';
126 126
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 127
         	//$last_exec['deltadbtxt'] = 0;
128 128
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
129
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
130 130
         	//$formats[$id] = 'vatsimtxt';
131 131
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 132
         	//$last_exec['vatsimtxt'] = 0;
133 133
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
134
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
135 135
         	//$formats[$id] = 'aircraftlistjson';
136 136
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 137
         	//$last_exec['aircraftlistjson'] = 0;
138 138
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
139
+    	    } else if (preg_match('/opensky/i', $host)) {
140 140
         	//$formats[$id] = 'aircraftlistjson';
141 141
         	$globalSources[$id]['format'] = 'opensky';
142 142
         	//$last_exec['aircraftlistjson'] = 0;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         	    exit(0);
154 154
         	}
155 155
     	    */
156
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
156
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
157 157
         	//$formats[$id] = 'planeupdatefaa';
158 158
         	$globalSources[$id]['format'] = 'planeupdatefaa';
159 159
         	//$last_exec['planeupdatefaa'] = 0;
@@ -162,29 +162,29 @@  discard block
 block discarded – undo
162 162
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163 163
         	    exit(0);
164 164
         	}
165
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
165
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
166 166
         	//$formats[$id] = 'phpvmacars';
167 167
         	$globalSources[$id]['format'] = 'phpvmacars';
168 168
         	//$last_exec['phpvmacars'] = 0;
169 169
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
170
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
170
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
171 171
         	//$formats[$id] = 'phpvmacars';
172 172
         	$globalSources[$id]['format'] = 'vam';
173 173
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
174
-            } else if (preg_match('/whazzup/i',$host)) {
174
+            } else if (preg_match('/whazzup/i', $host)) {
175 175
         	//$formats[$id] = 'whazzup';
176 176
         	$globalSources[$id]['format'] = 'whazzup';
177 177
         	//$last_exec['whazzup'] = 0;
178 178
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
179
-            } else if (preg_match('/airwhere/i',$host)) {
179
+            } else if (preg_match('/airwhere/i', $host)) {
180 180
         	$globalSources[$id]['format'] = 'airwhere';
181 181
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
182
-            } else if (preg_match('/recentpireps/i',$host)) {
182
+            } else if (preg_match('/recentpireps/i', $host)) {
183 183
         	//$formats[$id] = 'pirepsjson';
184 184
         	$globalSources[$id]['format'] = 'pirepsjson';
185 185
         	//$last_exec['pirepsjson'] = 0;
186 186
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
187
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
187
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
188 188
         	//$formats[$id] = 'fr24json';
189 189
         	$globalSources[$id]['format'] = 'fr24json';
190 190
         	//$last_exec['fr24json'] = 0;
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
194 194
         	    exit(0);
195 195
         	}
196
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
196
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
197 197
         	//$formats[$id] = 'fr24json';
198 198
         	$globalSources[$id]['format'] = 'myshiptracking';
199 199
         	//$last_exec['fr24json'] = 0;
@@ -203,22 +203,22 @@  discard block
 block discarded – undo
203 203
         	    exit(0);
204 204
         	}
205 205
             //} else if (preg_match('/10001/',$host)) {
206
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
206
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
207 207
         	//$formats[$id] = 'tsv';
208 208
         	$globalSources[$id]['format'] = 'tsv';
209 209
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
210 210
             }
211
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
211
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
212 212
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
213
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
213
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
214 214
     		    if ($idf !== false) {
215 215
     			$httpfeeds[$id] = $idf;
216 216
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
217 217
     		    }
218 218
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
219 219
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
220
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
221
-	    $hostport = explode(':',$host);
220
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
221
+	    $hostport = explode(':', $host);
222 222
 	    if (isset($hostport[1])) {
223 223
 		$port = $hostport[1];
224 224
 		$hostn = $hostport[0];
@@ -228,19 +228,19 @@  discard block
 block discarded – undo
228 228
 	    }
229 229
 	    $Common = new Common();
230 230
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
231
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
231
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
232 232
     	    } else {
233
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
233
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
234 234
 	    }
235 235
 	    if ($s) {
236 236
     	        $sockets[$id] = $s;
237 237
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
238
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
238
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
239 239
 			//$formats[$id] = 'aprs';
240 240
 			$globalSources[$id]['format'] = 'aprs';
241 241
 			//$aprs_connect = 0;
242 242
 			//$use_aprs = true;
243
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
243
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
244 244
 			$globalSources[$id]['format'] = 'vrstcp';
245 245
     		    } elseif ($port == '10001') {
246 246
         		//$formats[$id] = 'tsv';
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
280 280
 else $timeout = 20;
281 281
 $errno = '';
282
-$errstr='';
282
+$errstr = '';
283 283
 
284 284
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
285 285
 /* Initiate connections to all the hosts simultaneously */
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 //connect_all($globalSources);
288 288
 
289 289
 if (isset($globalProxy) && $globalProxy) {
290
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
290
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
291 291
 } else {
292 292
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
293 293
 }
@@ -314,16 +314,16 @@  discard block
 block discarded – undo
314 314
 
315 315
 if ($use_aprs) {
316 316
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
317
-	$APRS=new APRS();
317
+	$APRS = new APRS();
318 318
 	$aprs_connect = 0;
319 319
 	$aprs_keep = 120;
320 320
 	$aprs_last_tx = time();
321 321
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
322
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
322
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
323 323
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
324
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
324
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
325 325
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
326
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
326
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
327 327
 	if ($aprs_full) $aprs_filter = '';
328 328
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
329 329
 	else $aprs_pass = '-1';
@@ -337,12 +337,12 @@  discard block
 block discarded – undo
337 337
 sleep(1);
338 338
 if ($globalDebug) echo "SCAN MODE \n\n";
339 339
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
340
-$endtime = time()+$globalCronEnd;
340
+$endtime = time() + $globalCronEnd;
341 341
 $i = 1;
342 342
 $tt = array();
343 343
 // Delete all ATC
344 344
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
345
-	$ATC=new ATC($Connection->db);
345
+	$ATC = new ATC($Connection->db);
346 346
 }
347 347
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
348 348
 	$ATC->deleteAll();
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 
351 351
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
352 352
 while ($i > 0) {
353
-    if (!$globalDaemon) $i = $endtime-time();
353
+    if (!$globalDaemon) $i = $endtime - time();
354 354
     // Delete old ATC
355 355
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
356 356
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 	}
365 365
 	if ($max != $globalMinFetch) {
366 366
 	    if ($globalDebug) echo 'Sleeping...'."\n";
367
-	    sleep($globalMinFetch-$max+2);
367
+	    sleep($globalMinFetch - $max + 2);
368 368
 	}
369 369
     }
370 370
 
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
 	    //$buffer = $Common->getData($hosts[$id]);
378 378
 	    $buffer = $Common->getData($value['host']);
379 379
 	    if ($buffer != '') $reset = 0;
380
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
381
-	    $buffer = explode('\n',$buffer);
380
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
381
+	    $buffer = explode('\n', $buffer);
382 382
 	    foreach ($buffer as $line) {
383 383
     		if ($line != '' && count($line) > 7) {
384 384
     		    $line = explode(',', $line);
@@ -406,11 +406,11 @@  discard block
 block discarded – undo
406 406
     	    $last_exec[$id]['last'] = time();
407 407
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
408 408
 	    date_default_timezone_set('CET');
409
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
409
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
410 410
 	    date_default_timezone_set('UTC');
411 411
 	    if ($buffer != '') $reset = 0;
412
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
413
-	    $buffer = explode('\n',$buffer);
412
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
413
+	    $buffer = explode('\n', $buffer);
414 414
 	    foreach ($buffer as $line) {
415 415
 		if ($line != '') {
416 416
 		    //echo "'".$line."'\n";
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
429 429
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
430 430
 		    if (isset($ais_data['timestamp'])) {
431
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
431
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
432 432
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
433 433
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
434 434
 			    $add = true;
@@ -451,12 +451,12 @@  discard block
 block discarded – undo
451 451
 	    $w = $e = null;
452 452
 	    
453 453
 	    if (isset($arr[$id])) {
454
-		$nn = stream_select($arr,$w,$e,$timeout);
454
+		$nn = stream_select($arr, $w, $e, $timeout);
455 455
 		if ($nn > 0) {
456 456
 		    foreach ($httpfeeds as $feed) {
457
-			$buffer = stream_get_line($feed,2000,"\n");
458
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
459
-			$buffer = explode('\n',$buffer);
457
+			$buffer = stream_get_line($feed, 2000, "\n");
458
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
459
+			$buffer = explode('\n', $buffer);
460 460
 			foreach ($buffer as $line) {
461 461
 			    if ($line != '') {
462 462
 				$ais_data = $AIS->parse_line(trim($line));
@@ -474,9 +474,9 @@  discard block
 block discarded – undo
474 474
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
475 475
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
476 476
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
477
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
477
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
478 478
 				if (isset($ais_data['timestamp'])) {
479
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
479
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
480 480
 				} else {
481 481
 				    $data['datetime'] = date('Y-m-d H:i:s');
482 482
 				}
@@ -502,10 +502,10 @@  discard block
 block discarded – undo
502 502
 		}
503 503
 	    }
504 504
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
505
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
505
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
506 506
 	    if ($buffer != '') {
507 507
 		//echo $buffer;
508
-		$all_data = json_decode($buffer,true);
508
+		$all_data = json_decode($buffer, true);
509 509
 		//print_r($all_data);
510 510
 		if (isset($all_data[0]['DATA'])) {
511 511
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
521 521
 			    $data['imo'] = $line['IMO'];
522 522
 			    //$data['arrival_code'] = $ais_data['destination'];
523
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
523
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
524 524
 			    $data['format_source'] = 'myshiptracking';
525 525
 			    $data['id_source'] = $id_source;
526 526
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -532,9 +532,9 @@  discard block
 block discarded – undo
532 532
 	    }
533 533
 	    $last_exec[$id]['last'] = time();
534 534
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
535
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
535
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
536 536
 	    if ($buffer != '') {
537
-		$all_data = json_decode($buffer,true);
537
+		$all_data = json_decode($buffer, true);
538 538
 		if (isset($all_data[0]['mmsi'])) {
539 539
 		    foreach ($all_data as $line) {
540 540
 			if ($line != '') {
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 	} elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
564 564
 	    $buffer = $Common->getData($value['host']);
565 565
 	    if ($buffer != '') {
566
-		$all_data = json_decode($buffer,true);
566
+		$all_data = json_decode($buffer, true);
567 567
 		if (isset($all_data['features'][0]['id'])) {
568 568
 		    foreach ($all_data['features'] as $line) {
569 569
 			$data = array();
@@ -591,27 +591,27 @@  discard block
 block discarded – undo
591 591
     	    $last_exec[$id]['last'] = time();
592 592
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
593 593
 	    echo 'download...';
594
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
594
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
595 595
 	    echo 'done !'."\n";
596 596
 	    if ($buffer != '') $reset = 0;
597
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
598
-	    $buffer = explode('\n',$buffer);
597
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
598
+	    $buffer = explode('\n', $buffer);
599 599
 	    foreach ($buffer as $line) {
600 600
 		if ($line != '') {
601 601
 		    $data = array();
602
-		    $data['mmsi'] = (int)substr($line,0,9);
603
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
602
+		    $data['mmsi'] = (int) substr($line, 0, 9);
603
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
604 604
 		    //$data['status'] = substr($line,21,2);
605 605
 		    //$data['type'] = substr($line,24,3);
606
-		    $data['latitude'] = substr($line,29,9);
607
-		    $data['longitude'] = substr($line,41,9);
608
-		    $data['speed'] = round(substr($line,51,5));
606
+		    $data['latitude'] = substr($line, 29, 9);
607
+		    $data['longitude'] = substr($line, 41, 9);
608
+		    $data['speed'] = round(substr($line, 51, 5));
609 609
 		    //$data['course'] = substr($line,57,5);
610
-		    $data['heading'] = round(substr($line,63,3));
610
+		    $data['heading'] = round(substr($line, 63, 3));
611 611
 		    //$data['draft'] = substr($line,67,4);
612 612
 		    //$data['length'] = substr($line,72,3);
613 613
 		    //$data['beam'] = substr($line,76,2);
614
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
614
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
615 615
 		    //$data['callsign'] = trim(substr($line,100,7);
616 616
 		    //$data['dest'] = substr($line,108,20);
617 617
 		    //$data['etaDate'] = substr($line,129,5);
@@ -630,8 +630,8 @@  discard block
 block discarded – undo
630 630
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
631 631
 	    //$buffer = $Common->getData($hosts[$id]);
632 632
 	    $buffer = $Common->getData($value['host']);
633
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
634
-	    $buffer = explode('\n',$buffer);
633
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
634
+	    $buffer = explode('\n', $buffer);
635 635
 	    $reset = 0;
636 636
 	    foreach ($buffer as $line) {
637 637
     		if ($line != '') {
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
643 643
 			$data['pilot_id'] = $line[1];
644 644
 			$data['pilot_name'] = $line[2];
645
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
645
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
646 646
 			$data['ident'] = $line[0]; // ident
647 647
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
648 648
 			$data['speed'] = $line[8]; // speed
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
659 659
 			//if (isset($line[37])) $data['last_update'] = $line[37];
660 660
 		        $data['departure_airport_icao'] = $line[11];
661
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
661
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
662 662
 		        $data['arrival_airport_icao'] = $line[13];
663 663
 			$data['frequency'] = $line[4];
664 664
 			$data['type'] = $line[18];
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
     			$data['id_source'] = $id_source;
668 668
 	    		//$data['arrival_airport_time'] = ;
669 669
 	    		if ($line[9] != '') {
670
-	    		    $aircraft_data = explode('/',$line[9]);
670
+	    		    $aircraft_data = explode('/', $line[9]);
671 671
 	    		    if (isset($aircraft_data[1])) {
672 672
 	    			$data['aircraft_icao'] = $aircraft_data[1];
673 673
 	    		    }
@@ -682,9 +682,9 @@  discard block
 block discarded – undo
682 682
     			if ($line[3] == 'PILOT') $SI->add($data);
683 683
 			elseif ($line[3] == 'ATC') {
684 684
 				//print_r($data);
685
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
686
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
687
-				$typec = substr($data['ident'],-3);
685
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
686
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
687
+				$typec = substr($data['ident'], -3);
688 688
 				if ($typec == 'APP') $data['type'] = 'Approach';
689 689
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
690 690
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -696,8 +696,8 @@  discard block
 block discarded – undo
696 696
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
697 697
 				if (!isset($data['source_name'])) $data['source_name'] = '';
698 698
 				if (isset($ATC)) {
699
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
700
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
699
+					if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
700
+					else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
701 701
 				}
702 702
 			}
703 703
     			unset($data);
@@ -708,24 +708,24 @@  discard block
 block discarded – undo
708 708
     	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
709 709
     	    $last_exec[$id]['last'] = time();
710 710
     	} elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
711
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
711
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
712 712
 	    if ($buffer != '') {
713 713
 		$all_data = simplexml_load_string($buffer);
714
-		foreach($all_data->children() as $childdata) {
714
+		foreach ($all_data->children() as $childdata) {
715 715
 			$data = array();
716 716
 			$line = $childdata;
717 717
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
718
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
719
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
720
-			$data['latitude'] = (float)$line['pktLatitude'];
721
-			$data['longitude'] = (float)$line['pktLongitude'];
722
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
723
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
724
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
718
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
719
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
720
+			$data['latitude'] = (float) $line['pktLatitude'];
721
+			$data['longitude'] = (float) $line['pktLongitude'];
722
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
723
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
724
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
725 725
 			$data['altitude_relative'] = 'AMSL';
726
-			$data['pilot_id'] = (int)$line['pktPilotID'];
726
+			$data['pilot_id'] = (int) $line['pktPilotID'];
727 727
 			$data['aircraft_icao'] = 'PARAGLIDER';
728
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
728
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
729 729
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
730 730
 			$data['format_source'] = $value['format'];
731 731
 			$SI->add($data);
@@ -733,31 +733,31 @@  discard block
 block discarded – undo
733 733
 		}
734 734
 	    }
735 735
 	    $Source->deleteOldLocationByType('gs');
736
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
736
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
737 737
 	    if ($buffer != '') {
738 738
 		$all_data = simplexml_load_string($buffer);
739
-		foreach($all_data->children() as $childdata) {
739
+		foreach ($all_data->children() as $childdata) {
740 740
 			$data = array();
741 741
 			$line = $childdata;
742
-			$data['id'] = (int)$line['gsID'];
743
-			$data['latitude'] = (float)$line['gsLatitude'];
744
-			$data['longitude'] = (float)$line['gsLongitude'];
745
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
742
+			$data['id'] = (int) $line['gsID'];
743
+			$data['latitude'] = (float) $line['gsLatitude'];
744
+			$data['longitude'] = (float) $line['gsLongitude'];
745
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
746 746
 			$data['altitude_relative'] = 'AMSL';
747
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
747
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
748 748
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
749
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
749
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
750 750
 			} else {
751
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
751
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
752 752
 			}
753 753
 			unset($data);
754 754
 		}
755 755
 	    }
756 756
 	    $last_exec[$id]['last'] = time();
757 757
 	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
758
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
758
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
759 759
 	    if ($buffer != '') {
760
-	    $all_data = json_decode($buffer,true);
760
+	    $all_data = json_decode($buffer, true);
761 761
 	    if (isset($all_data['acList'])) {
762 762
 		$reset = 0;
763 763
 		foreach ($all_data['acList'] as $line) {
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 		    $data['emergency'] = ''; // emergency
775 775
 		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
776 776
 		    
777
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
777
+		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
778 778
 		    else $data['datetime'] = date('Y-m-d H:i:s');
779 779
 		    
780 780
 		    //$data['datetime'] = date('Y-m-d H:i:s');
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
801 801
 		    $data['squawk'] = $line['squawk']; // squawk
802 802
 		    $data['emergency'] = ''; // emergency
803
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
803
+		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
804 804
 		    else $data['datetime'] = date('Y-m-d H:i:s');
805 805
 	    	    $data['format_source'] = 'aircraftlistjson';
806 806
     		    $data['id_source'] = $id_source;
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
817 817
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
818 818
 	    $buffer = $Common->getData($value['host']);
819
-	    $all_data = json_decode($buffer,true);
819
+	    $all_data = json_decode($buffer, true);
820 820
 	    if (isset($all_data['planes'])) {
821 821
 		$reset = 0;
822 822
 		foreach ($all_data['planes'] as $key => $line) {
@@ -833,12 +833,12 @@  discard block
 block discarded – undo
833 833
 		    $data['emergency'] = ''; // emergency
834 834
 		    $data['registration'] = $line[2];
835 835
 		    $data['aircraft_icao'] = $line[0];
836
-		    $deparr = explode('-',$line[1]);
836
+		    $deparr = explode('-', $line[1]);
837 837
 		    if (count($deparr) == 2) {
838 838
 			$data['departure_airport_icao'] = $deparr[0];
839 839
 			$data['arrival_airport_icao'] = $deparr[1];
840 840
 		    }
841
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
841
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
842 842
 	    	    $data['format_source'] = 'planeupdatefaa';
843 843
     		    $data['id_source'] = $id_source;
844 844
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
     	    $last_exec[$id]['last'] = time();
852 852
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
853 853
 	    $buffer = $Common->getData($value['host']);
854
-	    $all_data = json_decode($buffer,true);
854
+	    $all_data = json_decode($buffer, true);
855 855
 	    if (isset($all_data['states'])) {
856 856
 		$reset = 0;
857 857
 		foreach ($all_data['states'] as $key => $line) {
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
 		    //$data['emergency'] = ''; // emergency
869 869
 		    //$data['registration'] = $line[2];
870 870
 		    //$data['aircraft_icao'] = $line[0];
871
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
871
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
872 872
 	    	    $data['format_source'] = 'opensky';
873 873
     		    $data['id_source'] = $id_source;
874 874
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
883 883
 	    //$buffer = $Common->getData($hosts[$id]);
884 884
 	    $buffer = $Common->getData($value['host']);
885
-	    $all_data = json_decode($buffer,true);
885
+	    $all_data = json_decode($buffer, true);
886 886
 	    if (!empty($all_data)) $reset = 0;
887 887
 	    foreach ($all_data as $key => $line) {
888 888
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -915,11 +915,11 @@  discard block
 block discarded – undo
915 915
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
916 916
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
917 917
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
918
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
918
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
919 919
 	    //echo $buffer;
920
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
921
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
922
-	    $all_data = json_decode($buffer,true);
920
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
921
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
922
+	    $all_data = json_decode($buffer, true);
923 923
 	    if (json_last_error() != JSON_ERROR_NONE) {
924 924
 		die(json_last_error_msg());
925 925
 	    }
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 			//$data['departure_airport_iata'] = $line[11];
943 943
 			//$data['arrival_airport_iata'] = $line[12];
944 944
 	    		//$data['emergency'] = ''; // emergency
945
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
945
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
946 946
 	    		$data['format_source'] = 'radarvirtueljson';
947 947
     			$data['id_source'] = $id_source;
948 948
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -958,14 +958,14 @@  discard block
 block discarded – undo
958 958
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
959 959
 	    //$buffer = $Common->getData($hosts[$id]);
960 960
 	    $buffer = $Common->getData($value['host'].'?'.time());
961
-	    $all_data = json_decode(utf8_encode($buffer),true);
961
+	    $all_data = json_decode(utf8_encode($buffer), true);
962 962
 	    
963 963
 	    if (isset($all_data['pireps'])) {
964 964
 		$reset = 0;
965 965
 	        foreach ($all_data['pireps'] as $line) {
966 966
 		    $data = array();
967 967
 		    $data['id'] = $line['id'];
968
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
968
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
969 969
 		    $data['ident'] = $line['callsign']; // ident
970 970
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
971 971
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -995,9 +995,9 @@  discard block
 block discarded – undo
995 995
 			$SI->add($data);
996 996
 		    //    print_r($data);
997 997
     		    } elseif ($line['icon'] == 'ct') {
998
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
999
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1000
-			$typec = substr($data['ident'],-3);
998
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
999
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1000
+			$typec = substr($data['ident'], -3);
1001 1001
 			$data['type'] = '';
1002 1002
 			if ($typec == 'APP') $data['type'] = 'Approach';
1003 1003
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1009 1009
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1010 1010
 			else $data['type'] = 'Observer';
1011
-			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']);
1011
+			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']);
1012 1012
 		    }
1013 1013
 		    unset($data);
1014 1014
 		}
@@ -1020,14 +1020,14 @@  discard block
 block discarded – undo
1020 1020
 	    //$buffer = $Common->getData($hosts[$id]);
1021 1021
 	    if ($globalDebug) echo 'Get Data...'."\n";
1022 1022
 	    $buffer = $Common->getData($value['host']);
1023
-	    $all_data = json_decode($buffer,true);
1023
+	    $all_data = json_decode($buffer, true);
1024 1024
 	    if ($buffer != '' && is_array($all_data)) {
1025 1025
 		$reset = 0;
1026 1026
 		foreach ($all_data as $line) {
1027 1027
 	    	    $data = array();
1028 1028
 	    	    //$data['id'] = $line['id']; // id not usable
1029 1029
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1030
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1030
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1031 1031
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1032 1032
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1033 1033
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
 	    	    //$data['datetime'] = $line['lastupdate'];
1043 1043
 	    	    //$data['last_update'] = $line['lastupdate'];
1044 1044
 	    	    if (isset($value['timezone'])) {
1045
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1045
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1046 1046
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1047 1047
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1048 1048
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1055,14 +1055,14 @@  discard block
 block discarded – undo
1055 1055
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1056 1056
 		    if (isset($line['aircraftname'])) {
1057 1057
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1058
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1059
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1058
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1059
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1060 1060
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1061 1061
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1062 1062
 	    		else {
1063
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1064
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1065
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1063
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1064
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1065
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1066 1066
 	    		}
1067 1067
 	    	    }
1068 1068
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1082,14 +1082,14 @@  discard block
 block discarded – undo
1082 1082
 	    //$buffer = $Common->getData($hosts[$id]);
1083 1083
 	    if ($globalDebug) echo 'Get Data...'."\n";
1084 1084
 	    $buffer = $Common->getData($value['host']);
1085
-	    $all_data = json_decode($buffer,true);
1085
+	    $all_data = json_decode($buffer, true);
1086 1086
 	    if ($buffer != '' && is_array($all_data)) {
1087 1087
 		$reset = 0;
1088 1088
 		foreach ($all_data as $line) {
1089 1089
 	    	    $data = array();
1090 1090
 	    	    //$data['id'] = $line['id']; // id not usable
1091 1091
 	    	    $data['id'] = trim($line['flight_id']);
1092
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1092
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1093 1093
 	    	    $data['pilot_name'] = $line['pilot_name'];
1094 1094
 	    	    $data['pilot_id'] = $line['pilot_id'];
1095 1095
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1141,11 +1141,11 @@  discard block
 block discarded – undo
1141 1141
 		    //$value = $formats[$nb];
1142 1142
 		    $format = $globalSources[$nb]['format'];
1143 1143
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1144
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1144
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1145 1145
 		    } elseif ($format == 'vrstcp') {
1146 1146
 			$buffer = @socket_read($r, 6000);
1147 1147
 		    } else {
1148
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1148
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1149 1149
 		    }
1150 1150
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1151 1151
 		    //echo $buffer."\n";
@@ -1154,8 +1154,8 @@  discard block
 block discarded – undo
1154 1154
 		    $error = false;
1155 1155
 		    //$SI::del();
1156 1156
 		    if ($format == 'vrstcp') {
1157
-			$buffer = explode('},{',$buffer);
1158
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1157
+			$buffer = explode('},{', $buffer);
1158
+		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1159 1159
 		    // SBS format is CSV format
1160 1160
 		    if ($buffer !== FALSE && $buffer != '') {
1161 1161
 			$tt[$format] = 0;
@@ -1189,13 +1189,13 @@  discard block
 block discarded – undo
1189 1189
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1190 1190
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1191 1191
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1192
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1192
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1193 1193
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1194 1194
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1195 1195
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1196 1196
 
1197 1197
 			    if (isset($ais_data['timestamp'])) {
1198
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1198
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1199 1199
 			    } else {
1200 1200
 				$data['datetime'] = date('Y-m-d H:i:s');
1201 1201
 			    }
@@ -1206,10 +1206,10 @@  discard block
 block discarded – undo
1206 1206
                         } elseif ($format == 'flightgearsp') {
1207 1207
                     	    //echo $buffer."\n";
1208 1208
                     	    if (strlen($buffer) > 5) {
1209
-				$line = explode(',',$buffer);
1209
+				$line = explode(',', $buffer);
1210 1210
 				$data = array();
1211 1211
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1212
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1212
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1213 1213
 				$data['ident'] = $line[6];
1214 1214
 				$data['aircraft_name'] = $line[7];
1215 1215
 				$data['longitude'] = $line[1];
@@ -1226,16 +1226,16 @@  discard block
 block discarded – undo
1226 1226
                         } elseif ($format == 'acars') {
1227 1227
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1228 1228
 			    $ACARS->add(trim($buffer));
1229
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1229
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1230 1230
 			    $ACARS->deleteLiveAcarsData();
1231 1231
 			} elseif ($format == 'flightgearmp') {
1232
-			    if (substr($buffer,0,1) != '#') {
1232
+			    if (substr($buffer, 0, 1) != '#') {
1233 1233
 				$data = array();
1234 1234
 				//echo $buffer."\n";
1235
-				$line = explode(' ',$buffer);
1235
+				$line = explode(' ', $buffer);
1236 1236
 				if (count($line) == 11) {
1237
-				    $userserver = explode('@',$line[0]);
1238
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1237
+				    $userserver = explode('@', $line[0]);
1238
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1239 1239
 				    $data['ident'] = $userserver[0];
1240 1240
 				    $data['registration'] = $userserver[0];
1241 1241
 				    $data['latitude'] = $line[4];
@@ -1243,8 +1243,8 @@  discard block
 block discarded – undo
1243 1243
 				    $data['altitude'] = $line[6];
1244 1244
 				    $data['datetime'] = date('Y-m-d H:i:s');
1245 1245
 				    $aircraft_type = $line[10];
1246
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1247
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1246
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1247
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1248 1248
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1249 1249
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1250 1250
 				}
@@ -1253,8 +1253,8 @@  discard block
 block discarded – undo
1253 1253
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1254 1254
 			    die;
1255 1255
 			} elseif ($format == 'vrstcp') {
1256
-			    foreach($buffer as $all_data) {
1257
-				$line = json_decode('{'.$all_data.'}',true);
1256
+			    foreach ($buffer as $all_data) {
1257
+				$line = json_decode('{'.$all_data.'}', true);
1258 1258
 				$data = array();
1259 1259
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1260 1260
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1280,16 +1280,16 @@  discard block
 block discarded – undo
1280 1280
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1281 1281
 				unset($data);
1282 1282
 			    }
1283
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1283
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1284 1284
 			    $line = explode("\t", $buffer);
1285
-			    for($k = 0; $k < count($line); $k=$k+2) {
1285
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1286 1286
 				$key = $line[$k];
1287
-			        $lined[$key] = $line[$k+1];
1287
+			        $lined[$key] = $line[$k + 1];
1288 1288
 			    }
1289 1289
     			    if (count($lined) > 3) {
1290 1290
     				$data['hex'] = $lined['hexid'];
1291 1291
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1292
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1292
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1293 1293
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1294 1294
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1295 1295
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1308,22 +1308,22 @@  discard block
 block discarded – undo
1308 1308
     			    } else $error = true;
1309 1309
 			} elseif ($format == 'aprs' && $use_aprs) {
1310 1310
 			    if ($aprs_connect == 0) {
1311
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1311
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1312 1312
 				$aprs_connect = 1;
1313 1313
 			    }
1314 1314
 			    
1315
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1315
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1316 1316
 				$aprs_last_tx = time();
1317 1317
 				$data_aprs = "# Keep alive";
1318
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1318
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1319 1319
 			    }
1320 1320
 			    
1321 1321
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1322 1322
 			    //echo 'APRS data : '.$buffer."\n";
1323
-			    $buffer = str_replace('APRS <- ','',$buffer);
1324
-			    $buffer = str_replace('APRS -> ','',$buffer);
1323
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1324
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1325 1325
 			    //echo $buffer."\n";
1326
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1326
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1327 1327
 				$line = $APRS->parse($buffer);
1328 1328
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1329 1329
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1338,7 +1338,7 @@  discard block
 block discarded – undo
1338 1338
 				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1339 1339
 				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1340 1340
 				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1341
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1341
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1342 1342
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1343 1343
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1344 1344
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1386,9 +1386,9 @@  discard block
 block discarded – undo
1386 1386
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1387 1387
 					$Source->deleteOldLocationByType('gs');
1388 1388
 					if (count($Source->getLocationInfoByName($data['ident'])) > 0) {
1389
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1389
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1390 1390
 					} else {
1391
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1391
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1392 1392
 					}
1393 1393
 				    } else {
1394 1394
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
 				}
1402 1402
 				 
1403 1403
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1404
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1404
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1405 1405
 				}
1406 1406
 				/*
1407 1407
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
@@ -1488,7 +1488,7 @@  discard block
 block discarded – undo
1488 1488
 				connect_all($sourceee);
1489 1489
 				$sourceee = array();
1490 1490
 				//connect_all($globalSources);
1491
-				$tt[$format]=0;
1491
+				$tt[$format] = 0;
1492 1492
 				break;
1493 1493
 			    }
1494 1494
 			}
@@ -1497,14 +1497,14 @@  discard block
 block discarded – undo
1497 1497
 	    } else {
1498 1498
 		$error = socket_strerror(socket_last_error());
1499 1499
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1500
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1500
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1501 1501
 			if (isset($globalDebug)) echo "Restarting...\n";
1502 1502
 			// Restart the script if possible
1503 1503
 			if (is_array($sockets)) {
1504 1504
 			    if ($globalDebug) echo "Shutdown all sockets...";
1505 1505
 			    
1506 1506
 			    foreach ($sockets as $sock) {
1507
-				@socket_shutdown($sock,2);
1507
+				@socket_shutdown($sock, 2);
1508 1508
 				@socket_close($sock);
1509 1509
 			    }
1510 1510
 			    
Please login to merge, or discard this patch.
Braces   +993 added lines, -342 removed lines patch added patch discarded remove patch
@@ -14,13 +14,17 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Source.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17
+if (isset($globalTracker) && $globalTracker) {
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19
+}
18 20
 if (isset($globalMarine) && $globalMarine) {
19 21
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
20 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 23
 }
22 24
 
23
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
24 28
 
25 29
 // Check if schema is at latest version
26 30
 $Connection = new Connection();
@@ -55,35 +59,62 @@  discard block
 block discarded – undo
55 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
56 60
 if (isset($options['s'])) {
57 61
     $globalSources = array();
58
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
59
-    else $globalSources[] = array('host' => $options['s']);
60
-} elseif (isset($options['source'])) {
62
+    if (isset($options['format'])) {
63
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
64
+    } else {
65
+    	$globalSources[] = array('host' => $options['s']);
66
+    }
67
+    } elseif (isset($options['source'])) {
61 68
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['source']);
64
-}
69
+    if (isset($options['format'])) {
70
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
71
+    } else {
72
+    	$globalSources[] = array('host' => $options['source']);
73
+    }
74
+    }
65 75
 if (isset($options['aprsserverhost'])) {
66 76
 	$globalServerAPRS = TRUE;
67 77
 	$globalServerAPRShost = $options['aprsserverhost'];
68 78
 }
69
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
70
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
71
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
72
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
73
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
74
-if (isset($options['server'])) $globalServer = TRUE;
75
-if (isset($options['idsource'])) $id_source = $options['idsource'];
76
-else $id_source = 1;
79
+if (isset($options['aprsserverport'])) {
80
+	$globalServerAPRSport = $options['aprsserverport'];
81
+}
82
+if (isset($options['aprsserverssid'])) {
83
+	$globalServerAPRSssid = $options['aprsserverssid'];
84
+}
85
+if (isset($options['aprsserverpass'])) {
86
+	$globalServerAPRSpass = $options['aprsserverpass'];
87
+}
88
+if (isset($options['noaprsserver'])) {
89
+	$globalServerAPRS = FALSE;
90
+}
91
+if (isset($options['nodaemon'])) {
92
+	$globalDaemon = FALSE;
93
+}
94
+if (isset($options['server'])) {
95
+	$globalServer = TRUE;
96
+}
97
+if (isset($options['idsource'])) {
98
+	$id_source = $options['idsource'];
99
+} else {
100
+	$id_source = 1;
101
+}
77 102
 if (isset($globalServer) && $globalServer) {
78
-    if ($globalDebug) echo "Using Server Mode\n";
103
+    if ($globalDebug) {
104
+    	echo "Using Server Mode\n";
105
+    }
79 106
     $SI=new SpotterServer();
80 107
 /*
81 108
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
82 109
     $SI = new adsb2aprs();
83 110
     $SI->connect();
84 111
 */
85
-} else $SI=new SpotterImport($Connection->db);
86
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
112
+} else {
113
+	$SI=new SpotterImport($Connection->db);
114
+}
115
+if (isset($globalTracker) && $globalTracker) {
116
+	$TI = new TrackerImport($Connection->db);
117
+}
87 118
 if (isset($globalMarine) && $globalMarine) {
88 119
     $AIS = new AIS();
89 120
     $MI = new MarineImport($Connection->db);
@@ -106,7 +137,9 @@  discard block
 block discarded – undo
106 137
 }
107 138
 
108 139
 // let's try and connect
109
-if ($globalDebug) echo "Connecting...\n";
140
+if ($globalDebug) {
141
+	echo "Connecting...\n";
142
+}
110 143
 $use_aprs = false;
111 144
 $aprs_full = false;
112 145
 $reset = 0;
@@ -115,7 +148,9 @@  discard block
 block discarded – undo
115 148
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116 149
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
117 150
     $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
151
+    if ($globalDebug) {
152
+    	echo 'Connect to all...'."\n";
153
+    }
119 154
     foreach ($hosts as $id => $value) {
120 155
 	$host = $value['host'];
121 156
 	$globalSources[$id]['last_exec'] = 0;
@@ -125,22 +160,30 @@  discard block
 block discarded – undo
125 160
         	//$formats[$id] = 'deltadbtxt';
126 161
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 162
         	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
163
+        	if ($globalDebug) {
164
+        		echo "Connect to deltadb source (".$host.")...\n";
165
+        	}
129 166
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130 167
         	//$formats[$id] = 'vatsimtxt';
131 168
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 169
         	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
170
+        	if ($globalDebug) {
171
+        		echo "Connect to vatsim source (".$host.")...\n";
172
+        	}
134 173
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135 174
         	//$formats[$id] = 'aircraftlistjson';
136 175
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 176
         	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
177
+        	if ($globalDebug) {
178
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
179
+        	}
139 180
     	    } else if (preg_match('/opensky/i',$host)) {
140 181
         	//$formats[$id] = 'aircraftlistjson';
141 182
         	$globalSources[$id]['format'] = 'opensky';
142 183
         	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
184
+        	if ($globalDebug) {
185
+        		echo "Connect to opensky source (".$host.")...\n";
186
+        	}
144 187
     	    /*
145 188
     	    // Disabled for now, site change source format
146 189
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -157,7 +200,9 @@  discard block
 block discarded – undo
157 200
         	//$formats[$id] = 'planeupdatefaa';
158 201
         	$globalSources[$id]['format'] = 'planeupdatefaa';
159 202
         	//$last_exec['planeupdatefaa'] = 0;
160
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
203
+        	if ($globalDebug) {
204
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
205
+        	}
161 206
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
162 207
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163 208
         	    exit(0);
@@ -166,29 +211,41 @@  discard block
 block discarded – undo
166 211
         	//$formats[$id] = 'phpvmacars';
167 212
         	$globalSources[$id]['format'] = 'phpvmacars';
168 213
         	//$last_exec['phpvmacars'] = 0;
169
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
214
+        	if ($globalDebug) {
215
+        		echo "Connect to phpvmacars source (".$host.")...\n";
216
+        	}
170 217
             } else if (preg_match('/VAM-json.php$/i',$host)) {
171 218
         	//$formats[$id] = 'phpvmacars';
172 219
         	$globalSources[$id]['format'] = 'vam';
173
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
220
+        	if ($globalDebug) {
221
+        		echo "Connect to Vam source (".$host.")...\n";
222
+        	}
174 223
             } else if (preg_match('/whazzup/i',$host)) {
175 224
         	//$formats[$id] = 'whazzup';
176 225
         	$globalSources[$id]['format'] = 'whazzup';
177 226
         	//$last_exec['whazzup'] = 0;
178
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
227
+        	if ($globalDebug) {
228
+        		echo "Connect to whazzup source (".$host.")...\n";
229
+        	}
179 230
             } else if (preg_match('/airwhere/i',$host)) {
180 231
         	$globalSources[$id]['format'] = 'airwhere';
181
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
232
+        	if ($globalDebug) {
233
+        		echo "Connect to airwhere source (".$host.")...\n";
234
+        	}
182 235
             } else if (preg_match('/recentpireps/i',$host)) {
183 236
         	//$formats[$id] = 'pirepsjson';
184 237
         	$globalSources[$id]['format'] = 'pirepsjson';
185 238
         	//$last_exec['pirepsjson'] = 0;
186
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
239
+        	if ($globalDebug) {
240
+        		echo "Connect to pirepsjson source (".$host.")...\n";
241
+        	}
187 242
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
188 243
         	//$formats[$id] = 'fr24json';
189 244
         	$globalSources[$id]['format'] = 'fr24json';
190 245
         	//$last_exec['fr24json'] = 0;
191
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
246
+        	if ($globalDebug) {
247
+        		echo "Connect to fr24 source (".$host.")...\n";
248
+        	}
192 249
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
193 250
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
194 251
         	    exit(0);
@@ -197,7 +254,9 @@  discard block
 block discarded – undo
197 254
         	//$formats[$id] = 'fr24json';
198 255
         	$globalSources[$id]['format'] = 'myshiptracking';
199 256
         	//$last_exec['fr24json'] = 0;
200
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
257
+        	if ($globalDebug) {
258
+        		echo "Connect to myshiptracking source (".$host.")...\n";
259
+        	}
201 260
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
202 261
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
203 262
         	    exit(0);
@@ -206,17 +265,24 @@  discard block
 block discarded – undo
206 265
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
207 266
         	//$formats[$id] = 'tsv';
208 267
         	$globalSources[$id]['format'] = 'tsv';
209
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
268
+        	if ($globalDebug) {
269
+        		echo "Connect to tsv source (".$host.")...\n";
270
+        	}
210 271
             }
211 272
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
212 273
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
213 274
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
214 275
     		    if ($idf !== false) {
215 276
     			$httpfeeds[$id] = $idf;
216
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
277
+        		if ($globalDebug) {
278
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
279
+        		}
280
+    		    } elseif ($globalDebug) {
281
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
217 282
     		    }
218
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
219
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
283
+    		} elseif ($globalDebug) {
284
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
285
+    		}
220 286
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
221 287
 	    $hostport = explode(':',$host);
222 288
 	    if (isset($hostport[1])) {
@@ -256,17 +322,25 @@  discard block
 block discarded – undo
256 322
         		//$formats[$id] = 'beast';
257 323
         		$globalSources[$id]['format'] = 'beast';
258 324
 		    //} else $formats[$id] = 'sbs';
259
-		    } else $globalSources[$id]['format'] = 'sbs';
325
+		    } else {
326
+		    	$globalSources[$id]['format'] = 'sbs';
327
+		    }
260 328
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
261 329
 		}
262
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
330
+		if ($globalDebug) {
331
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
332
+		}
263 333
             } else {
264
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
334
+		if ($globalDebug) {
335
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
336
+		}
265 337
     	    }
266 338
         }
267 339
     }
268 340
 }
269
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
341
+if (!isset($globalMinFetch)) {
342
+	$globalMinFetch = 15;
343
+}
270 344
 
271 345
 // Initialize all
272 346
 $status = array();
@@ -275,13 +349,19 @@  discard block
 block discarded – undo
275 349
 $formats = array();
276 350
 $last_exec = array();
277 351
 $time = time();
278
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
279
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
280
-else $timeout = 20;
352
+if (isset($globalSourcesTimeout)) {
353
+	$timeout = $globalSourcesTimeOut;
354
+} else if (isset($globalSBS1TimeOut)) {
355
+	$timeout = $globalSBS1TimeOut;
356
+} else {
357
+	$timeout = 20;
358
+}
281 359
 $errno = '';
282 360
 $errstr='';
283 361
 
284
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
362
+if (!isset($globalDaemon)) {
363
+	$globalDaemon = TRUE;
364
+}
285 365
 /* Initiate connections to all the hosts simultaneously */
286 366
 //connect_all($hosts);
287 367
 //connect_all($globalSources);
@@ -307,7 +387,9 @@  discard block
 block discarded – undo
307 387
     if (isset($source['format']) && $source['format'] == 'aprs') {
308 388
 	$aprs_connect = 0;
309 389
 	$use_aprs = true;
310
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
390
+	if (isset($source['port']) && $source['port'] == '10152') {
391
+		$aprs_full = true;
392
+	}
311 393
 	break;
312 394
     }
313 395
 }
@@ -318,25 +400,48 @@  discard block
 block discarded – undo
318 400
 	$aprs_connect = 0;
319 401
 	$aprs_keep = 120;
320 402
 	$aprs_last_tx = time();
321
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
322
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
323
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
324
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
325
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
326
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
327
-	if ($aprs_full) $aprs_filter = '';
328
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
329
-	else $aprs_pass = '-1';
403
+	if (isset($globalAPRSversion)) {
404
+		$aprs_version = $globalAPRSversion;
405
+	} else {
406
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
407
+	}
408
+	if (isset($globalAPRSssid)) {
409
+		$aprs_ssid = $globalAPRSssid;
410
+	} else {
411
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
412
+	}
413
+	if (isset($globalAPRSfilter)) {
414
+		$aprs_filter = $globalAPRSfilter;
415
+	} else {
416
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
417
+	}
418
+	if ($aprs_full) {
419
+		$aprs_filter = '';
420
+	}
421
+	if (isset($globalAPRSpass)) {
422
+		$aprs_pass = $globalAPRSpass;
423
+	} else {
424
+		$aprs_pass = '-1';
425
+	}
330 426
 
331
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
332
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
333
-}
427
+	if ($aprs_filter != '') {
428
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
429
+	} else {
430
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
431
+	}
432
+	}
334 433
 
335 434
 // connected - lets do some work
336
-if ($globalDebug) echo "Connected!\n";
435
+if ($globalDebug) {
436
+	echo "Connected!\n";
437
+}
337 438
 sleep(1);
338
-if ($globalDebug) echo "SCAN MODE \n\n";
339
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
439
+if ($globalDebug) {
440
+	echo "SCAN MODE \n\n";
441
+}
442
+if (!isset($globalCronEnd)) {
443
+	$globalCronEnd = 60;
444
+}
340 445
 $endtime = time()+$globalCronEnd;
341 446
 $i = 1;
342 447
 $tt = array();
@@ -350,20 +455,28 @@  discard block
 block discarded – undo
350 455
 
351 456
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
352 457
 while ($i > 0) {
353
-    if (!$globalDaemon) $i = $endtime-time();
458
+    if (!$globalDaemon) {
459
+    	$i = $endtime-time();
460
+    }
354 461
     // Delete old ATC
355 462
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
356
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
463
+	if ($globalDebug) {
464
+		echo 'Delete old ATC...'."\n";
465
+	}
357 466
         $ATC->deleteOldATC();
358 467
     }
359 468
     
360 469
     if (count($last_exec) == count($globalSources)) {
361 470
 	$max = $globalMinFetch;
362 471
 	foreach ($last_exec as $last) {
363
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
472
+	    if ((time() - $last['last']) < $max) {
473
+	    	$max = time() - $last['last'];
474
+	    }
364 475
 	}
365 476
 	if ($max != $globalMinFetch) {
366
-	    if ($globalDebug) echo 'Sleeping...'."\n";
477
+	    if ($globalDebug) {
478
+	    	echo 'Sleeping...'."\n";
479
+	    }
367 480
 	    sleep($globalMinFetch-$max+2);
368 481
 	}
369 482
     }
@@ -372,11 +485,15 @@  discard block
 block discarded – undo
372 485
     //foreach ($formats as $id => $value) {
373 486
     foreach ($globalSources as $id => $value) {
374 487
 	date_default_timezone_set('UTC');
375
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
488
+	if (!isset($last_exec[$id]['last'])) {
489
+		$last_exec[$id]['last'] = 0;
490
+	}
376 491
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
377 492
 	    //$buffer = $Common->getData($hosts[$id]);
378 493
 	    $buffer = $Common->getData($value['host']);
379
-	    if ($buffer != '') $reset = 0;
494
+	    if ($buffer != '') {
495
+	    	$reset = 0;
496
+	    }
380 497
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
381 498
 	    $buffer = explode('\n',$buffer);
382 499
 	    foreach ($buffer as $line) {
@@ -385,20 +502,41 @@  discard block
 block discarded – undo
385 502
 	            $data = array();
386 503
 	            $data['hex'] = $line[1]; // hex
387 504
 	            $data['ident'] = $line[2]; // ident
388
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
389
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
390
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
391
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
392
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
505
+	            if (isset($line[3])) {
506
+	            	$data['altitude'] = $line[3];
507
+	            }
508
+	            // altitude
509
+	            if (isset($line[4])) {
510
+	            	$data['speed'] = $line[4];
511
+	            }
512
+	            // speed
513
+	            if (isset($line[5])) {
514
+	            	$data['heading'] = $line[5];
515
+	            }
516
+	            // heading
517
+	            if (isset($line[6])) {
518
+	            	$data['latitude'] = $line[6];
519
+	            }
520
+	            // lat
521
+	            if (isset($line[7])) {
522
+	            	$data['longitude'] = $line[7];
523
+	            }
524
+	            // long
393 525
 	            $data['verticalrate'] = ''; // vertical rate
394 526
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
395 527
 	            $data['emergency'] = ''; // emergency
396 528
 		    $data['datetime'] = date('Y-m-d H:i:s');
397 529
 		    $data['format_source'] = 'deltadbtxt';
398 530
     		    $data['id_source'] = $id_source;
399
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
400
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
401
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
531
+		    if (isset($value['name']) && $value['name'] != '') {
532
+		    	$data['source_name'] = $value['name'];
533
+		    }
534
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
535
+		    	$data['noarchive'] = true;
536
+		    }
537
+		    if (isset($value['sourcestats'])) {
538
+		    	$data['sourcestats'] = $value['sourcestats'];
539
+		    }
402 540
     		    $SI->add($data);
403 541
 		    unset($data);
404 542
     		}
@@ -408,7 +546,9 @@  discard block
 block discarded – undo
408 546
 	    date_default_timezone_set('CET');
409 547
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
410 548
 	    date_default_timezone_set('UTC');
411
-	    if ($buffer != '') $reset = 0;
549
+	    if ($buffer != '') {
550
+	    	$reset = 0;
551
+	    }
412 552
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
413 553
 	    $buffer = explode('\n',$buffer);
414 554
 	    foreach ($buffer as $line) {
@@ -417,16 +557,36 @@  discard block
 block discarded – undo
417 557
 		    $add = false;
418 558
 		    $ais_data = $AIS->parse_line(trim($line));
419 559
 		    $data = array();
420
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
421
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
422
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
423
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
424
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
425
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
426
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
427
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
428
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
429
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
560
+		    if (isset($ais_data['ident'])) {
561
+		    	$data['ident'] = $ais_data['ident'];
562
+		    }
563
+		    if (isset($ais_data['mmsi'])) {
564
+		    	$data['mmsi'] = $ais_data['mmsi'];
565
+		    }
566
+		    if (isset($ais_data['speed'])) {
567
+		    	$data['speed'] = $ais_data['speed'];
568
+		    }
569
+		    if (isset($ais_data['heading'])) {
570
+		    	$data['heading'] = $ais_data['heading'];
571
+		    }
572
+		    if (isset($ais_data['latitude'])) {
573
+		    	$data['latitude'] = $ais_data['latitude'];
574
+		    }
575
+		    if (isset($ais_data['longitude'])) {
576
+		    	$data['longitude'] = $ais_data['longitude'];
577
+		    }
578
+		    if (isset($ais_data['status'])) {
579
+		    	$data['status'] = $ais_data['status'];
580
+		    }
581
+		    if (isset($ais_data['type'])) {
582
+		    	$data['type'] = $ais_data['type'];
583
+		    }
584
+		    if (isset($ais_data['imo'])) {
585
+		    	$data['imo'] = $ais_data['imo'];
586
+		    }
587
+		    if (isset($ais_data['callsign'])) {
588
+		    	$data['callsign'] = $ais_data['callsign'];
589
+		    }
430 590
 		    if (isset($ais_data['timestamp'])) {
431 591
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
432 592
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -440,8 +600,12 @@  discard block
 block discarded – undo
440 600
 		    $data['format_source'] = 'aisnmeatxt';
441 601
     		    $data['id_source'] = $id_source;
442 602
 		    //print_r($data);
443
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
444
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
603
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
604
+		    	$data['noarchive'] = true;
605
+		    }
606
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
607
+		    	$MI->add($data);
608
+		    }
445 609
 		    unset($data);
446 610
 		}
447 611
     	    }
@@ -461,20 +625,48 @@  discard block
 block discarded – undo
461 625
 			    if ($line != '') {
462 626
 				$ais_data = $AIS->parse_line(trim($line));
463 627
 				$data = array();
464
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
465
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
466
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
467
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
468
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
469
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
470
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
471
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
472
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
473
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
474
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
475
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
476
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
477
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
628
+				if (isset($ais_data['ident'])) {
629
+					$data['ident'] = $ais_data['ident'];
630
+				}
631
+				if (isset($ais_data['mmsi'])) {
632
+					$data['mmsi'] = $ais_data['mmsi'];
633
+				}
634
+				if (isset($ais_data['speed'])) {
635
+					$data['speed'] = $ais_data['speed'];
636
+				}
637
+				if (isset($ais_data['heading'])) {
638
+					$data['heading'] = $ais_data['heading'];
639
+				}
640
+				if (isset($ais_data['latitude'])) {
641
+					$data['latitude'] = $ais_data['latitude'];
642
+				}
643
+				if (isset($ais_data['longitude'])) {
644
+					$data['longitude'] = $ais_data['longitude'];
645
+				}
646
+				if (isset($ais_data['status'])) {
647
+					$data['status'] = $ais_data['status'];
648
+				}
649
+				if (isset($ais_data['statusid'])) {
650
+					$data['status_id'] = $ais_data['statusid'];
651
+				}
652
+				if (isset($ais_data['type'])) {
653
+					$data['type'] = $ais_data['type'];
654
+				}
655
+				if (isset($ais_data['typeid'])) {
656
+					$data['type_id'] = $ais_data['typeid'];
657
+				}
658
+				if (isset($ais_data['imo'])) {
659
+					$data['imo'] = $ais_data['imo'];
660
+				}
661
+				if (isset($ais_data['callsign'])) {
662
+					$data['callsign'] = $ais_data['callsign'];
663
+				}
664
+				if (isset($ais_data['destination'])) {
665
+					$data['arrival_code'] = $ais_data['destination'];
666
+				}
667
+				if (isset($ais_data['eta_ts'])) {
668
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
669
+				}
478 670
 				if (isset($ais_data['timestamp'])) {
479 671
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
480 672
 				} else {
@@ -482,18 +674,27 @@  discard block
 block discarded – undo
482 674
 				}
483 675
 				$data['format_source'] = 'aisnmeahttp';
484 676
 				$data['id_source'] = $id_source;
485
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
486
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
677
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
678
+					$data['noarchive'] = true;
679
+				}
680
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
681
+					$MI->add($data);
682
+				}
487 683
 				unset($data);
488 684
 			    }
489 685
 			}
490 686
 		    }
491 687
 		} else {
492 688
 		    $format = $value['format'];
493
-		    if (isset($tt[$format])) $tt[$format]++;
494
-		    else $tt[$format] = 0;
689
+		    if (isset($tt[$format])) {
690
+		    	$tt[$format]++;
691
+		    } else {
692
+		    	$tt[$format] = 0;
693
+		    }
495 694
 		    if ($tt[$format] > 30) {
496
-			if ($globalDebug) echo 'Reconnect...'."\n";
695
+			if ($globalDebug) {
696
+				echo 'Reconnect...'."\n";
697
+			}
497 698
 			sleep(2);
498 699
 			$sourceeen[] = $value;
499 700
 			connect_all($sourceeen);
@@ -523,7 +724,9 @@  discard block
 block discarded – undo
523 724
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
524 725
 			    $data['format_source'] = 'myshiptracking';
525 726
 			    $data['id_source'] = $id_source;
526
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
727
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
728
+			    	$data['noarchive'] = true;
729
+			    }
527 730
 			    $MI->add($data);
528 731
 			    unset($data);
529 732
 			}
@@ -543,7 +746,9 @@  discard block
 block discarded – undo
543 746
 			    $data['callsign'] = $line['callsign'];
544 747
 			    $data['mmsi'] = $line['mmsi'];
545 748
 			    $data['speed'] = $line['sog'];
546
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
749
+			    if ($line['heading'] != '511') {
750
+			    	$data['heading'] = $line['heading'];
751
+			    }
547 752
 			    $data['latitude'] = $line['latitude'];
548 753
 			    $data['longitude'] = $line['longitude'];
549 754
 			    $data['type_id'] = $line['shiptype'];
@@ -551,7 +756,9 @@  discard block
 block discarded – undo
551 756
 			    $data['datetime'] = $line['time'];
552 757
 			    $data['format_source'] = 'boatbeaconapp';
553 758
 			    $data['id_source'] = $id_source;
554
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
759
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
760
+			    	$data['noarchive'] = true;
761
+			    }
555 762
 			    $MI->add($data);
556 763
 			    unset($data);
557 764
 			}
@@ -567,22 +774,44 @@  discard block
 block discarded – undo
567 774
 		if (isset($all_data['features'][0]['id'])) {
568 775
 		    foreach ($all_data['features'] as $line) {
569 776
 			$data = array();
570
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
571
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
572
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi'];
573
-			if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo'];
574
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
575
-			if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading'];
777
+			if (isset($line['properties']['name'])) {
778
+				$data['ident'] = $line['properties']['name'];
779
+			}
780
+			if (isset($line['properties']['callsign'])) {
781
+				$data['callsign'] = $line['properties']['callsign'];
782
+			}
783
+			if (isset($line['properties']['mmsi'])) {
784
+				$data['mmsi'] = $line['properties']['mmsi'];
785
+			}
786
+			if (isset($line['properties']['imo'])) {
787
+				$data['mmsi'] = $line['properties']['imo'];
788
+			}
789
+			if (isset($line['properties']['speed'])) {
790
+				$data['speed'] = $line['properties']['speed'];
791
+			}
792
+			if (isset($line['properties']['heading'])) {
793
+				$data['heading'] = $line['properties']['heading'];
794
+			}
576 795
 			$data['latitude'] = $line['geometry']['coordinates'][1];
577 796
 			$data['longitude'] = $line['geometry']['coordinates'][0];
578
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
579
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
580
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
797
+			if (isset($line['properties']['vesselType'])) {
798
+				$data['type'] = $line['properties']['vesselType'];
799
+			}
800
+			if (isset($line['properties']['destination'])) {
801
+				$data['arrival_code'] = $line['properties']['destination'];
802
+			}
803
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
804
+				$data['arrival_date'] = $line['properties']['eta'];
805
+			}
581 806
 			$data['format_source'] = 'boatnerd';
582 807
 			$data['id_source'] = $id_source;
583 808
 			$data['datetime'] = date('Y-m-d H:i:s');
584
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
585
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
809
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
810
+				$data['noarchive'] = true;
811
+			}
812
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
813
+				$MI->add($data);
814
+			}
586 815
 			unset($data);
587 816
 		    }
588 817
 		}
@@ -593,7 +822,9 @@  discard block
 block discarded – undo
593 822
 	    echo 'download...';
594 823
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
595 824
 	    echo 'done !'."\n";
596
-	    if ($buffer != '') $reset = 0;
825
+	    if ($buffer != '') {
826
+	    	$reset = 0;
827
+	    }
597 828
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
598 829
 	    $buffer = explode('\n',$buffer);
599 830
 	    foreach ($buffer as $line) {
@@ -618,7 +849,9 @@  discard block
 block discarded – undo
618 849
 		    //$data['etaTime'] = substr($line,135,5);
619 850
 		    $data['format_source'] = 'shipplotter';
620 851
     		    $data['id_source'] = $id_source;
621
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
852
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
853
+		    	$data['noarchive'] = true;
854
+		    }
622 855
 		    //print_r($data);
623 856
 		    echo 'Add...'."\n";
624 857
 		    $MI->add($data);
@@ -638,16 +871,28 @@  discard block
 block discarded – undo
638 871
     		    $line = explode(':', $line);
639 872
     		    if (count($line) > 30 && $line[0] != 'callsign') {
640 873
 			$data = array();
641
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
642
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
874
+			if (isset($line[37]) && $line[37] != '') {
875
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
876
+			} else {
877
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
878
+			}
643 879
 			$data['pilot_id'] = $line[1];
644 880
 			$data['pilot_name'] = $line[2];
645 881
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
646 882
 			$data['ident'] = $line[0]; // ident
647
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
883
+			if ($line[7] != '' && $line[7] != 0) {
884
+				$data['altitude'] = $line[7];
885
+			}
886
+			// altitude
648 887
 			$data['speed'] = $line[8]; // speed
649
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
650
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
888
+			if (isset($line[45])) {
889
+				$data['heading'] = $line[45];
890
+			}
891
+			// heading
892
+			elseif (isset($line[38])) {
893
+				$data['heading'] = $line[38];
894
+			}
895
+			// heading
651 896
 			$data['latitude'] = $line[5]; // lat
652 897
 	        	$data['longitude'] = $line[6]; // long
653 898
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -663,7 +908,9 @@  discard block
 block discarded – undo
663 908
 			$data['frequency'] = $line[4];
664 909
 			$data['type'] = $line[18];
665 910
 			$data['range'] = $line[19];
666
-			if (isset($line[35])) $data['info'] = $line[35];
911
+			if (isset($line[35])) {
912
+				$data['info'] = $line[35];
913
+			}
667 914
     			$data['id_source'] = $id_source;
668 915
 	    		//$data['arrival_airport_time'] = ;
669 916
 	    		if ($line[9] != '') {
@@ -677,27 +924,47 @@  discard block
 block discarded – undo
677 924
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
678 925
 	    		*/
679 926
 	    		$data['format_source'] = $value['format'];
680
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
681
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
682
-    			if ($line[3] == 'PILOT') $SI->add($data);
683
-			elseif ($line[3] == 'ATC') {
927
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
928
+				$data['noarchive'] = true;
929
+			}
930
+			if (isset($value['name']) && $value['name'] != '') {
931
+				$data['source_name'] = $value['name'];
932
+			}
933
+    			if ($line[3] == 'PILOT') {
934
+    				$SI->add($data);
935
+    			} elseif ($line[3] == 'ATC') {
684 936
 				//print_r($data);
685 937
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
686 938
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
687 939
 				$typec = substr($data['ident'],-3);
688
-				if ($typec == 'APP') $data['type'] = 'Approach';
689
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
690
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
691
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
692
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
693
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
694
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
695
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
696
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
697
-				if (!isset($data['source_name'])) $data['source_name'] = '';
940
+				if ($typec == 'APP') {
941
+					$data['type'] = 'Approach';
942
+				} elseif ($typec == 'TWR') {
943
+					$data['type'] = 'Tower';
944
+				} elseif ($typec == 'OBS') {
945
+					$data['type'] = 'Observer';
946
+				} elseif ($typec == 'GND') {
947
+					$data['type'] = 'Ground';
948
+				} elseif ($typec == 'DEL') {
949
+					$data['type'] = 'Delivery';
950
+				} elseif ($typec == 'DEP') {
951
+					$data['type'] = 'Departure';
952
+				} elseif ($typec == 'FSS') {
953
+					$data['type'] = 'Flight Service Station';
954
+				} elseif ($typec == 'CTR') {
955
+					$data['type'] = 'Control Radar or Centre';
956
+				} elseif ($data['type'] == '') {
957
+					$data['type'] = 'Observer';
958
+				}
959
+				if (!isset($data['source_name'])) {
960
+					$data['source_name'] = '';
961
+				}
698 962
 				if (isset($ATC)) {
699
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
700
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
963
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
964
+						echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
965
+					} else {
966
+						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']);
967
+					}
701 968
 				}
702 969
 			}
703 970
     			unset($data);
@@ -719,14 +986,20 @@  discard block
 block discarded – undo
719 986
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
720 987
 			$data['latitude'] = (float)$line['pktLatitude'];
721 988
 			$data['longitude'] = (float)$line['pktLongitude'];
722
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
723
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
989
+			if ((float)$line['pktTrack'] != 0) {
990
+				$data['heading'] = (float)$line['pktTrack'];
991
+			}
992
+			if ((int)$line['pktSpeed'] != 0) {
993
+				$data['speed'] = (int)$line['pktSpeed'];
994
+			}
724 995
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
725 996
 			$data['altitude_relative'] = 'AMSL';
726 997
 			$data['pilot_id'] = (int)$line['pktPilotID'];
727 998
 			$data['aircraft_icao'] = 'PARAGLIDER';
728 999
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
729
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1000
+			if (isset($pilot_data[4])) {
1001
+				$data['pilot_name'] = $pilot_data[4];
1002
+			}
730 1003
 			$data['format_source'] = $value['format'];
731 1004
 			$SI->add($data);
732 1005
 			unset($data);
@@ -763,27 +1036,61 @@  discard block
 block discarded – undo
763 1036
 		foreach ($all_data['acList'] as $line) {
764 1037
 		    $data = array();
765 1038
 		    $data['hex'] = $line['Icao']; // hex
766
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
767
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
768
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
769
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
770
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
771
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1039
+		    if (isset($line['Call'])) {
1040
+		    	$data['ident'] = $line['Call'];
1041
+		    }
1042
+		    // ident
1043
+		    if (isset($line['Alt'])) {
1044
+		    	$data['altitude'] = $line['Alt'];
1045
+		    }
1046
+		    // altitude
1047
+		    if (isset($line['Spd'])) {
1048
+		    	$data['speed'] = $line['Spd'];
1049
+		    }
1050
+		    // speed
1051
+		    if (isset($line['Trak'])) {
1052
+		    	$data['heading'] = $line['Trak'];
1053
+		    }
1054
+		    // heading
1055
+		    if (isset($line['Lat'])) {
1056
+		    	$data['latitude'] = $line['Lat'];
1057
+		    }
1058
+		    // lat
1059
+		    if (isset($line['Long'])) {
1060
+		    	$data['longitude'] = $line['Long'];
1061
+		    }
1062
+		    // long
772 1063
 		    //$data['verticalrate'] = $line['']; // verticale rate
773
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1064
+		    if (isset($line['Sqk'])) {
1065
+		    	$data['squawk'] = $line['Sqk'];
1066
+		    }
1067
+		    // squawk
774 1068
 		    $data['emergency'] = ''; // emergency
775
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1069
+		    if (isset($line['Reg'])) {
1070
+		    	$data['registration'] = $line['Reg'];
1071
+		    }
776 1072
 		    
777
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
778
-		    else $data['datetime'] = date('Y-m-d H:i:s');
1073
+		    if (isset($line['PosTime'])) {
1074
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1075
+		    } else {
1076
+		    	$data['datetime'] = date('Y-m-d H:i:s');
1077
+		    }
779 1078
 		    
780 1079
 		    //$data['datetime'] = date('Y-m-d H:i:s');
781
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1080
+		    if (isset($line['Type'])) {
1081
+		    	$data['aircraft_icao'] = $line['Type'];
1082
+		    }
782 1083
 	    	    $data['format_source'] = 'aircraftlistjson';
783 1084
 		    $data['id_source'] = $id_source;
784
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
785
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
786
-		    if (isset($data['latitude'])) $SI->add($data);
1085
+		    if (isset($value['name']) && $value['name'] != '') {
1086
+		    	$data['source_name'] = $value['name'];
1087
+		    }
1088
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1089
+		    	$data['noarchive'] = true;
1090
+		    }
1091
+		    if (isset($data['latitude'])) {
1092
+		    	$SI->add($data);
1093
+		    }
787 1094
 		    unset($data);
788 1095
 		}
789 1096
 	    } elseif (is_array($all_data)) {
@@ -800,12 +1107,19 @@  discard block
 block discarded – undo
800 1107
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
801 1108
 		    $data['squawk'] = $line['squawk']; // squawk
802 1109
 		    $data['emergency'] = ''; // emergency
803
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
804
-		    else $data['datetime'] = date('Y-m-d H:i:s');
1110
+		    if (isset($line['PosTime'])) {
1111
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1112
+		    } else {
1113
+		    	$data['datetime'] = date('Y-m-d H:i:s');
1114
+		    }
805 1115
 	    	    $data['format_source'] = 'aircraftlistjson';
806 1116
     		    $data['id_source'] = $id_source;
807
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
808
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1117
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1118
+		    	$data['noarchive'] = true;
1119
+		    }
1120
+		    if (isset($value['name']) && $value['name'] != '') {
1121
+		    	$data['source_name'] = $value['name'];
1122
+		    }
809 1123
 		    $SI->add($data);
810 1124
 		    unset($data);
811 1125
 		}
@@ -841,8 +1155,12 @@  discard block
 block discarded – undo
841 1155
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
842 1156
 	    	    $data['format_source'] = 'planeupdatefaa';
843 1157
     		    $data['id_source'] = $id_source;
844
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
845
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1158
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1159
+		    	$data['noarchive'] = true;
1160
+		    }
1161
+		    if (isset($value['name']) && $value['name'] != '') {
1162
+		    	$data['source_name'] = $value['name'];
1163
+		    }
846 1164
 		    $SI->add($data);
847 1165
 		    unset($data);
848 1166
 		}
@@ -871,7 +1189,9 @@  discard block
 block discarded – undo
871 1189
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
872 1190
 	    	    $data['format_source'] = 'opensky';
873 1191
     		    $data['id_source'] = $id_source;
874
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1192
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1193
+		    	$data['noarchive'] = true;
1194
+		    }
875 1195
 		    $SI->add($data);
876 1196
 		    unset($data);
877 1197
 		}
@@ -883,7 +1203,9 @@  discard block
 block discarded – undo
883 1203
 	    //$buffer = $Common->getData($hosts[$id]);
884 1204
 	    $buffer = $Common->getData($value['host']);
885 1205
 	    $all_data = json_decode($buffer,true);
886
-	    if (!empty($all_data)) $reset = 0;
1206
+	    if (!empty($all_data)) {
1207
+	    	$reset = 0;
1208
+	    }
887 1209
 	    foreach ($all_data as $key => $line) {
888 1210
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
889 1211
 		    $data = array();
@@ -904,8 +1226,12 @@  discard block
 block discarded – undo
904 1226
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
905 1227
 	    	    $data['format_source'] = 'fr24json';
906 1228
     		    $data['id_source'] = $id_source;
907
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
908
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1229
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1230
+		    	$data['noarchive'] = true;
1231
+		    }
1232
+		    if (isset($value['name']) && $value['name'] != '') {
1233
+		    	$data['source_name'] = $value['name'];
1234
+		    }
909 1235
 		    $SI->add($data);
910 1236
 		    unset($data);
911 1237
 		}
@@ -929,24 +1255,42 @@  discard block
 block discarded – undo
929 1255
 		    if (isset($line['inf'])) {
930 1256
 			$data = array();
931 1257
 			$data['hex'] = $line['inf']['ia'];
932
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1258
+			if (isset($line['inf']['cs'])) {
1259
+				$data['ident'] = $line['inf']['cs'];
1260
+			}
1261
+			//$line[13]
933 1262
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
934
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
935
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1263
+	    		if (isset($line['inf']['gs'])) {
1264
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1265
+	    		}
1266
+	    		// speed
1267
+	    		if (isset($line['inf']['tr'])) {
1268
+	    			$data['heading'] = $line['inf']['tr'];
1269
+	    		}
1270
+	    		// heading
936 1271
 	    		$data['latitude'] = $line['pt'][0]; // lat
937 1272
 	    		$data['longitude'] = $line['pt'][1]; // long
938 1273
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
939
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1274
+	    		if (isset($line['inf']['sq'])) {
1275
+	    			$data['squawk'] = $line['inf']['sq'];
1276
+	    		}
1277
+	    		// squawk
940 1278
 	    		//$data['aircraft_icao'] = $line[8];
941
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1279
+	    		if (isset($line['inf']['rc'])) {
1280
+	    			$data['registration'] = $line['inf']['rc'];
1281
+	    		}
942 1282
 			//$data['departure_airport_iata'] = $line[11];
943 1283
 			//$data['arrival_airport_iata'] = $line[12];
944 1284
 	    		//$data['emergency'] = ''; // emergency
945 1285
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
946 1286
 	    		$data['format_source'] = 'radarvirtueljson';
947 1287
     			$data['id_source'] = $id_source;
948
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
949
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1288
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1289
+				$data['noarchive'] = true;
1290
+			}
1291
+			if (isset($value['name']) && $value['name'] != '') {
1292
+				$data['source_name'] = $value['name'];
1293
+			}
950 1294
 			$SI->add($data);
951 1295
 			unset($data);
952 1296
 		    }
@@ -967,30 +1311,65 @@  discard block
 block discarded – undo
967 1311
 		    $data['id'] = $line['id'];
968 1312
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
969 1313
 		    $data['ident'] = $line['callsign']; // ident
970
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
971
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
972
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
973
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
974
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
975
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1314
+		    if (isset($line['pilotid'])) {
1315
+		    	$data['pilot_id'] = $line['pilotid'];
1316
+		    }
1317
+		    // pilot id
1318
+		    if (isset($line['name'])) {
1319
+		    	$data['pilot_name'] = $line['name'];
1320
+		    }
1321
+		    // pilot name
1322
+		    if (isset($line['alt'])) {
1323
+		    	$data['altitude'] = $line['alt'];
1324
+		    }
1325
+		    // altitude
1326
+		    if (isset($line['gs'])) {
1327
+		    	$data['speed'] = $line['gs'];
1328
+		    }
1329
+		    // speed
1330
+		    if (isset($line['heading'])) {
1331
+		    	$data['heading'] = $line['heading'];
1332
+		    }
1333
+		    // heading
1334
+		    if (isset($line['route'])) {
1335
+		    	$data['waypoints'] = $line['route'];
1336
+		    }
1337
+		    // route
976 1338
 		    $data['latitude'] = $line['lat']; // lat
977 1339
 		    $data['longitude'] = $line['lon']; // long
978 1340
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
979 1341
 		    //$data['squawk'] = $line['squawk']; // squawk
980 1342
 		    //$data['emergency'] = ''; // emergency
981
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
982
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
983
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1343
+		    if (isset($line['depicao'])) {
1344
+		    	$data['departure_airport_icao'] = $line['depicao'];
1345
+		    }
1346
+		    if (isset($line['deptime'])) {
1347
+		    	$data['departure_airport_time'] = $line['deptime'];
1348
+		    }
1349
+		    if (isset($line['arricao'])) {
1350
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1351
+		    }
984 1352
 		    //$data['arrival_airport_time'] = $line['arrtime'];
985
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
986
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
987
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
988
-		    else $data['info'] = '';
1353
+		    if (isset($line['aircraft'])) {
1354
+		    	$data['aircraft_icao'] = $line['aircraft'];
1355
+		    }
1356
+		    if (isset($line['transponder'])) {
1357
+		    	$data['squawk'] = $line['transponder'];
1358
+		    }
1359
+		    if (isset($line['atis'])) {
1360
+		    	$data['info'] = $line['atis'];
1361
+		    } else {
1362
+		    	$data['info'] = '';
1363
+		    }
989 1364
 		    $data['format_source'] = 'pireps';
990 1365
     		    $data['id_source'] = $id_source;
991 1366
 		    $data['datetime'] = date('Y-m-d H:i:s');
992
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
993
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1367
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1368
+		    	$data['noarchive'] = true;
1369
+		    }
1370
+		    if (isset($value['name']) && $value['name'] != '') {
1371
+		    	$data['source_name'] = $value['name'];
1372
+		    }
994 1373
 		    if ($line['icon'] == 'plane') {
995 1374
 			$SI->add($data);
996 1375
 		    //    print_r($data);
@@ -999,16 +1378,28 @@  discard block
 block discarded – undo
999 1378
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1000 1379
 			$typec = substr($data['ident'],-3);
1001 1380
 			$data['type'] = '';
1002
-			if ($typec == 'APP') $data['type'] = 'Approach';
1003
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
1004
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
1005
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
1006
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
1007
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
1008
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1009
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1010
-			else $data['type'] = 'Observer';
1011
-			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']);
1381
+			if ($typec == 'APP') {
1382
+				$data['type'] = 'Approach';
1383
+			} elseif ($typec == 'TWR') {
1384
+				$data['type'] = 'Tower';
1385
+			} elseif ($typec == 'OBS') {
1386
+				$data['type'] = 'Observer';
1387
+			} elseif ($typec == 'GND') {
1388
+				$data['type'] = 'Ground';
1389
+			} elseif ($typec == 'DEL') {
1390
+				$data['type'] = 'Delivery';
1391
+			} elseif ($typec == 'DEP') {
1392
+				$data['type'] = 'Departure';
1393
+			} elseif ($typec == 'FSS') {
1394
+				$data['type'] = 'Flight Service Station';
1395
+			} elseif ($typec == 'CTR') {
1396
+				$data['type'] = 'Control Radar or Centre';
1397
+			} else {
1398
+				$data['type'] = 'Observer';
1399
+			}
1400
+			if (isset($ATC)) {
1401
+				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']);
1402
+			}
1012 1403
 		    }
1013 1404
 		    unset($data);
1014 1405
 		}
@@ -1018,7 +1409,9 @@  discard block
 block discarded – undo
1018 1409
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1019 1410
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1020 1411
 	    //$buffer = $Common->getData($hosts[$id]);
1021
-	    if ($globalDebug) echo 'Get Data...'."\n";
1412
+	    if ($globalDebug) {
1413
+	    	echo 'Get Data...'."\n";
1414
+	    }
1022 1415
 	    $buffer = $Common->getData($value['host']);
1023 1416
 	    $all_data = json_decode($buffer,true);
1024 1417
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1026,10 +1419,16 @@  discard block
 block discarded – undo
1026 1419
 		foreach ($all_data as $line) {
1027 1420
 	    	    $data = array();
1028 1421
 	    	    //$data['id'] = $line['id']; // id not usable
1029
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1422
+	    	    if (isset($line['pilotid'])) {
1423
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1424
+	    	    }
1030 1425
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1031
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1032
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1426
+	    	    if (isset($line['pilotname'])) {
1427
+	    	    	$data['pilot_name'] = $line['pilotname'];
1428
+	    	    }
1429
+	    	    if (isset($line['pilotid'])) {
1430
+	    	    	$data['pilot_id'] = $line['pilotid'];
1431
+	    	    }
1033 1432
 	    	    $data['ident'] = $line['flightnum']; // ident
1034 1433
 	    	    $data['altitude'] = $line['alt']; // altitude
1035 1434
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1045,34 +1444,52 @@  discard block
 block discarded – undo
1045 1444
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1046 1445
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1047 1446
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1048
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1447
+	    	    } else {
1448
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1449
+	    	    }
1049 1450
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1050 1451
 	    	    $data['departure_airport_time'] = $line['deptime'];
1051 1452
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
1052 1453
     		    $data['arrival_airport_time'] = $line['arrtime'];
1053 1454
     		    $data['registration'] = $line['aircraft'];
1054
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1055
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1455
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1456
+		    	$data['noarchive'] = true;
1457
+		    }
1458
+		    if (isset($line['route'])) {
1459
+		    	$data['waypoints'] = $line['route'];
1460
+		    }
1461
+		    // route
1056 1462
 		    if (isset($line['aircraftname'])) {
1057 1463
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1058 1464
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1059 1465
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1060
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1061
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1062
-	    		else {
1466
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1467
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1468
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1469
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1470
+	    		} else {
1063 1471
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1064
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1065
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1472
+	    		    if (isset($aircraft_data[1])) {
1473
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1474
+	    		    } else {
1475
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1476
+	    		    }
1066 1477
 	    		}
1067 1478
 	    	    }
1068
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1479
+    		    if (isset($line['route'])) {
1480
+    		    	$data['waypoints'] = $line['route'];
1481
+    		    }
1069 1482
     		    $data['id_source'] = $id_source;
1070 1483
 	    	    $data['format_source'] = 'phpvmacars';
1071
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1484
+		    if (isset($value['name']) && $value['name'] != '') {
1485
+		    	$data['source_name'] = $value['name'];
1486
+		    }
1072 1487
 		    $SI->add($data);
1073 1488
 		    unset($data);
1074 1489
 		}
1075
-		if ($globalDebug) echo 'No more data...'."\n";
1490
+		if ($globalDebug) {
1491
+			echo 'No more data...'."\n";
1492
+		}
1076 1493
 		unset($buffer);
1077 1494
 		unset($all_data);
1078 1495
 	    }
@@ -1080,7 +1497,9 @@  discard block
 block discarded – undo
1080 1497
     	    $last_exec[$id]['last'] = time();
1081 1498
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1082 1499
 	    //$buffer = $Common->getData($hosts[$id]);
1083
-	    if ($globalDebug) echo 'Get Data...'."\n";
1500
+	    if ($globalDebug) {
1501
+	    	echo 'Get Data...'."\n";
1502
+	    }
1084 1503
 	    $buffer = $Common->getData($value['host']);
1085 1504
 	    $all_data = json_decode($buffer,true);
1086 1505
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1109,16 +1528,25 @@  discard block
 block discarded – undo
1109 1528
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1110 1529
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1111 1530
     		    //$data['registration'] = $line['aircraft'];
1112
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1531
+		    if (isset($line['route'])) {
1532
+		    	$data['waypoints'] = $line['route'];
1533
+		    }
1534
+		    // route
1113 1535
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1114 1536
     		    $data['id_source'] = $id_source;
1115 1537
 	    	    $data['format_source'] = 'vam';
1116
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1117
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1538
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1539
+		    	$data['noarchive'] = true;
1540
+		    }
1541
+		    if (isset($value['name']) && $value['name'] != '') {
1542
+		    	$data['source_name'] = $value['name'];
1543
+		    }
1118 1544
 		    $SI->add($data);
1119 1545
 		    unset($data);
1120 1546
 		}
1121
-		if ($globalDebug) echo 'No more data...'."\n";
1547
+		if ($globalDebug) {
1548
+			echo 'No more data...'."\n";
1549
+		}
1122 1550
 		unset($buffer);
1123 1551
 		unset($all_data);
1124 1552
 	    }
@@ -1126,7 +1554,9 @@  discard block
 block discarded – undo
1126 1554
     	    $last_exec[$id]['last'] = time();
1127 1555
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1128 1556
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1129
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1557
+	    if (function_exists('pcntl_fork')) {
1558
+	    	pcntl_signal_dispatch();
1559
+	    }
1130 1560
     	    //$last_exec[$id]['last'] = time();
1131 1561
 
1132 1562
 	    //$read = array( $sockets[$id] );
@@ -1134,7 +1564,9 @@  discard block
 block discarded – undo
1134 1564
 	    $write = NULL;
1135 1565
 	    $e = NULL;
1136 1566
 	    $n = socket_select($read, $write, $e, $timeout);
1137
-	    if ($e != NULL) var_dump($e);
1567
+	    if ($e != NULL) {
1568
+	    	var_dump($e);
1569
+	    }
1138 1570
 	    if ($n > 0) {
1139 1571
 		$reset = 0;
1140 1572
 		foreach ($read as $nb => $r) {
@@ -1155,12 +1587,16 @@  discard block
 block discarded – undo
1155 1587
 		    //$SI::del();
1156 1588
 		    if ($format == 'vrstcp') {
1157 1589
 			$buffer = explode('},{',$buffer);
1158
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1590
+		    } else {
1591
+		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1592
+		    }
1159 1593
 		    // SBS format is CSV format
1160 1594
 		    if ($buffer !== FALSE && $buffer != '') {
1161 1595
 			$tt[$format] = 0;
1162 1596
 			if ($format == 'acarssbs3') {
1163
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1597
+			    if ($globalDebug) {
1598
+			    	echo 'ACARS : '.$buffer."\n";
1599
+			    }
1164 1600
 			    $ACARS->add(trim($buffer));
1165 1601
 			    $ACARS->deleteLiveAcarsData();
1166 1602
 			} elseif ($format == 'raw') {
@@ -1169,30 +1605,70 @@  discard block
 block discarded – undo
1169 1605
 			    if (is_array($data)) {
1170 1606
 				$data['datetime'] = date('Y-m-d H:i:s');
1171 1607
 				$data['format_source'] = 'raw';
1172
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1173
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1174
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1175
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1608
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1609
+					$data['source_name'] = $globalSources[$nb]['name'];
1610
+				}
1611
+				if (isset($globalSources[$nb]['sourcestats'])) {
1612
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1613
+				}
1614
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1615
+					$data['noarchive'] = true;
1616
+				}
1617
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1618
+					$SI->add($data);
1619
+				}
1176 1620
 			    }
1177 1621
 			} elseif ($format == 'ais') {
1178 1622
 			    $ais_data = $AIS->parse_line(trim($buffer));
1179 1623
 			    $data = array();
1180
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1181
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1182
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1183
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1184
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1185
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1186
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1187
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1188
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1189
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1190
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1191
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1192
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1193
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1194
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1195
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1624
+			    if (isset($ais_data['ident'])) {
1625
+			    	$data['ident'] = $ais_data['ident'];
1626
+			    }
1627
+			    if (isset($ais_data['mmsi'])) {
1628
+			    	$data['mmsi'] = $ais_data['mmsi'];
1629
+			    }
1630
+			    if (isset($ais_data['speed'])) {
1631
+			    	$data['speed'] = $ais_data['speed'];
1632
+			    }
1633
+			    if (isset($ais_data['heading'])) {
1634
+			    	$data['heading'] = $ais_data['heading'];
1635
+			    }
1636
+			    if (isset($ais_data['latitude'])) {
1637
+			    	$data['latitude'] = $ais_data['latitude'];
1638
+			    }
1639
+			    if (isset($ais_data['longitude'])) {
1640
+			    	$data['longitude'] = $ais_data['longitude'];
1641
+			    }
1642
+			    if (isset($ais_data['status'])) {
1643
+			    	$data['status'] = $ais_data['status'];
1644
+			    }
1645
+			    if (isset($ais_data['statusid'])) {
1646
+			    	$data['status_id'] = $ais_data['statusid'];
1647
+			    }
1648
+			    if (isset($ais_data['type'])) {
1649
+			    	$data['type'] = $ais_data['type'];
1650
+			    }
1651
+			    if (isset($ais_data['imo'])) {
1652
+			    	$data['imo'] = $ais_data['imo'];
1653
+			    }
1654
+			    if (isset($ais_data['callsign'])) {
1655
+			    	$data['callsign'] = $ais_data['callsign'];
1656
+			    }
1657
+			    if (isset($ais_data['destination'])) {
1658
+			    	$data['arrival_code'] = $ais_data['destination'];
1659
+			    }
1660
+			    if (isset($ais_data['eta_ts'])) {
1661
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1662
+			    }
1663
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1664
+			    	$data['noarchive'] = true;
1665
+			    }
1666
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1667
+			    	$data['source_name'] = $globalSources[$nb]['name'];
1668
+			    }
1669
+			    if (isset($globalSources[$nb]['sourcestats'])) {
1670
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1671
+			    }
1196 1672
 
1197 1673
 			    if (isset($ais_data['timestamp'])) {
1198 1674
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1201,7 +1677,9 @@  discard block
 block discarded – undo
1201 1677
 			    }
1202 1678
 			    $data['format_source'] = 'aisnmea';
1203 1679
     			    $data['id_source'] = $id_source;
1204
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1680
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1681
+			    	$MI->add($data);
1682
+			    }
1205 1683
 			    unset($data);
1206 1684
                         } elseif ($format == 'flightgearsp') {
1207 1685
                     	    //echo $buffer."\n";
@@ -1219,12 +1697,18 @@  discard block
 block discarded – undo
1219 1697
 				$data['speed'] = round($line[5]*1.94384);
1220 1698
 				$data['datetime'] = date('Y-m-d H:i:s');
1221 1699
 				$data['format_source'] = 'flightgearsp';
1222
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1223
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1700
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1701
+					$data['noarchive'] = true;
1702
+				}
1703
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1704
+					$SI->add($data);
1705
+				}
1224 1706
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1225 1707
 			    }
1226 1708
                         } elseif ($format == 'acars') {
1227
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1709
+                    	    if ($globalDebug) {
1710
+                    	    	echo 'ACARS : '.$buffer."\n";
1711
+                    	    }
1228 1712
 			    $ACARS->add(trim($buffer));
1229 1713
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1230 1714
 			    $ACARS->deleteLiveAcarsData();
@@ -1245,8 +1729,12 @@  discard block
 block discarded – undo
1245 1729
 				    $aircraft_type = $line[10];
1246 1730
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1247 1731
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1248
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1249
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1732
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1733
+				    	$data['noarchive'] = true;
1734
+				    }
1735
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1736
+				    	$SI->add($data);
1737
+				    }
1250 1738
 				}
1251 1739
 			    }
1252 1740
 			} elseif ($format == 'beast') {
@@ -1256,28 +1744,62 @@  discard block
 block discarded – undo
1256 1744
 			    foreach($buffer as $all_data) {
1257 1745
 				$line = json_decode('{'.$all_data.'}',true);
1258 1746
 				$data = array();
1259
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1260
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1261
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1262
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1263
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1264
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1265
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1747
+				if (isset($line['Icao'])) {
1748
+					$data['hex'] = $line['Icao'];
1749
+				}
1750
+				// hex
1751
+				if (isset($line['Call'])) {
1752
+					$data['ident'] = $line['Call'];
1753
+				}
1754
+				// ident
1755
+				if (isset($line['Alt'])) {
1756
+					$data['altitude'] = $line['Alt'];
1757
+				}
1758
+				// altitude
1759
+				if (isset($line['Spd'])) {
1760
+					$data['speed'] = $line['Spd'];
1761
+				}
1762
+				// speed
1763
+				if (isset($line['Trak'])) {
1764
+					$data['heading'] = $line['Trak'];
1765
+				}
1766
+				// heading
1767
+				if (isset($line['Lat'])) {
1768
+					$data['latitude'] = $line['Lat'];
1769
+				}
1770
+				// lat
1771
+				if (isset($line['Long'])) {
1772
+					$data['longitude'] = $line['Long'];
1773
+				}
1774
+				// long
1266 1775
 				//$data['verticalrate'] = $line['']; // verticale rate
1267
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1776
+				if (isset($line['Sqk'])) {
1777
+					$data['squawk'] = $line['Sqk'];
1778
+				}
1779
+				// squawk
1268 1780
 				$data['emergency'] = ''; // emergency
1269
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1781
+				if (isset($line['Reg'])) {
1782
+					$data['registration'] = $line['Reg'];
1783
+				}
1270 1784
 				/*
1271 1785
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1272 1786
 				else $data['datetime'] = date('Y-m-d H:i:s');
1273 1787
 				*/
1274 1788
 				$data['datetime'] = date('Y-m-d H:i:s');
1275
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1789
+				if (isset($line['Type'])) {
1790
+					$data['aircraft_icao'] = $line['Type'];
1791
+				}
1276 1792
 		    		$data['format_source'] = 'vrstcp';
1277 1793
 				$data['id_source'] = $id_source;
1278
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1279
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1280
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1794
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1795
+					$data['noarchive'] = true;
1796
+				}
1797
+				if (isset($value['name']) && $value['name'] != '') {
1798
+					$data['source_name'] = $value['name'];
1799
+				}
1800
+				if (isset($data['latitude']) && isset($data['hex'])) {
1801
+					$SI->add($data);
1802
+				}
1281 1803
 				unset($data);
1282 1804
 			    }
1283 1805
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1290,22 +1812,46 @@  discard block
 block discarded – undo
1290 1812
     				$data['hex'] = $lined['hexid'];
1291 1813
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1292 1814
     				$data['datetime'] = date('Y-m-d H:i:s');;
1293
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1294
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1295
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1296
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1297
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1298
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1299
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1815
+    				if (isset($lined['ident'])) {
1816
+    					$data['ident'] = $lined['ident'];
1817
+    				}
1818
+    				if (isset($lined['lat'])) {
1819
+    					$data['latitude'] = $lined['lat'];
1820
+    				}
1821
+    				if (isset($lined['lon'])) {
1822
+    					$data['longitude'] = $lined['lon'];
1823
+    				}
1824
+    				if (isset($lined['speed'])) {
1825
+    					$data['speed'] = $lined['speed'];
1826
+    				}
1827
+    				if (isset($lined['squawk'])) {
1828
+    					$data['squawk'] = $lined['squawk'];
1829
+    				}
1830
+    				if (isset($lined['alt'])) {
1831
+    					$data['altitude'] = $lined['alt'];
1832
+    				}
1833
+    				if (isset($lined['heading'])) {
1834
+    					$data['heading'] = $lined['heading'];
1835
+    				}
1300 1836
     				$data['id_source'] = $id_source;
1301 1837
     				$data['format_source'] = 'tsv';
1302
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1303
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1304
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1305
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1838
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1839
+    					$data['source_name'] = $globalSources[$nb]['name'];
1840
+    				}
1841
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1842
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1843
+    				}
1844
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1845
+					$data['noarchive'] = true;
1846
+				}
1847
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1848
+    					$SI->add($data);
1849
+    				}
1306 1850
     				unset($lined);
1307 1851
     				unset($data);
1308
-    			    } else $error = true;
1852
+    			    } else {
1853
+    			    	$error = true;
1854
+    			    }
1309 1855
 			} elseif ($format == 'aprs' && $use_aprs) {
1310 1856
 			    if ($aprs_connect == 0) {
1311 1857
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1330,60 +1876,118 @@  discard block
 block discarded – undo
1330 1876
 				    $aprs_last_tx = time();
1331 1877
 				    $data = array();
1332 1878
 				    //print_r($line);
1333
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1334
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1335
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1336
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1337
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1338
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1339
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1340
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1341
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1342
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1879
+				    if (isset($line['address'])) {
1880
+				    	$data['hex'] = $line['address'];
1881
+				    }
1882
+				    if (isset($line['mmsi'])) {
1883
+				    	$data['mmsi'] = $line['mmsi'];
1884
+				    }
1885
+				    if (isset($line['imo'])) {
1886
+				    	$data['imo'] = $line['imo'];
1887
+				    }
1888
+				    if (isset($line['squawk'])) {
1889
+				    	$data['squawk'] = $line['squawk'];
1890
+				    }
1891
+				    if (isset($line['arrival_code'])) {
1892
+				    	$data['arrical_code'] = $line['arrival_code'];
1893
+				    }
1894
+				    if (isset($line['arrival_date'])) {
1895
+				    	$data['arrical_date'] = $line['arrival_date'];
1896
+				    }
1897
+				    if (isset($line['type_id'])) {
1898
+				    	$data['type_id'] = $line['typeid'];
1899
+				    }
1900
+				    if (isset($line['status_id'])) {
1901
+				    	$data['status_id'] = $line['statusid'];
1902
+				    }
1903
+				    if (isset($line['timestamp'])) {
1904
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1905
+				    } else {
1906
+				    	$data['datetime'] = date('Y-m-d H:i:s');
1907
+				    }
1343 1908
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1344
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1909
+				    if (isset($line['ident'])) {
1910
+				    	$data['ident'] = $line['ident'];
1911
+				    }
1345 1912
 				    $data['latitude'] = $line['latitude'];
1346 1913
 				    $data['longitude'] = $line['longitude'];
1347 1914
 				    //$data['verticalrate'] = $line[16];
1348
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1915
+				    if (isset($line['speed'])) {
1916
+				    	$data['speed'] = $line['speed'];
1917
+				    }
1349 1918
 				    //else $data['speed'] = 0;
1350
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1351
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1352
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1353
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1919
+				    if (isset($line['altitude'])) {
1920
+				    	$data['altitude'] = $line['altitude'];
1921
+				    }
1922
+				    if (isset($line['comment'])) {
1923
+				    	$data['comment'] = $line['comment'];
1924
+				    }
1925
+				    if (isset($line['symbol'])) {
1926
+				    	$data['type'] = $line['symbol'];
1927
+				    }
1928
+				    if (isset($line['heading'])) {
1929
+				    	$data['heading'] = $line['heading'];
1930
+				    }
1354 1931
 				    //else $data['heading'] = 0;
1355
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1932
+				    if (isset($line['stealth'])) {
1933
+				    	$data['aircraft_type'] = $line['stealth'];
1934
+				    }
1356 1935
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1357
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1358
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1359
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1360
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1936
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
1937
+				    	$data['noarchive'] = true;
1938
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
1939
+				    	$data['noarchive'] = false;
1940
+				    }
1941
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1942
+				    	$data['noarchive'] = true;
1943
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
1944
+				    	$data['noarchive'] = false;
1945
+				    }
1361 1946
     				    $data['id_source'] = $id_source;
1362
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1363
-				    else $data['format_source'] = 'aprs';
1947
+    				    if (isset($line['format_source'])) {
1948
+    				    	$data['format_source'] = $line['format_source'];
1949
+    				    } else {
1950
+				    	$data['format_source'] = 'aprs';
1951
+				    }
1364 1952
 				    $data['source_name'] = $line['source'];
1365
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1366
-				    else $data['source_type'] = 'flarm';
1367
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1953
+				    if (isset($line['source_type'])) {
1954
+				    	$data['source_type'] = $line['source_type'];
1955
+				    } else {
1956
+				    	$data['source_type'] = 'flarm';
1957
+				    }
1958
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1959
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1960
+    				    }
1368 1961
 				    $currentdate = date('Y-m-d H:i:s');
1369 1962
 				    $aprsdate = strtotime($data['datetime']);
1370
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1963
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
1964
+				    	$data['altitude_relative'] = 'AMSL';
1965
+				    }
1371 1966
 				    // Accept data if time <= system time + 20s
1372 1967
 				    //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1373 1968
 				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1374 1969
 					$send = $SI->add($data);
1375 1970
 				    } elseif ($data['source_type'] == 'ais') {
1376
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1971
+					if (isset($globalMarine) && $globalMarine) {
1972
+						$send = $MI->add($data);
1973
+					}
1377 1974
 				    } elseif (isset($line['stealth'])) {
1378
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1379
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1975
+					if ($line['stealth'] != 0) {
1976
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1977
+					} else {
1978
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1979
+					}
1380 1980
 				    //} 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')) {
1381 1981
 				    //} 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') {
1382 1982
 				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1383 1983
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1384
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1984
+					if (isset($globalTracker) && $globalTracker) {
1985
+						$send = $TI->add($data);
1986
+					}
1385 1987
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1386
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
1988
+					if (!isset($data['altitude'])) {
1989
+						$data['altitude'] = 0;
1990
+					}
1387 1991
 					$Source->deleteOldLocationByType('gs');
1388 1992
 					if (count($Source->getLocationInfoByName($data['ident'])) > 0) {
1389 1993
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1395,12 +1999,9 @@  discard block
 block discarded – undo
1395 1999
 				    	print_r($line);
1396 2000
 				    }
1397 2001
 				    unset($data);
1398
-				} 
1399
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
2002
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1400 2003
 					echo '!! Weather Station not yet supported'."\n";
1401
-				}
1402
-				 
1403
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2004
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1404 2005
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1405 2006
 				}
1406 2007
 				/*
@@ -1409,7 +2010,9 @@  discard block
 block discarded – undo
1409 2010
 				}
1410 2011
 				*/
1411 2012
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1412
-				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2013
+				elseif ($line == true && $globalDebug) {
2014
+					echo '!! Failed : '.$buffer."!!\n";
2015
+				}
1413 2016
 			    }
1414 2017
 			} else {
1415 2018
 			    $line = explode(',', $buffer);
@@ -1438,26 +2041,45 @@  discard block
 block discarded – undo
1438 2041
     				$data['ground'] = $line[21];
1439 2042
     				$data['emergency'] = $line[19];
1440 2043
     				$data['format_source'] = 'sbs';
1441
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1442
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1443
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2044
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2045
+					$data['source_name'] = $globalSources[$nb]['name'];
2046
+				}
2047
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2048
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2049
+    				}
2050
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2051
+					$data['noarchive'] = true;
2052
+				}
1444 2053
     				$data['id_source'] = $id_source;
1445
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1446
-    				else $error = true;
2054
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2055
+    					$send = $SI->add($data);
2056
+    				} else {
2057
+    					$error = true;
2058
+    				}
1447 2059
     				unset($data);
1448
-    			    } else $error = true;
2060
+    			    } else {
2061
+    			    	$error = true;
2062
+    			    }
1449 2063
 			    if ($error) {
1450 2064
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1451
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2065
+					if ($globalDebug) {
2066
+						echo "Not a message. Ignoring... \n";
2067
+					}
1452 2068
 				} else {
1453
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2069
+					if ($globalDebug) {
2070
+						echo "Wrong line format. Ignoring... \n";
2071
+					}
1454 2072
 					if ($globalDebug) {
1455 2073
 						echo $buffer;
1456 2074
 						//print_r($line);
1457 2075
 					}
1458 2076
 					//socket_close($r);
1459
-					if ($globalDebug) echo "Reconnect after an error...\n";
1460
-					if ($format == 'aprs') $aprs_connect = 0;
2077
+					if ($globalDebug) {
2078
+						echo "Reconnect after an error...\n";
2079
+					}
2080
+					if ($format == 'aprs') {
2081
+						$aprs_connect = 0;
2082
+					}
1461 2083
 					$sourceer[$nb] = $globalSources[$nb];
1462 2084
 					connect_all($sourceer);
1463 2085
 					$sourceer = array();
@@ -1465,10 +2087,14 @@  discard block
 block discarded – undo
1465 2087
 			    }
1466 2088
 			}
1467 2089
 			// Sleep for xxx microseconds
1468
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2090
+			if (isset($globalSBSSleep)) {
2091
+				usleep($globalSBSSleep);
2092
+			}
1469 2093
 		    } else {
1470 2094
 			if ($format == 'flightgearmp') {
1471
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2095
+			    	if ($globalDebug) {
2096
+			    		echo "Reconnect FlightGear MP...";
2097
+			    	}
1472 2098
 				//@socket_close($r);
1473 2099
 				sleep($globalMinFetch);
1474 2100
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1477,10 +2103,15 @@  discard block
 block discarded – undo
1477 2103
 				break;
1478 2104
 				
1479 2105
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1480
-			    if (isset($tt[$format])) $tt[$format]++;
1481
-			    else $tt[$format] = 0;
2106
+			    if (isset($tt[$format])) {
2107
+			    	$tt[$format]++;
2108
+			    } else {
2109
+			    	$tt[$format] = 0;
2110
+			    }
1482 2111
 			    if ($tt[$format] > 30) {
1483
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2112
+				if ($globalDebug) {
2113
+					echo "ERROR : Reconnect ".$format."...";
2114
+				}
1484 2115
 				//@socket_close($r);
1485 2116
 				sleep(2);
1486 2117
 				$aprs_connect = 0;
@@ -1497,11 +2128,17 @@  discard block
 block discarded – undo
1497 2128
 	    } else {
1498 2129
 		$error = socket_strerror(socket_last_error());
1499 2130
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1500
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1501
-			if (isset($globalDebug)) echo "Restarting...\n";
2131
+			if ($globalDebug) {
2132
+				echo "ERROR : socket_select give this error ".$error . "\n";
2133
+			}
2134
+			if (isset($globalDebug)) {
2135
+				echo "Restarting...\n";
2136
+			}
1502 2137
 			// Restart the script if possible
1503 2138
 			if (is_array($sockets)) {
1504
-			    if ($globalDebug) echo "Shutdown all sockets...";
2139
+			    if ($globalDebug) {
2140
+			    	echo "Shutdown all sockets...";
2141
+			    }
1505 2142
 			    
1506 2143
 			    foreach ($sockets as $sock) {
1507 2144
 				@socket_shutdown($sock,2);
@@ -1509,22 +2146,36 @@  discard block
 block discarded – undo
1509 2146
 			    }
1510 2147
 			    
1511 2148
 			}
1512
-			if ($globalDebug) echo "Waiting...";
2149
+			if ($globalDebug) {
2150
+				echo "Waiting...";
2151
+			}
1513 2152
 			sleep(2);
1514 2153
 			$time = time();
1515 2154
 			//connect_all($hosts);
1516 2155
 			$aprs_connect = 0;
1517
-			if ($reset%5 == 0) sleep(20);
1518
-			if ($reset%10 == 0) sleep(100);
1519
-			if ($reset%20 == 0) sleep(200);
1520
-			if ($reset > 100) exit('Too many attempts...');
1521
-			if ($globalDebug) echo "Restart all connections...";
2156
+			if ($reset%5 == 0) {
2157
+				sleep(20);
2158
+			}
2159
+			if ($reset%10 == 0) {
2160
+				sleep(100);
2161
+			}
2162
+			if ($reset%20 == 0) {
2163
+				sleep(200);
2164
+			}
2165
+			if ($reset > 100) {
2166
+				exit('Too many attempts...');
2167
+			}
2168
+			if ($globalDebug) {
2169
+				echo "Restart all connections...";
2170
+			}
1522 2171
 			connect_all($globalSources);
1523 2172
 		}
1524 2173
 	    }
1525 2174
 	}
1526 2175
 	if ($globalDaemon === false) {
1527
-	    if ($globalDebug) echo 'Check all...'."\n";
2176
+	    if ($globalDebug) {
2177
+	    	echo 'Check all...'."\n";
2178
+	    }
1528 2179
 	    $SI->checkAll();
1529 2180
 	}
1530 2181
     }
Please login to merge, or discard this patch.
install/index.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -317,18 +317,18 @@  discard block
 block discarded – undo
317 317
 				</tr>
318 318
 				<!--
319 319
 		<?php
320
-		    require_once(dirname(__FILE__).'/../require/class.Connection.php');
321
-		    $Connection = new Connection();
320
+			require_once(dirname(__FILE__).'/../require/class.Connection.php');
321
+			$Connection = new Connection();
322 322
 		?>
323 323
 				-->
324 324
 		<?php
325
-		    if ($Connection->db != NULL) {
325
+			if ($Connection->db != NULL) {
326 326
 			if ($Connection->tableExists('source_location')) {
327
-			    require_once(dirname(__FILE__).'/../require/class.Source.php');
328
-			    $Source = new Source();
329
-			    //$alllocations = $Source->getAllLocationInfo();
330
-			    $alllocations = $Source->getLocationInfobyType('');
331
-			    foreach ($alllocations as $location) {
327
+				require_once(dirname(__FILE__).'/../require/class.Source.php');
328
+				$Source = new Source();
329
+				//$alllocations = $Source->getAllLocationInfo();
330
+				$alllocations = $Source->getLocationInfobyType('');
331
+				foreach ($alllocations as $location) {
332 332
 		?>
333 333
 				<tr>
334 334
 	    				<input type="hidden" name="source_id[]" value="<?php print $location['id']; ?>" />
@@ -342,9 +342,9 @@  discard block
 block discarded – undo
342 342
 				</tr>
343 343
 		
344 344
 		<?php
345
-			    }
345
+				}
346
+			}
346 347
 			}
347
-		    }
348 348
 		?>
349 349
 
350 350
 				<tr>
@@ -452,12 +452,12 @@  discard block
 block discarded – undo
452 452
 ?>
453 453
 							<tr>
454 454
 								<?php
455
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
455
+									if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
456 456
 								?>
457 457
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
458 458
 								<td><input type="number" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
459 459
 								<?php
460
-								    } else {
460
+									} else {
461 461
 									$hostport = explode(':',$source['host']);
462 462
 									if (isset($hostport[1])) {
463 463
 										$host = $hostport[0];
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 								<td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td>
471 471
 								<td><input type="number" name="port[]" id="port" class="col-xs-2" value="<?php print $port; ?>" /></td>
472 472
 								<?php
473
-								    }
473
+									}
474 474
 								?>
475 475
 								<td>
476 476
 									<select name="format[]" id="format">
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
 			<br />
877 877
 			<p>
878 878
 			<?php 
879
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
879
+				if (extension_loaded('gd') && function_exists('gd_info')) {
880 880
 			?>
881 881
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
882 882
 				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
@@ -886,11 +886,11 @@  discard block
 block discarded – undo
886 886
 				<b>The directory cache is not writable, aircraft icon will not be cached</b>
887 887
 			<?php
888 888
 				}
889
-			    } else {
889
+				} else {
890 890
 			?>
891 891
 				<b>PHP GD is not installed, you can't change color of aircraft icon on map</b>
892 892
 			<?php
893
-			    }
893
+				}
894 894
 			?>
895 895
 			</p>
896 896
 			<br />
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
 	</p>
915 915
 <?php
916 916
 	require('../footer.php');
917
-        exit;
917
+		exit;
918 918
 }
919 919
 	
920 920
 $settings = array();
@@ -1005,8 +1005,8 @@  discard block
 block discarded – undo
1005 1005
 	
1006 1006
 	$sources = array();
1007 1007
 	foreach ($source_name as $keys => $name) {
1008
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1009
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1008
+		if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1009
+		else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1010 1010
 	}
1011 1011
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1012 1012
 
@@ -1384,14 +1384,14 @@  discard block
 block discarded – undo
1384 1384
 
1385 1385
 	// Set some defaults values...
1386 1386
 	if (!isset($globalAircraftImageSources)) {
1387
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1388
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1387
+		$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1388
+		$settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1389 1389
 	}
1390 1390
 
1391 1391
 	if (!isset($globalSchedulesSources)) {
1392
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1393
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1394
-    	}
1392
+		$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1393
+			$settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1394
+		}
1395 1395
 
1396 1396
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1397 1397
 
@@ -1443,21 +1443,21 @@  discard block
 block discarded – undo
1443 1443
 	$popi = false;
1444 1444
 	$popw = false;
1445 1445
 	foreach ($_SESSION['done'] as $done) {
1446
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1447
-	    if ($done == 'Create database') $pop = true;
1448
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1449
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1450
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1446
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1447
+		if ($done == 'Create database') $pop = true;
1448
+		if ($_SESSION['install'] == 'database_create') $pop = true;
1449
+		if ($_SESSION['install'] == 'database_import') $popi = true;
1450
+		if ($_SESSION['install'] == 'waypoints') $popw = true;
1451 1451
 	}
1452 1452
 	if ($pop) {
1453
-	    sleep(5);
1454
-	    print '<li>Create database....<img src="../images/loading.gif" /></li>';
1453
+		sleep(5);
1454
+		print '<li>Create database....<img src="../images/loading.gif" /></li>';
1455 1455
 	} else if ($popi) {
1456
-	    sleep(5);
1457
-	    print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1456
+		sleep(5);
1457
+		print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1458 1458
 	} else if ($popw) {
1459
-	    sleep(5);
1460
-	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1459
+		sleep(5);
1460
+		print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1461 1461
 	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1462 1462
 	print '</div></ul>';
1463 1463
 	print '<div id="error"></div>';
@@ -1520,7 +1520,7 @@  discard block
 block discarded – undo
1520 1520
 	unset($_COOKIE['install']);
1521 1521
 	print '<div class="info column"><ul>';
1522 1522
 	foreach ($_SESSION['done'] as $done) {
1523
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1523
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1524 1524
 	}
1525 1525
 	print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>';
1526 1526
 	print '</ul></div>';
Please login to merge, or discard this patch.
live-geojson.php 2 patches
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -55,23 +55,23 @@  discard block
 block discarded – undo
55 55
 $min = true;
56 56
 $allhistory = false;
57 57
 $filter['source'] = array();
58
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
59
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
60
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
61
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
62
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
63
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
64
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
65
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
66
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
67
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
58
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
59
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
60
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
61
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs'));
62
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
63
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
64
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
65
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
66
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
67
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING);
68 68
 
69 69
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
70 70
 	$min = true;
71 71
 } else $min = false;
72 72
 
73 73
 if (isset($_GET['ident'])) {
74
-	$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
74
+	$ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING));
75 75
 	if ($tracker) {
76 76
 		$spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident);
77 77
 	} elseif ($marine) {
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	}
86 86
 	$allhistory = true;
87 87
 } elseif (isset($_GET['flightaware_id'])) {
88
-	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
88
+	$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
89 89
 	$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
90 90
 	if (empty($spotter_array)) {
91 91
 		$from_archive = true;
@@ -93,44 +93,44 @@  discard block
 block discarded – undo
93 93
 	}
94 94
 	$allhistory = true;
95 95
 } elseif (isset($_GET['famtrack_id'])) {
96
-	$famtrack_id = urldecode(filter_input(INPUT_GET,'famtrack_id',FILTER_SANITIZE_STRING));
96
+	$famtrack_id = urldecode(filter_input(INPUT_GET, 'famtrack_id', FILTER_SANITIZE_STRING));
97 97
 	$spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrack_id);
98 98
 	$allhistory = true;
99 99
 } elseif (isset($_GET['fammarine_id'])) {
100
-	$fammarine_id = urldecode(filter_input(INPUT_GET,'fammarine_id',FILTER_SANITIZE_STRING));
100
+	$fammarine_id = urldecode(filter_input(INPUT_GET, 'fammarine_id', FILTER_SANITIZE_STRING));
101 101
 	$spotter_array = $MarineLive->getLastLiveMarineDataById($fammarine_id);
102 102
 	$allhistory = true;
103 103
 } elseif (isset($_GET['coord']) && (!isset($globalMapPopup) || $globalMapPopup || (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true'))) {
104 104
 //} elseif (isset($_GET['coord'])) {
105 105
 	$usecoord = true;
106
-	$coord = explode(',',$_GET['coord']);
106
+	$coord = explode(',', $_GET['coord']);
107 107
 	if ($tracker) {
108
-		$spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord,$filter);
108
+		$spotter_array = $TrackerLive->getLiveTrackerDatabyCoord($coord, $filter);
109 109
 	} elseif ($marine) {
110
-		$spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord,$filter);
110
+		$spotter_array = $MarineLive->getLiveMarineDatabyCoord($coord, $filter);
111 111
 	} else {
112
-		$spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord,$filter);
112
+		$spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord, $filter);
113 113
 	}
114 114
 } elseif (isset($globalMapUseBbox) && $globalMapUseBbox && isset($_GET['coord']) && $min) {
115 115
 	$usecoord = true;
116
-	$coord = explode(',',$_GET['coord']);
116
+	$coord = explode(',', $_GET['coord']);
117 117
 	if ($tracker) {
118
-		$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord,$filter);
118
+		$spotter_array = $TrackerLive->getMinLiveTrackerDatabyCoord($coord, $filter);
119 119
 	} elseif ($marine) {
120
-		$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord,$filter);
120
+		$spotter_array = $MarineLive->getMinLiveMarineDatabyCoord($coord, $filter);
121 121
 	} else {
122
-		$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord,$filter);
122
+		$spotter_array = $SpotterLive->getMinLiveSpotterDatabyCoord($coord, $filter);
123 123
 	}
124 124
 } elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed']) && !isset($_GET['tracker']) && !isset($_GET['marine'])) {
125 125
 	$from_archive = true;
126 126
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
127 127
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
128
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
129
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
130
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
131
-	$begindate = date('Y-m-d H:i:s',$begindate);
132
-	$enddate = date('Y-m-d H:i:s',$enddate);
133
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
128
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
129
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
130
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
131
+	$begindate = date('Y-m-d H:i:s', $begindate);
132
+	$enddate = date('Y-m-d H:i:s', $enddate);
133
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
134 134
 } elseif ($min) {
135 135
 	if ($tracker) {
136 136
 		$spotter_array = $TrackerLive->getMinLiveTrackerData($filter);
@@ -142,18 +142,18 @@  discard block
 block discarded – undo
142 142
 #	$min = true;
143 143
 } else {
144 144
 	if ($tracker) {
145
-		$spotter_array = $TrackerLive->getLiveTrackerData('','',$filter);
145
+		$spotter_array = $TrackerLive->getLiveTrackerData('', '', $filter);
146 146
 	} elseif ($marine) {
147
-		$spotter_array = $marineLive->getLiveMarineData('','',$filter);
147
+		$spotter_array = $marineLive->getLiveMarineData('', '', $filter);
148 148
 	} else {
149
-		$spotter_array = $SpotterLive->getLiveSpotterData('','',$filter);
149
+		$spotter_array = $SpotterLive->getLiveSpotterData('', '', $filter);
150 150
 	}
151 151
 }
152 152
 
153 153
 if (!empty($spotter_array) || $usecoord) {
154 154
 	if ($usecoord) {
155 155
 		if (isset($_GET['archive'])) {
156
-			$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
156
+			$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
157 157
 		} else {
158 158
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
159 159
 		}
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	if ($flightcnt == '') $flightcnt = 0;
162 162
 } else $flightcnt = 0;
163 163
 
164
-$sqltime = round(microtime(true)-$begintime,2);
164
+$sqltime = round(microtime(true) - $begintime, 2);
165 165
 
166 166
 if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
167 167
 else $usenextlatlon = true;
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 		if (!empty($spotter_array) && is_array($spotter_array))
179 179
 		{
180 180
 			$output .= '"features": [';
181
-			foreach($spotter_array as $spotter_item)
181
+			foreach ($spotter_array as $spotter_item)
182 182
 			{
183 183
 				$j++;
184 184
 				date_default_timezone_set('UTC');
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
 */
235 235
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
236 236
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
237
-							if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
238
-							else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
237
+							if ($compress) $output .= '"c": "'.str_replace('\\', '', $spotter_item['ident']).'",';
238
+							else $output .= '"callsign": "'.str_replace('\\', '', $spotter_item['ident']).'",';
239 239
 							//"
240 240
 						} else {
241 241
 							if ($compress) $output .= '"c": "NA",';
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
245 245
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
246 246
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
247
-							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
247
+							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ', '_', $spotter_item['aircraft_name'])).'",';
248 248
 						} elseif (isset($spotter_item['aircraft_type'])) {
249 249
 							$output .= '"aircraft_name": "NA ('.$spotter_item['aircraft_type'].')",';
250 250
 						} elseif (!$min) {
@@ -385,16 +385,16 @@  discard block
 block discarded – undo
385 385
 						else $output .= '"heading": "'.$spotter_item['heading'].'",';
386 386
 						
387 387
 						if (isset($archivespeed)) {
388
-							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
388
+							$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading'], $archivespeed);
389 389
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
390 390
 						} elseif ($usenextlatlon) {
391
-							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']);
391
+							$nextcoord = $Common->nextcoord($spotter_item['latitude'], $spotter_item['longitude'], $spotter_item['ground_speed'], $spotter_item['heading']);
392 392
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
393 393
 						}
394 394
 
395 395
 						if (!$min) $output .= '"image": "'.$image.'",';
396 396
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
397
-							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
397
+							$output .= '"image_copyright": "'.str_replace('"', "'", trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $spotter_item['image_copyright']))).'",';
398 398
 						}
399 399
 						if (isset($spotter_item['image_source_website'])) {
400 400
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 							$output .= '"waypoints": "'.$spotter_item['waypoints'].'",';
417 417
 						}
418 418
 						if (isset($spotter_item['acars'])) {
419
-							$output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",';
419
+							$output .= '"acars": "'.trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '<br />', $spotter_item['acars']['message'])).'",';
420 420
 						}
421 421
 						// type when not aircraft ?
422 422
 						if (isset($spotter_item['type'])) {
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
                 
495 495
 			}
496 496
 */
497
-				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
497
+				$history = filter_input(INPUT_GET, 'history', FILTER_SANITIZE_STRING);
498 498
 				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
499 499
 				
500 500
 				if (
@@ -502,11 +502,11 @@  discard block
 block discarded – undo
502 502
 				    || ((isset($globalMapHistory) && $globalMapHistory) || $allhistory)
503 503
 				//    || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))
504 504
 				//    || (isset($history) && $history != '' && $history != 'NA' && $history == $spotter_item['ident'])
505
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
505
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
506 506
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])
507
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['fammarine_id']))
507
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['fammarine_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['fammarine_id']))
508 508
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['fammarine_id']) && $_GET['fammarine_id'] == $spotter_item['fammarine_id'])
509
-				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['famtrackid']))
509
+				    || (isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['famtrackid']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['famtrackid']))
510 510
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['famtrackid']) && $_GET['famtrackid'] == $spotter_item['famtrackid'])
511 511
 				    ) {
512 512
 					if ($tracker) {
@@ -543,9 +543,9 @@  discard block
 block discarded – undo
543 543
 								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
544 544
 							}
545 545
 							$output_history .= '[';
546
-							$output_history .=  $spotter_history['longitude'].', ';
547
-							$output_history .=  $spotter_history['latitude'].', ';
548
-							$output_history .=  $spotter_history['altitude']*30.48;
546
+							$output_history .= $spotter_history['longitude'].', ';
547
+							$output_history .= $spotter_history['latitude'].', ';
548
+							$output_history .= $spotter_history['altitude']*30.48;
549 549
 							$output_history .= '],';
550 550
 							/*
551 551
 							if ($from_archive === false) {
@@ -563,8 +563,8 @@  discard block
 block discarded – undo
563 563
 								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
564 564
 							} else $d = true;
565 565
 							$output_history .= '[';
566
-							$output_history .=  $spotter_history['longitude'].', ';
567
-							$output_history .=  $spotter_history['latitude'];
566
+							$output_history .= $spotter_history['longitude'].', ';
567
+							$output_history .= $spotter_history['latitude'];
568 568
 							$output_history .= '],';
569 569
 							/*
570 570
 							if ($from_archive === false) {
@@ -580,9 +580,9 @@  discard block
 block discarded – undo
580 580
 					
581 581
 						if ($from_archive === false) {
582 582
 							$output_historyd = '[';
583
-							$output_historyd .=  $spotter_item['longitude'].', ';
584
-							$output_historyd .=  $spotter_item['latitude'];
585
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
583
+							$output_historyd .= $spotter_item['longitude'].', ';
584
+							$output_historyd .= $spotter_item['latitude'];
585
+							if (isset($spotter_history['altitude'])) $output_historyd .= ','.$spotter_item['altitude']*30.48;
586 586
 							$output_historyd .= '],';
587 587
 							//$output_history = $output_historyd.$output_history;
588 588
 							$output_history = $output_history.$output_historyd;
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 					}
597 597
 				}
598 598
 				
599
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
599
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
600 600
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
601 601
 				     && (isset($spotter_item['departure_airport']) 
602 602
 				        && $spotter_item['departure_airport'] != 'NA' 
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 
631 631
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA' && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
632 632
 				//if (isset($history) && $history != '' && $history == $spotter_item['ident'] && isset($spotter_item['arrival_airport']) && $spotter_item['arrival_airport'] != 'NA' && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") || (!isset($_COOKIE['MapRoute']) && (!isset($globalMapRoute) || (isset($globalMapRoute) && $globalMapRoute))))) {
633
-				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-','',$history) == str_replace('-','',$spotter_item['flightaware_id']))
633
+				if (((isset($history) && $history != '' && $history != 'NA' && isset($spotter_item['flightaware_id']) && str_replace('-', '', $history) == str_replace('-', '', $spotter_item['flightaware_id']))
634 634
 				    || (isset($history) && $history == '' && isset($spotter_item['flightaware_id']) && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id']))
635 635
 				     && (isset($spotter_item['arrival_airport']) 
636 636
 				        && $spotter_item['arrival_airport'] != 'NA' 
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 			$output  = substr($output, 0, -1);
662 662
 			$output .= ']';
663 663
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
664
-			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
664
+			$output .= '"totaltime": "'.round(microtime(true) - $begintime, 2).'",';
665 665
 			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
666 666
 			$output .= '"fc": "'.$j.'"';
667 667
 		} else {
Please login to merge, or discard this patch.
Braces   +291 added lines, -114 removed lines patch added patch discarded remove patch
@@ -48,27 +48,52 @@  discard block
 block discarded – undo
48 48
 }
49 49
 header('Content-Type: text/javascript');
50 50
 
51
-if (!isset($globalJsonCompress)) $compress = true;
52
-else $compress = $globalJsonCompress;
51
+if (!isset($globalJsonCompress)) {
52
+	$compress = true;
53
+} else {
54
+	$compress = $globalJsonCompress;
55
+}
53 56
 
54 57
 $from_archive = false;
55 58
 $min = true;
56 59
 $allhistory = false;
57 60
 $filter['source'] = array();
58
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
59
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
60
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
61
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
62
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
63
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
64
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
65
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
66
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
67
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
61
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
62
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
63
+}
64
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
65
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
66
+}
67
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
68
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
69
+}
70
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
71
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
72
+}
73
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
74
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
75
+}
76
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
77
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
78
+}
79
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
80
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
81
+}
82
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
83
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
84
+}
85
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
86
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
87
+}
88
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
89
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
90
+}
68 91
 
69 92
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
70 93
 	$min = true;
71
-} else $min = false;
94
+} else {
95
+	$min = false;
96
+}
72 97
 
73 98
 if (isset($_GET['ident'])) {
74 99
 	$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
@@ -157,21 +182,33 @@  discard block
 block discarded – undo
157 182
 		} else {
158 183
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
159 184
 		}
160
-	} else $flightcnt = count($spotter_array);
161
-	if ($flightcnt == '') $flightcnt = 0;
162
-} else $flightcnt = 0;
185
+	} else {
186
+		$flightcnt = count($spotter_array);
187
+	}
188
+	if ($flightcnt == '') {
189
+		$flightcnt = 0;
190
+	}
191
+	} else {
192
+	$flightcnt = 0;
193
+}
163 194
 
164 195
 $sqltime = round(microtime(true)-$begintime,2);
165 196
 
166
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
167
-else $usenextlatlon = true;
197
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
198
+	$usenextlatlon = false;
199
+} else {
200
+	$usenextlatlon = true;
201
+}
168 202
 $j = 0;
169 203
 $prev_flightaware_id = '';
170 204
 $aircrafts_shadow = array();
171 205
 $output = '{';
172 206
 	$output .= '"type": "FeatureCollection",';
173
-		if ($min) $output .= '"minimal": "true",';
174
-		else $output .= '"minimal": "false",';
207
+		if ($min) {
208
+			$output .= '"minimal": "true",';
209
+		} else {
210
+			$output .= '"minimal": "false",';
211
+		}
175 212
 		//$output .= '"fc": "'.$flightcnt.'",';
176 213
 		$output .= '"sqt": "'.$sqltime.'",';
177 214
 
@@ -215,18 +252,29 @@  discard block
 block discarded – undo
215 252
 						}
216 253
 						$output .= '"properties": {';
217 254
 						if (isset($spotter_item['flightaware_id'])) {
218
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
219
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
255
+							if ($compress) {
256
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
257
+							} else {
258
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
259
+							}
220 260
 						} elseif (isset($spotter_item['famtrackid'])) {
221
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
222
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
261
+							if ($compress) {
262
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
263
+							} else {
264
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
265
+							}
223 266
 						} elseif (isset($spotter_item['fammarine_id'])) {
224
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
225
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
267
+							if ($compress) {
268
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
269
+							} else {
270
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
271
+							}
226 272
 						}
227 273
 							$output .= '"fc": "'.$flightcnt.'",';
228 274
 							$output .= '"sqt": "'.$sqltime.'",';
229
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
275
+							if (isset($begindate)) {
276
+								$output .= '"archive_date": "'.$begindate.'",';
277
+							}
230 278
 
231 279
 /*
232 280
 							if ($min) $output .= '"minimal": "true",';
@@ -234,14 +282,22 @@  discard block
 block discarded – undo
234 282
 */
235 283
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
236 284
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
237
-							if ($compress) $output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
238
-							else $output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
285
+							if ($compress) {
286
+								$output .= '"c": "'.str_replace('\\','',$spotter_item['ident']).'",';
287
+							} else {
288
+								$output .= '"callsign": "'.str_replace('\\','',$spotter_item['ident']).'",';
289
+							}
239 290
 							//"
240 291
 						} else {
241
-							if ($compress) $output .= '"c": "NA",';
242
-							else $output .= '"callsign": "NA",';
292
+							if ($compress) {
293
+								$output .= '"c": "NA",';
294
+							} else {
295
+								$output .= '"callsign": "NA",';
296
+							}
297
+						}
298
+						if (isset($spotter_item['registration'])) {
299
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
243 300
 						}
244
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
245 301
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
246 302
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
247 303
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -254,16 +310,23 @@  discard block
 block discarded – undo
254 310
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
255 311
 						}
256 312
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker) {
257
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
258
-							else {
313
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
314
+								$spotter_item['aircraft_shadow'] = '';
315
+							} else {
259 316
 								$aircraft_icao = $spotter_item['aircraft_icao'];
260
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
261
-								else {
317
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
318
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
319
+								} else {
262 320
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
263
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
264
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
265
-									elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
266
-									else $spotter_item['aircraft_shadow'] = '';
321
+									if (count($aircraft_info) > 0) {
322
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
323
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
324
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
325
+									} elseif ($aircraft_icao == 'PARAGLIDER') {
326
+										$spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
327
+									} else {
328
+										$spotter_item['aircraft_shadow'] = '';
329
+									}
267 330
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
268 331
 								}
269 332
 							}
@@ -271,73 +334,139 @@  discard block
 block discarded – undo
271 334
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
272 335
 							if ($tracker) {
273 336
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
274
-									if ($compress) $output .= '"as": "ambulance.png",';
275
-									else $output .= '"aircraft_shadow": "ambulance.png",';
337
+									if ($compress) {
338
+										$output .= '"as": "ambulance.png",';
339
+									} else {
340
+										$output .= '"aircraft_shadow": "ambulance.png",';
341
+									}
276 342
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
277
-									if ($compress) $output .= '"as": "police.png",';
278
-									else $output .= '"aircraft_shadow": "police.png",';
343
+									if ($compress) {
344
+										$output .= '"as": "police.png",';
345
+									} else {
346
+										$output .= '"aircraft_shadow": "police.png",';
347
+									}
279 348
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
280
-									if ($compress) $output .= '"as": "ship.png",';
281
-									else $output .= '"aircraft_shadow": "ship.png",';
349
+									if ($compress) {
350
+										$output .= '"as": "ship.png",';
351
+									} else {
352
+										$output .= '"aircraft_shadow": "ship.png",';
353
+									}
282 354
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
283
-									if ($compress) $output .= '"as": "ship.png",';
284
-									else $output .= '"aircraft_shadow": "ship.png",';
355
+									if ($compress) {
356
+										$output .= '"as": "ship.png",';
357
+									} else {
358
+										$output .= '"aircraft_shadow": "ship.png",';
359
+									}
285 360
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
286
-									if ($compress) $output .= '"as": "ship.png",';
287
-									else $output .= '"aircraft_shadow": "ship.png",';
361
+									if ($compress) {
362
+										$output .= '"as": "ship.png",';
363
+									} else {
364
+										$output .= '"aircraft_shadow": "ship.png",';
365
+									}
288 366
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
289
-									if ($compress) $output .= '"as": "truck.png",';
290
-									else $output .= '"aircraft_shadow": "truck.png",';
367
+									if ($compress) {
368
+										$output .= '"as": "truck.png",';
369
+									} else {
370
+										$output .= '"aircraft_shadow": "truck.png",';
371
+									}
291 372
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
292
-									if ($compress) $output .= '"as": "truck.png",';
293
-									else $output .= '"aircraft_shadow": "truck.png",';
373
+									if ($compress) {
374
+										$output .= '"as": "truck.png",';
375
+									} else {
376
+										$output .= '"aircraft_shadow": "truck.png",';
377
+									}
294 378
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
295
-									if ($compress) $output .= '"as": "aircraft.png",';
296
-									else $output .= '"aircraft_shadow": "aircraft.png",';
379
+									if ($compress) {
380
+										$output .= '"as": "aircraft.png",';
381
+									} else {
382
+										$output .= '"aircraft_shadow": "aircraft.png",';
383
+									}
297 384
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
298
-									if ($compress) $output .= '"as": "aircraft.png",';
299
-									else $output .= '"aircraft_shadow": "aircraft.png",';
385
+									if ($compress) {
386
+										$output .= '"as": "aircraft.png",';
387
+									} else {
388
+										$output .= '"aircraft_shadow": "aircraft.png",';
389
+									}
300 390
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
301
-									if ($compress) $output .= '"as": "helico.png",';
302
-									else $output .= '"aircraft_shadow": "helico.png",';
391
+									if ($compress) {
392
+										$output .= '"as": "helico.png",';
393
+									} else {
394
+										$output .= '"aircraft_shadow": "helico.png",';
395
+									}
303 396
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
304
-									if ($compress) $output .= '"as": "rail.png",';
305
-									else $output .= '"aircraft_shadow": "rail.png",';
397
+									if ($compress) {
398
+										$output .= '"as": "rail.png",';
399
+									} else {
400
+										$output .= '"aircraft_shadow": "rail.png",';
401
+									}
306 402
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
307
-									if ($compress) $output .= '"as": "firetruck.png",';
308
-									else $output .= '"aircraft_shadow": "firetruck.png",';
403
+									if ($compress) {
404
+										$output .= '"as": "firetruck.png",';
405
+									} else {
406
+										$output .= '"aircraft_shadow": "firetruck.png",';
407
+									}
309 408
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
310
-									if ($compress) $output .= '"as": "bus.png",';
311
-									else $output .= '"aircraft_shadow": "bus.png",';
409
+									if ($compress) {
410
+										$output .= '"as": "bus.png",';
411
+									} else {
412
+										$output .= '"aircraft_shadow": "bus.png",';
413
+									}
312 414
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
313
-									if ($compress) $output .= '"as": "phone.png",';
314
-									else $output .= '"aircraft_shadow": "phone.png",';
415
+									if ($compress) {
416
+										$output .= '"as": "phone.png",';
417
+									} else {
418
+										$output .= '"aircraft_shadow": "phone.png",';
419
+									}
315 420
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
316
-									if ($compress) $output .= '"as": "jogger.png",';
317
-									else $output .= '"aircraft_shadow": "jogger.png",';
421
+									if ($compress) {
422
+										$output .= '"as": "jogger.png",';
423
+									} else {
424
+										$output .= '"aircraft_shadow": "jogger.png",';
425
+									}
318 426
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
319
-									if ($compress) $output .= '"as": "bike.png",';
320
-									else $output .= '"aircraft_shadow": "bike.png",';
427
+									if ($compress) {
428
+										$output .= '"as": "bike.png",';
429
+									} else {
430
+										$output .= '"aircraft_shadow": "bike.png",';
431
+									}
321 432
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
322
-									if ($compress) $output .= '"as": "motorcycle.png",';
323
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
433
+									if ($compress) {
434
+										$output .= '"as": "motorcycle.png",';
435
+									} else {
436
+										$output .= '"aircraft_shadow": "motorcycle.png",';
437
+									}
324 438
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
325
-									if ($compress) $output .= '"as": "balloon.png",';
326
-									else $output .= '"aircraft_shadow": "balloon.png",';
439
+									if ($compress) {
440
+										$output .= '"as": "balloon.png",';
441
+									} else {
442
+										$output .= '"aircraft_shadow": "balloon.png",';
443
+									}
327 444
 								} else {
328
-									if ($compress) $output .= '"as": "car.png",';
329
-									else $output .= '"aircraft_shadow": "car.png",';
445
+									if ($compress) {
446
+										$output .= '"as": "car.png",';
447
+									} else {
448
+										$output .= '"aircraft_shadow": "car.png",';
449
+									}
330 450
 								}
331 451
 							} elseif ($marine) {
332
-								if ($compress) $output .= '"as": "ship.png",';
333
-								else $output .= '"aircraft_shadow": "ship.png",';
452
+								if ($compress) {
453
+									$output .= '"as": "ship.png",';
454
+								} else {
455
+									$output .= '"aircraft_shadow": "ship.png",';
456
+								}
334 457
 							} else {
335
-								if ($compress) $output .= '"as": "default.png",';
336
-								else $output .= '"aircraft_shadow": "default.png",';
458
+								if ($compress) {
459
+									$output .= '"as": "default.png",';
460
+								} else {
461
+									$output .= '"aircraft_shadow": "default.png",';
462
+								}
337 463
 							}
338 464
 						} else {
339
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
340
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
465
+							if ($compress) {
466
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
467
+							} else {
468
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
469
+							}
341 470
 						}
342 471
 						if (isset($spotter_item['airline_name'])) {
343 472
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -345,8 +474,11 @@  discard block
 block discarded – undo
345 474
 							$output .= '"airline_name": "NA",';
346 475
 						}
347 476
 						if (isset($spotter_item['departure_airport'])) {
348
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
349
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
477
+							if ($compress) {
478
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
479
+							} else {
480
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
481
+							}
350 482
 						}
351 483
 						if (isset($spotter_item['departure_airport_city'])) {
352 484
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -358,8 +490,11 @@  discard block
 block discarded – undo
358 490
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
359 491
 						}
360 492
 						if (isset($spotter_item['arrival_airport'])) {
361
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
362
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
493
+							if ($compress) {
494
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
495
+							} else {
496
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
497
+							}
363 498
 						}
364 499
 						if (isset($spotter_item['arrival_airport_city'])) {
365 500
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -378,11 +513,17 @@  discard block
 block discarded – undo
378 513
 						}
379 514
 						
380 515
 						if (isset($spotter_item['altitude'])) {
381
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
382
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
516
+							if ($compress) {
517
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
518
+							} else {
519
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
520
+							}
521
+						}
522
+						if ($compress) {
523
+							$output .= '"h": "'.$spotter_item['heading'].'",';
524
+						} else {
525
+							$output .= '"heading": "'.$spotter_item['heading'].'",';
383 526
 						}
384
-						if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';
385
-						else $output .= '"heading": "'.$spotter_item['heading'].'",';
386 527
 						
387 528
 						if (isset($archivespeed)) {
388 529
 							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
@@ -392,7 +533,9 @@  discard block
 block discarded – undo
392 533
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
393 534
 						}
394 535
 
395
-						if (!$min) $output .= '"image": "'.$image.'",';
536
+						if (!$min) {
537
+							$output .= '"image": "'.$image.'",';
538
+						}
396 539
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
397 540
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
398 541
 						}
@@ -400,8 +543,11 @@  discard block
 block discarded – undo
400 543
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
401 544
 						}
402 545
 						if (isset($spotter_item['squawk'])) {
403
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
404
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
546
+							if ($compress) {
547
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
548
+							} else {
549
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
550
+							}
405 551
 						}
406 552
 						if (isset($spotter_item['squawk_usage'])) {
407 553
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -420,14 +566,23 @@  discard block
 block discarded – undo
420 566
 						}
421 567
 						// type when not aircraft ?
422 568
 						if (isset($spotter_item['type'])) {
423
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
424
-							else $output .= '"type": "'.$spotter_item['type'].'"';
569
+							if ($compress) {
570
+								$output .= '"t": "'.$spotter_item['type'].'"';
571
+							} else {
572
+								$output .= '"type": "'.$spotter_item['type'].'"';
573
+							}
425 574
 						} elseif ($marine) {
426
-							if ($compress) $output .= '"t": "ship"';
427
-							else $output .= '"type": "ship"';
575
+							if ($compress) {
576
+								$output .= '"t": "ship"';
577
+							} else {
578
+								$output .= '"type": "ship"';
579
+							}
428 580
 						} else {
429
-							if ($compress) $output .= '"t": "aircraft"';
430
-							else $output .= '"type": "aircraft"';
581
+							if ($compress) {
582
+								$output .= '"t": "aircraft"';
583
+							} else {
584
+								$output .= '"type": "aircraft"';
585
+							}
431 586
 						}
432 587
 						$output .= '},';
433 588
 						$output .= '"geometry": {';
@@ -495,7 +650,9 @@  discard block
 block discarded – undo
495 650
 			}
496 651
 */
497 652
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
498
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
653
+				if ($history == '' && isset($_COOKIE['history'])) {
654
+					$history = $_COOKIE['history'];
655
+				}
499 656
 				
500 657
 				if (
501 658
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -539,8 +696,11 @@  discard block
 block discarded – undo
539 696
 									$output_history .= ']}},';
540 697
 									$output .= $output_history;
541 698
 								}
542
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
543
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
699
+								if ($compress) {
700
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
701
+								} else {
702
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
703
+								}
544 704
 							}
545 705
 							$output_history .= '[';
546 706
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -559,9 +719,14 @@  discard block
 block discarded – undo
559 719
 							$prev_alt = $alt;
560 720
 						} else {
561 721
 							if ($d == false) {
562
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": [';
563
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
564
-							} else $d = true;
722
+								if ($compress) {
723
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": [';
724
+								} else {
725
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
726
+								}
727
+							} else {
728
+								$d = true;
729
+							}
565 730
 							$output_history .= '[';
566 731
 							$output_history .=  $spotter_history['longitude'].', ';
567 732
 							$output_history .=  $spotter_history['latitude'];
@@ -582,7 +747,9 @@  discard block
 block discarded – undo
582 747
 							$output_historyd = '[';
583 748
 							$output_historyd .=  $spotter_item['longitude'].', ';
584 749
 							$output_historyd .=  $spotter_item['latitude'];
585
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
750
+							if (isset($spotter_history['altitude'])) {
751
+								$output_historyd .=  ','.$spotter_item['altitude']*30.48;
752
+							}
586 753
 							$output_historyd .= '],';
587 754
 							//$output_history = $output_historyd.$output_history;
588 755
 							$output_history = $output_history.$output_historyd;
@@ -604,8 +771,11 @@  discard block
 block discarded – undo
604 771
 				        && $spotter_item['arrival_airport'] != 'NA' 
605 772
 				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
606 773
 				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
607
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
608
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
774
+				    if ($compress) {
775
+				    	$output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
776
+				    } else {
777
+				    	$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
778
+				    }
609 779
 				    if (isset($spotter_item['departure_airport_latitude'])) {
610 780
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
611 781
 				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
@@ -638,8 +808,11 @@  discard block
 block discarded – undo
638 808
 				    	    || (!isset($_COOKIE['MapRemainaingRoute']) && (!isset($globalMapRemainingRoute) 
639 809
 				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
640 810
 				    $havedata = false;
641
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
642
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
811
+				    if ($compress) {
812
+				    	$output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
813
+				    } else {
814
+				    	$output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
815
+				    }
643 816
 				    $output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
644 817
 
645 818
 				    if (isset($spotter_item['arrival_airport_latitude'])) {
@@ -654,7 +827,9 @@  discard block
 block discarded – undo
654 827
 				    }
655 828
 				    //$output_dest  = substr($output_dest, 0, -1);
656 829
 				    $output_dest .= ']}},';
657
-				    if ($havedata) $output .= $output_dest;
830
+				    if ($havedata) {
831
+				    	$output .= $output_dest;
832
+				    }
658 833
 				    unset($output_dest);
659 834
 				}
660 835
 			}
@@ -662,7 +837,9 @@  discard block
 block discarded – undo
662 837
 			$output .= ']';
663 838
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
664 839
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
665
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
840
+			if (isset($begindate)) {
841
+				$output .= '"archive_date": "'.$begindate.'",';
842
+			}
666 843
 			$output .= '"fc": "'.$j.'"';
667 844
 		} else {
668 845
 			$output .= '"features": ';
Please login to merge, or discard this patch.
header.php 1 patch
Braces   +73 added lines, -16 removed lines patch added patch discarded remove patch
@@ -3,10 +3,15 @@  discard block
 block discarded – undo
3 3
 //gets the page file and stores it in a variable
4 4
 $file_path = pathinfo($_SERVER['SCRIPT_NAME']);
5 5
 $current_page = $file_path['filename'];
6
-if ($globalTimezone == '') $globalTimezone = 'UTC';
6
+if ($globalTimezone == '') {
7
+	$globalTimezone = 'UTC';
8
+}
7 9
 date_default_timezone_set($globalTimezone);
8
-if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType'];
9
-else $MapType = $globalMapProvider;
10
+if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') {
11
+	$MapType = $_COOKIE['MapType'];
12
+} else {
13
+	$MapType = $globalMapProvider;
14
+}
10 15
 if (isset($_GET['3d'])) {
11 16
 	setcookie('MapFormat','3d');
12 17
 } else if (isset($_GET['2d'])) {
@@ -240,7 +245,13 @@  discard block
 block discarded – undo
240 245
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
241 246
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
242 247
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
243
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
248
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) {
249
+	print '&latitude='.$latitude;
250
+}
251
+?><?php if(isset($longitude)) {
252
+	print '&longitude='.$longitude;
253
+}
254
+?>&<?php print time(); ?>"></script>
244 255
 <?php
245 256
 		if (!isset($type) || $type == 'aircraft') {
246 257
 ?>
@@ -310,7 +321,13 @@  discard block
 block discarded – undo
310 321
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
311 322
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
312 323
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
313
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
324
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) {
325
+	print '&latitude='.$latitude;
326
+}
327
+?><?php if(isset($longitude)) {
328
+	print '&longitude='.$longitude;
329
+}
330
+?>&<?php print time(); ?>"></script>
314 331
 <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script>
315 332
 <?php
316 333
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
@@ -391,7 +408,12 @@  discard block
 block discarded – undo
391 408
         <span class="icon-bar"></span>
392 409
       </button>
393 410
       <a href="<?php print $globalURL; ?>/search" class="navbar-toggle navbar-toggle-search"><i class="fa fa-search"></i></a>
394
-      <a class="navbar-brand" href="<?php if ($globalURL == '') print '/'; else print $globalURL; ?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
411
+      <a class="navbar-brand" href="<?php if ($globalURL == '') {
412
+	print '/';
413
+} else {
414
+	print $globalURL;
415
+}
416
+?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
395 417
     </div>
396 418
     <div class="collapse navbar-collapse">
397 419
 
@@ -417,7 +439,10 @@  discard block
 block discarded – undo
417 439
 <?php
418 440
     }
419 441
 ?>
420
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
442
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
443
+	echo 'right-';
444
+}
445
+?>caret"></b></a>
421 446
           <ul class="dropdown-menu">
422 447
           	<li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircrafts Types"); ?></a></li>
423 448
 <?php
@@ -488,8 +513,14 @@  discard block
 block discarded – undo
488 513
         </li>
489 514
       	<li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li>
490 515
       	<li><a href="<?php print $globalURL; ?>/statistics"><?php echo _("Statistics"); ?></a></li>
491
-        <li class="dropdown<?php if ($sub) echo '-submenu'; ?>">
492
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
516
+        <li class="dropdown<?php if ($sub) {
517
+	echo '-submenu';
518
+}
519
+?>">
520
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) {
521
+	echo 'right-';
522
+}
523
+?>caret"></b></a>
493 524
           <ul class="dropdown-menu">
494 525
           	<li><a href="<?php print $globalURL; ?>/tools/acars"><?php echo _("ACARS translator"); ?></a></li>
495 526
           	<li><a href="<?php print $globalURL; ?>/tools/metar"><?php echo _("METAR translator"); ?></a></li>
@@ -518,7 +549,10 @@  discard block
 block discarded – undo
518 549
 <?php
519 550
 	}
520 551
 ?>
521
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
552
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
553
+	echo 'right-';
554
+}
555
+?>caret"></b></a>
522 556
 		<ul class="dropdown-menu">
523 557
 		    <li><a href="<?php print $globalURL; ?>/marine/currently"><?php echo _("Current Activity"); ?></a></li>
524 558
 		    <li><a href="<?php print $globalURL; ?>/marine/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -550,7 +584,10 @@  discard block
 block discarded – undo
550 584
 <?php
551 585
 	}
552 586
 ?>
553
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
587
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
588
+	echo 'right-';
589
+}
590
+?>caret"></b></a>
554 591
 		<ul class="dropdown-menu">
555 592
 		    <li><a href="<?php print $globalURL; ?>/tracker/currently"><?php echo _("Current Activity"); ?></a></li>
556 593
 		    <li><a href="<?php print $globalURL; ?>/tracker/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -606,7 +643,9 @@  discard block
 block discarded – undo
606 643
   		        $alllang = $Language->getLanguages();
607 644
   		        foreach ($alllang as $key => $lang) {
608 645
   		            print '<option value="'.$key.'"';
609
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
646
+  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) {
647
+  		            	print ' selected ';
648
+  		            }
610 649
   		            print '>'.$lang[0].'</option>';
611 650
   		        }
612 651
   		    ?>
@@ -746,9 +785,24 @@  discard block
 block discarded – undo
746 785
 	$customid = $globalMapProvider;
747 786
 ?>
748 787
     L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
749
-        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>,
750
-        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
751
-        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
788
+        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
789
+	print $globalMapCustomLayer[$customid]['maxZoom'];
790
+} else {
791
+	print '18';
792
+}
793
+?>,
794
+        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
795
+	print $globalMapCustomLayer[$customid]['minZoom'];
796
+} else {
797
+	print '0';
798
+}
799
+?>,
800
+        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
801
+	print 'false';
802
+} else {
803
+	print 'true';
804
+}
805
+?>,
752 806
         attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
753 807
     }).addTo(map);
754 808
 <?php
@@ -771,4 +825,7 @@  discard block
 block discarded – undo
771 825
 
772 826
 ?>
773 827
 
774
-<section class="container main-content <?php if (strtolower($current_page) == 'index') print 'index '; ?>clear">
828
+<section class="container main-content <?php if (strtolower($current_page) == 'index') {
829
+	print 'index ';
830
+}
831
+?>clear">
Please login to merge, or discard this patch.
require/class.TrackerImport.php 3 patches
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@  discard block
 block discarded – undo
7 7
 require_once(dirname(__FILE__).'/class.Source.php');
8 8
 
9 9
 class TrackerImport {
10
-    private $all_tracked = array();
11
-    private $last_delete_hourly = 0;
12
-    private $last_delete = 0;
13
-    private $stats = array();
14
-    private $tmd = 0;
15
-    private $source_location = array();
16
-    public $db = null;
17
-    public $nb = 0;
10
+	private $all_tracked = array();
11
+	private $last_delete_hourly = 0;
12
+	private $last_delete = 0;
13
+	private $stats = array();
14
+	private $tmd = 0;
15
+	private $source_location = array();
16
+	public $db = null;
17
+	public $nb = 0;
18 18
 
19
-    public function __construct($dbc = null) {
19
+	public function __construct($dbc = null) {
20 20
 	global $globalBeta;
21 21
 	$Connection = new Connection($dbc);
22 22
 	$this->db = $Connection->db();
@@ -38,50 +38,50 @@  discard block
 block discarded – undo
38 38
 	    }
39 39
 	}
40 40
 	*/
41
-    }
41
+	}
42 42
 
43
-    public function checkAll() {
43
+	public function checkAll() {
44 44
 	global $globalDebug;
45 45
 	if ($globalDebug) echo "Update last seen tracked data...\n";
46 46
 	foreach ($this->all_tracked as $key => $flight) {
47
-	    if (isset($this->all_tracked[$key]['id'])) {
47
+		if (isset($this->all_tracked[$key]['id'])) {
48 48
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
49
-    		$Tracker = new Tracker($this->db);
50
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
51
-            }
49
+			$Tracker = new Tracker($this->db);
50
+			$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
51
+			}
52
+	}
52 53
 	}
53
-    }
54 54
 
55
-    public function del() {
55
+	public function del() {
56 56
 	global $globalDebug;
57 57
 	// Delete old infos
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60
-    	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
62
-            	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
60
+			if (isset($flight['lastupdate'])) {
61
+			if ($flight['lastupdate'] < (time()-3000)) {
62
+					if (isset($this->all_tracked[$key]['id'])) {
63
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
65 65
 			$TrackerLive = new TrackerLive();
66 66
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
67 67
 			$TrackerLive->db = null;
68 68
 			*/
69
-            		//$real_arrival = $this->arrival($key);
70
-            		$Tracker = new Tracker($this->db);
71
-            		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
69
+					//$real_arrival = $this->arrival($key);
70
+					$Tracker = new Tracker($this->db);
71
+					if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 72
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
73 73
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
74 74
 			}
75 75
 			// Put in archive
76 76
 //			$Tracker->db = null;
77
-            	    }
78
-            	    unset($this->all_tracked[$key]);
79
-    	        }
80
-	    }
81
-        }
82
-    }
77
+					}
78
+					unset($this->all_tracked[$key]);
79
+				}
80
+		}
81
+		}
82
+	}
83 83
 
84
-    public function add($line) {
84
+	public function add($line) {
85 85
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86 86
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
87 87
 	date_default_timezone_set('UTC');
@@ -90,47 +90,47 @@  discard block
 block discarded – undo
90 90
 	
91 91
 	// SBS format is CSV format
92 92
 	if(is_array($line) && isset($line['ident'])) {
93
-	    //print_r($line);
94
-  	    if (isset($line['ident'])) {
93
+		//print_r($line);
94
+  		if (isset($line['ident'])) {
95 95
 
96 96
 		
97 97
 		// Increment message number
98 98
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99
-		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
99
+			$current_date = date('Y-m-d');
100
+			if (isset($line['source_name'])) $source = $line['source_name'];
101
+			else $source = '';
102
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
104
+				$this->stats[$current_date][$source]['msg']['date'] = time();
105
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
107 107
 		}
108 108
 		
109 109
 		
110 110
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
111
+			if (!isset($line['id'])) $id = trim($line['ident']);
112
+			else $id = trim($line['id']);
113 113
 		
114 114
 		if (!isset($this->all_tracked[$id])) {
115
-		    $this->all_tracked[$id] = array();
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
-		    if (!isset($line['id'])) {
115
+			$this->all_tracked[$id] = array();
116
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
+			if (!isset($line['id'])) {
120 120
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
121 121
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
122
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
+			if ($globalAllTracked !== FALSE) $dataFound = true;
124 124
 		}
125 125
 		
126 126
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
127
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 128
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129
-		    } else {
129
+			} else {
130 130
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131 131
 				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]['ident']." - format : ".$line['format_source']."\n";
132 132
 				return '';
133
-		    }
133
+			}
134 134
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135 135
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
136 136
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//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'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
-		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
150
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
+			if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153
-            		$Tracker = new Tracker($this->db);
154
-            		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
153
+					$Tracker = new Tracker($this->db);
154
+					$fromsource = NULL;
155
+					$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158 158
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
159
-		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159
+			}
160
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
166 166
 		} 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'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
-		    if ($distance > 100 && $distance < 10000) {
167
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
+			if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171 171
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173
-		    }
173
+			}
174 174
 		}
175 175
 
176
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
-	    	    else unset($timediff);
179
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($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')))) {
176
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
+				else unset($timediff);
179
+				if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($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')))) {
180 180
 			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'])) {
181
-			    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'])) {
181
+				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'])) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -192,30 +192,30 @@  discard block
 block discarded – undo
192 192
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195
-			    }
195
+				}
196 196
 			}
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200 200
 				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') {
201
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
-				    $dataFound = true;
203
-				    $this->all_tracked[$id]['time_last_coord'] = time();
201
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
+					$dataFound = true;
203
+					$this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205 205
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
208
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210 210
 				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') {
211
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
-				    $dataFound = true;
213
-				    $this->all_tracked[$id]['time_last_coord'] = time();
211
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
+					$dataFound = true;
213
+					$this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215 215
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218
-		    } else if ($globalDebug && $timediff > 20) {
218
+			} else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) {
221 221
 				echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
@@ -223,131 +223,131 @@  discard block
 block discarded – undo
223 223
 				echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
224 224
 				echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
225 225
 			}
226
-		    }
226
+			}
227 227
 		}
228 228
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
229
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
231 231
 		}
232 232
 		if (isset($line['format_source']) && $line['format_source'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
233
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
234 234
 		}
235 235
 		if (isset($line['source_name']) && $line['source_name'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
236
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
237 237
 		}
238 238
 		if (isset($line['comment']) && $line['comment'] != '') {
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
240
-		    //$dataFound = true;
239
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
240
+			//$dataFound = true;
241 241
 		}
242 242
 		if (isset($line['type']) && $line['type'] != '') {
243
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
244
-		    //$dataFound = true;
243
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
244
+			//$dataFound = true;
245 245
 		}
246 246
 
247 247
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248
-		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
248
+			//if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249 249
 			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250 250
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251 251
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
252 252
 			//$dataFound = true;
253
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
253
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
254 254
   		}
255 255
 
256 256
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
257
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
257
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
258 258
 		}
259 259
 		
260 260
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264
-		    //$dataFound = true;
261
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264
+			//$dataFound = true;
265 265
   		} 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']) {
266
-  		    $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']);
267
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
266
+  			$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']);
267
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
270 270
   		}
271 271
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
272 272
 
273 273
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
274
-		    $this->all_tracked[$id]['lastupdate'] = time();
275
-		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
274
+			$this->all_tracked[$id]['lastupdate'] = time();
275
+			if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278 278
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
279 279
 				$timeelapsed = microtime(true);
280 280
 				$TrackerLive = new TrackerLive($this->db);
281 281
 				if (isset($line['id'])) {
282
-				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
282
+					$recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
284 284
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285
-				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
285
+					$recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287 287
 				} else $recent_ident = '';
288 288
 				$TrackerLive->db=null;
289 289
 
290 290
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291 291
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
292
-			    } else {
292
+				} else {
293 293
 				$recent_ident = '';
294 294
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
295
-			    }
296
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
-			    if($recent_ident == "")
298
-			    {
295
+				}
296
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
+				if($recent_ident == "")
298
+				{
299 299
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
300 300
 				//adds the spotter data for the archive
301
-				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303
-				    $timeelapsed = microtime(true);
304
-				    $Tracker = new Tracker($this->db);
305
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306
-				    $Tracker->db = null;
307
-				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
301
+					$highlight = '';
302
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303
+					$timeelapsed = microtime(true);
304
+					$Tracker = new Tracker($this->db);
305
+					$result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306
+					$Tracker->db = null;
307
+					if ($globalDebug && isset($result)) echo $result."\n";
308
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
309 309
 				    
310 310
 				    
311
-				    // Add source stat in DB
312
-				    $Stats = new Stats($this->db);
313
-				    if (!empty($this->stats)) {
311
+					// Add source stat in DB
312
+					$Stats = new Stats($this->db);
313
+					if (!empty($this->stats)) {
314 314
 					if ($globalDebug) echo 'Add source stats : ';
315
-				        foreach($this->stats as $date => $data) {
316
-					    foreach($data as $source => $sourced) {
317
-					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
320
-				    		if (isset($sourced['msg'])) {
321
-				    		    if (time() - $sourced['msg']['date'] > 10) {
322
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
324
-			    			        unset($this->stats[$date][$source]['msg']);
325
-			    			    }
326
-			    			}
327
-			    		    }
328
-			    		    if ($date != date('Y-m-d')) {
329
-			    			unset($this->stats[$date]);
330
-			    		    }
331
-				    	}
332
-				    	if ($globalDebug) echo 'Done'."\n";
315
+						foreach($this->stats as $date => $data) {
316
+						foreach($data as $source => $sourced) {
317
+							//print_r($sourced);
318
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
320
+							if (isset($sourced['msg'])) {
321
+								if (time() - $sourced['msg']['date'] > 10) {
322
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
+									echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
324
+									unset($this->stats[$date][$source]['msg']);
325
+								}
326
+							}
327
+							}
328
+							if ($date != date('Y-m-d')) {
329
+							unset($this->stats[$date]);
330
+							}
331
+						}
332
+						if ($globalDebug) echo 'Done'."\n";
333 333
 
334
-				    }
335
-				    $Stats->db = null;
334
+					}
335
+					$Stats->db = null;
336 336
 				    
337
-				    $this->del();
337
+					$this->del();
338 338
 				//$ignoreImport = false;
339 339
 				$this->all_tracked[$id]['addedTracker'] = 1;
340 340
 				//print_r($this->all_tracked[$id]);
341 341
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
342
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
343
-				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344
-				    $TrackerLive = new TrackerLive($this->db);
345
-				    $TrackerLive->deleteLiveTrackerData();
346
-				    $TrackerLive->db=null;
347
-				    if ($globalDebug) echo " Done\n";
348
-				    $this->last_delete = time();
342
+					if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
343
+					//TrackerLive->deleteLiveTrackerDataNotUpdated();
344
+					$TrackerLive = new TrackerLive($this->db);
345
+					$TrackerLive->deleteLiveTrackerData();
346
+					$TrackerLive->db=null;
347
+					if ($globalDebug) echo " Done\n";
348
+					$this->last_delete = time();
349 349
 				}
350
-			    } else {
350
+				} else {
351 351
 				$this->all_tracked[$id]['id'] = $recent_ident;
352 352
 				$this->all_tracked[$id]['addedTracker'] = 1;
353 353
 				if (isset($globalDaemon) && !$globalDaemon) {
@@ -356,16 +356,16 @@  discard block
 block discarded – undo
356 356
 					$Tracker->db = null;
357 357
 				}
358 358
 				
359
-			    }
359
+				}
360 360
 			}
361
-		    }
362
-		    //adds the spotter LIVE data
363
-		    if ($globalDebug) {
361
+			}
362
+			//adds the spotter LIVE data
363
+			if ($globalDebug) {
364 364
 			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'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
365
-		    }
366
-		    $ignoreImport = false;
365
+			}
366
+			$ignoreImport = false;
367 367
 
368
-		    if (!$ignoreImport) {
368
+			if (!$ignoreImport) {
369 369
 			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'])) {
370 370
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
371 371
 				$timeelapsed = microtime(true);
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 					if ($stats_heading == 16) $stats_heading = 0;
404 404
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405 405
 						for ($i=0;$i<=15;$i++) {
406
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
406
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
407 407
 						}
408 408
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
409 409
 					} else {
@@ -416,11 +416,11 @@  discard block
 block discarded – undo
416 416
 					//var_dump($this->stats);
417 417
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
418 418
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419
-						    end($this->stats[$current_date][$source]['hist']);
420
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
419
+							end($this->stats[$current_date][$source]['hist']);
420
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
421 421
 						} else $mini = 0;
422 422
 						for ($i=$mini;$i<=$distance;$i+=10) {
423
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
423
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
424 424
 						}
425 425
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
426 426
 					} else {
@@ -436,22 +436,22 @@  discard block
 block discarded – undo
436 436
 			
437 437
 			
438 438
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
-			    $TrackerLive = new TrackerLive($this->db);
441
-			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442
-			    $TrackerLive->db = null;
443
-			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
445
-			    $this->last_delete_hourly = time();
439
+				if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
+				$TrackerLive = new TrackerLive($this->db);
441
+				$TrackerLive->deleteLiveTrackerDataNotUpdated();
442
+				$TrackerLive->db = null;
443
+				//TrackerLive->deleteLiveTrackerData();
444
+				if ($globalDebug) echo " Done\n";
445
+				$this->last_delete_hourly = time();
446 446
 			}
447 447
 			
448
-		    }
449
-		    //$ignoreImport = false;
448
+			}
449
+			//$ignoreImport = false;
450 450
 		}
451 451
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452 452
 		if ($send) return $this->all_tracked[$id];
453
-	    }
453
+		}
454
+	}
454 455
 	}
455
-    }
456 456
 }
457 457
 ?>
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	    if (isset($this->all_tracked[$key]['id'])) {
48 48
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
49 49
     		$Tracker = new Tracker($this->db);
50
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
50
+        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
51 51
             }
52 52
 	}
53 53
     }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60 60
     	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
61
+        	if ($flight['lastupdate'] < (time() - 3000)) {
62 62
             	    if (isset($this->all_tracked[$key]['id'])) {
63 63
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
             		//$real_arrival = $this->arrival($key);
70 70
             		$Tracker = new Tracker($this->db);
71 71
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72
-				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
72
+				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed']);
73 73
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
74 74
 			}
75 75
 			// Put in archive
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	$send = false;
90 90
 	
91 91
 	// SBS format is CSV format
92
-	if(is_array($line) && isset($line['ident'])) {
92
+	if (is_array($line) && isset($line['ident'])) {
93 93
 	    //print_r($line);
94 94
   	    if (isset($line['ident'])) {
95 95
 
@@ -113,33 +113,33 @@  discard block
 block discarded – undo
113 113
 		
114 114
 		if (!isset($this->all_tracked[$id])) {
115 115
 		    $this->all_tracked[$id] = array();
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
116
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedTracker' => 0));
117
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => ''));
118
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
119 119
 		    if (!isset($line['id'])) {
120 120
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
121
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
121
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
122
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
123 123
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
124 124
 		}
125 125
 		
126
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
126
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
127 127
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
128
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
129 129
 		    } else {
130 130
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131 131
 				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]['ident']." - format : ".$line['format_source']."\n";
132 132
 				return '';
133 133
 		    }
134
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
134
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
135 135
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
136 136
 			return '';
137
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
137
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
138 138
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
139 139
 			return '';
140 140
 		} elseif (!isset($line['datetime'])) {
141 141
 			date_default_timezone_set('UTC');
142
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
142
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
143 143
 		} else {
144 144
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
145 145
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//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'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
150
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
151 151
 		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153 153
             		$Tracker = new Tracker($this->db);
154 154
             		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
155
+            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
158
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
159 159
 		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
160
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
165
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
166 166
 		} 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'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
167
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
168 168
 		    if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
171
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173 173
 		    }
174 174
 		}
175 175
 
176 176
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
177
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
178 178
 	    	    else unset($timediff);
179
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($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')))) {
179
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($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')))) {
180 180
 			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'])) {
181
-			    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'])) {
181
+			    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'])) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
187 187
 				$timeelapsed = microtime(true);
188 188
 				$Tracker = new Tracker($this->db);
189
-				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
189
+				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
190 190
 				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
191 191
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
192
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195 195
 			    }
@@ -197,75 +197,75 @@  discard block
 block discarded – undo
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200
-				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') {
200
+				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') {
201 201
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 202
 				    $dataFound = true;
203 203
 				    $this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
205
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208 208
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210
-				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') {
210
+				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') {
211 211
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 212
 				    $dataFound = true;
213 213
 				    $this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
215
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218 218
 		    } else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) {
221 221
 				echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
222
-				echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
223
-				echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
222
+				echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
223
+				echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
224 224
 				echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
225 225
 			}
226 226
 		    }
227 227
 		}
228 228
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229 229
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
230
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
231 231
 		}
232 232
 		if (isset($line['format_source']) && $line['format_source'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
233
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
234 234
 		}
235 235
 		if (isset($line['source_name']) && $line['source_name'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
236
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
237 237
 		}
238 238
 		if (isset($line['comment']) && $line['comment'] != '') {
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
239
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment']));
240 240
 		    //$dataFound = true;
241 241
 		}
242 242
 		if (isset($line['type']) && $line['type'] != '') {
243
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
243
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
244 244
 		    //$dataFound = true;
245 245
 		}
246 246
 
247 247
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248 248
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
249
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => $line['altitude']));
251
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude']));
252 252
 			//$dataFound = true;
253 253
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
254 254
   		}
255 255
 
256 256
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
257
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
257
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
258 258
 		}
259 259
 		
260 260
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
261
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
263
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
264 264
 		    //$dataFound = true;
265 265
   		} 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']) {
266
-  		    $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']);
267
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266
+  		    $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']);
267
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
268
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269 269
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
270 270
   		}
271 271
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -273,54 +273,54 @@  discard block
 block discarded – undo
273 273
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
274 274
 		    $this->all_tracked[$id]['lastupdate'] = time();
275 275
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
276
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277 277
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278 278
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
279 279
 				$timeelapsed = microtime(true);
280 280
 				$TrackerLive = new TrackerLive($this->db);
281 281
 				if (isset($line['id'])) {
282 282
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
283
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
284 284
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285 285
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
286
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
287 287
 				} else $recent_ident = '';
288
-				$TrackerLive->db=null;
288
+				$TrackerLive->db = null;
289 289
 
290 290
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291 291
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
292 292
 			    } else {
293 293
 				$recent_ident = '';
294
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
294
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
295 295
 			    }
296 296
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
-			    if($recent_ident == "")
297
+			    if ($recent_ident == "")
298 298
 			    {
299 299
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
300 300
 				//adds the spotter data for the archive
301 301
 				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
302
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303 303
 				    $timeelapsed = microtime(true);
304 304
 				    $Tracker = new Tracker($this->db);
305
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
305
+				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']);
306 306
 				    $Tracker->db = null;
307 307
 				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
308
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
309 309
 				    
310 310
 				    
311 311
 				    // Add source stat in DB
312 312
 				    $Stats = new Stats($this->db);
313 313
 				    if (!empty($this->stats)) {
314 314
 					if ($globalDebug) echo 'Add source stats : ';
315
-				        foreach($this->stats as $date => $data) {
316
-					    foreach($data as $source => $sourced) {
315
+				        foreach ($this->stats as $date => $data) {
316
+					    foreach ($data as $source => $sourced) {
317 317
 					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
318
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_tracker', $date);
319
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_tracker', $date);
320 320
 				    		if (isset($sourced['msg'])) {
321 321
 				    		    if (time() - $sourced['msg']['date'] > 10) {
322 322
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
323
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg_tracker', $date);
324 324
 			    			        unset($this->stats[$date][$source]['msg']);
325 325
 			    			    }
326 326
 			    			}
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344 344
 				    $TrackerLive = new TrackerLive($this->db);
345 345
 				    $TrackerLive->deleteLiveTrackerData();
346
-				    $TrackerLive->db=null;
346
+				    $TrackerLive->db = null;
347 347
 				    if ($globalDebug) echo " Done\n";
348 348
 				    $this->last_delete = time();
349 349
 				}
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 				$this->all_tracked[$id]['addedTracker'] = 1;
353 353
 				if (isset($globalDaemon) && !$globalDaemon) {
354 354
 					$Tracker = new Tracker($this->db);
355
-					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['altitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
355
+					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']);
356 356
 					$Tracker->db = null;
357 357
 				}
358 358
 				
@@ -366,14 +366,14 @@  discard block
 block discarded – undo
366 366
 		    $ignoreImport = false;
367 367
 
368 368
 		    if (!$ignoreImport) {
369
-			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'])) {
369
+			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'])) {
370 370
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
371 371
 				$timeelapsed = microtime(true);
372 372
 				$TrackerLive = new TrackerLive($this->db);
373
-				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
373
+				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
374 374
 				$TrackerLive->db = null;
375 375
 				$this->all_tracked[$id]['putinarchive'] = false;
376
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
376
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
377 377
 
378 378
 				// Put statistics in $this->stats variable
379 379
 				
@@ -390,19 +390,19 @@  discard block
 block discarded – undo
390 390
 							$latitude = $globalCenterLatitude;
391 391
 							$longitude = $globalCenterLongitude;
392 392
 						}
393
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
393
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
394 394
 					} else {
395 395
 						$latitude = $this->source_location[$source]['latitude'];
396 396
 						$longitude = $this->source_location[$source]['longitude'];
397 397
 					}
398
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
398
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
399 399
 					//$stats_heading = $stats_heading%22.5;
400 400
 					$stats_heading = round($stats_heading/22.5);
401
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
401
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
402 402
 					$current_date = date('Y-m-d');
403 403
 					if ($stats_heading == 16) $stats_heading = 0;
404 404
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405
-						for ($i=0;$i<=15;$i++) {
405
+						for ($i = 0; $i <= 15; $i++) {
406 406
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
407 407
 						}
408 408
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -417,9 +417,9 @@  discard block
 block discarded – undo
417 417
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
418 418
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419 419
 						    end($this->stats[$current_date][$source]['hist']);
420
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
420
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
421 421
 						} else $mini = 0;
422
-						for ($i=$mini;$i<=$distance;$i+=10) {
422
+						for ($i = $mini; $i <= $distance; $i += 10) {
423 423
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
424 424
 						}
425 425
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 				$this->all_tracked[$id]['lastupdate'] = time();
432 432
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
433 433
 				if ($globalDebug) echo $result."\n";
434
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
434
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
435 435
 			//$this->del();
436 436
 			
437 437
 			
Please login to merge, or discard this patch.
Braces   +190 added lines, -65 removed lines patch added patch discarded remove patch
@@ -42,7 +42,9 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function checkAll() {
44 44
 	global $globalDebug;
45
-	if ($globalDebug) echo "Update last seen tracked data...\n";
45
+	if ($globalDebug) {
46
+		echo "Update last seen tracked data...\n";
47
+	}
46 48
 	foreach ($this->all_tracked as $key => $flight) {
47 49
 	    if (isset($this->all_tracked[$key]['id'])) {
48 50
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -55,12 +57,16 @@  discard block
 block discarded – undo
55 57
     public function del() {
56 58
 	global $globalDebug;
57 59
 	// Delete old infos
58
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
60
+	if ($globalDebug) {
61
+		echo 'Delete old values and update latest data...'."\n";
62
+	}
59 63
 	foreach ($this->all_tracked as $key => $flight) {
60 64
     	    if (isset($flight['lastupdate'])) {
61 65
         	if ($flight['lastupdate'] < (time()-3000)) {
62 66
             	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
67
+            		if ($globalDebug) {
68
+            			echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
69
+            		}
64 70
 			/*
65 71
 			$TrackerLive = new TrackerLive();
66 72
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
@@ -70,7 +76,9 @@  discard block
 block discarded – undo
70 76
             		$Tracker = new Tracker($this->db);
71 77
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 78
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
73
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
79
+				if ($globalDebug && $result != 'success') {
80
+					echo '!!! ERROR : '.$result."\n";
81
+				}
74 82
 			}
75 83
 			// Put in archive
76 84
 //			$Tracker->db = null;
@@ -83,7 +91,9 @@  discard block
 block discarded – undo
83 91
 
84 92
     public function add($line) {
85 93
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
94
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
95
+		$globalCoordMinChange = '0.02';
96
+	}
87 97
 	date_default_timezone_set('UTC');
88 98
 	$dataFound = false;
89 99
 	$send = false;
@@ -97,19 +107,29 @@  discard block
 block discarded – undo
97 107
 		// Increment message number
98 108
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99 109
 		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
110
+		    if (isset($line['source_name'])) {
111
+		    	$source = $line['source_name'];
112
+		    } else {
113
+		    	$source = '';
114
+		    }
115
+		    if ($source == '' || $line['format_source'] == 'aprs') {
116
+		    	$source = $line['format_source'];
117
+		    }
103 118
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104 119
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105 120
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
121
+		    } else {
122
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
123
+		    }
107 124
 		}
108 125
 		
109 126
 		
110 127
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
128
+	        if (!isset($line['id'])) {
129
+	        	$id = trim($line['ident']);
130
+	        } else {
131
+	        	$id = trim($line['id']);
132
+	        }
113 133
 		
114 134
 		if (!isset($this->all_tracked[$id])) {
115 135
 		    $this->all_tracked[$id] = array();
@@ -117,31 +137,46 @@  discard block
 block discarded – undo
117 137
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118 138
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119 139
 		    if (!isset($line['id'])) {
120
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
140
+			if (!isset($globalDaemon)) {
141
+				$globalDaemon = TRUE;
142
+			}
121 143
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
144
+		     } else {
145
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
146
+		     }
147
+		    if ($globalAllTracked !== FALSE) {
148
+		    	$dataFound = true;
149
+		    }
124 150
 		}
125 151
 		
126 152
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127 153
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 154
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129 155
 		    } else {
130
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131
-				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]['ident']." - format : ".$line['format_source']."\n";
156
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
157
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
158
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
159
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
160
+				}
132 161
 				return '';
133 162
 		    }
134 163
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
164
+			if ($globalDebug) {
165
+				echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
166
+			}
136 167
 			return '';
137 168
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
138
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
169
+			if ($globalDebug) {
170
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
171
+			}
139 172
 			return '';
140 173
 		} elseif (!isset($line['datetime'])) {
141 174
 			date_default_timezone_set('UTC');
142 175
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
143 176
 		} else {
144
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
177
+			if ($globalDebug) {
178
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
179
+			}
145 180
 			return '';
146 181
 		}
147 182
 		
@@ -153,11 +188,17 @@  discard block
 block discarded – undo
153 188
             		$Tracker = new Tracker($this->db);
154 189
             		$fromsource = NULL;
155 190
             		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
191
+			if ($globalDebug && $result != 'success') {
192
+				echo '!!! ERROR : '.$result."\n";
193
+			}
157 194
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
195
+			if ($globalDebugTimeElapsed) {
196
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
197
+			}
198
+		    }
199
+		    if (!isset($this->all_tracked[$id]['id'])) {
200
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159 201
 		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161 202
 		}
162 203
 
163 204
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -168,14 +209,21 @@  discard block
 block discarded – undo
168 209
 		    if ($distance > 100 && $distance < 10000) {
169 210
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 211
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
212
+			if ($speed < 1000) {
213
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
214
+			}
215
+  			if ($globalDebug) {
216
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
217
+  			}
173 218
 		    }
174 219
 		}
175 220
 
176 221
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
-	    	    else unset($timediff);
222
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
223
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
224
+	    	    } else {
225
+	    	    	unset($timediff);
226
+	    	    }
179 227
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($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')))) {
180 228
 			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'])) {
181 229
 			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -183,20 +231,30 @@  discard block
 block discarded – undo
183 231
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 232
 				$this->all_tracked[$id]['putinarchive'] = true;
185 233
 				
186
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
234
+				if ($globalDebug) {
235
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
236
+				}
187 237
 				$timeelapsed = microtime(true);
188 238
 				$Tracker = new Tracker($this->db);
189 239
 				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
190
-				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
240
+				if (!empty($all_country)) {
241
+					$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
242
+				}
191 243
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
244
+				if ($globalDebugTimeElapsed) {
245
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
246
+				}
193 247
 				$this->tmd = 0;
194
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
248
+				if ($globalDebug) {
249
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
250
+				}
195 251
 			    }
196 252
 			}
197 253
 
198 254
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
255
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
256
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
257
+				}
200 258
 				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') {
201 259
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 260
 				    $dataFound = true;
@@ -205,8 +263,12 @@  discard block
 block discarded – undo
205 263
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 264
 			}
207 265
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
266
+			    if ($line['longitude'] > 180) {
267
+			    	$line['longitude'] = $line['longitude'] - 360;
268
+			    }
269
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
270
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
271
+				}
210 272
 				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') {
211 273
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 274
 				    $dataFound = true;
@@ -226,7 +288,9 @@  discard block
 block discarded – undo
226 288
 		    }
227 289
 		}
228 290
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
291
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
292
+		    	$dataFound = true;
293
+		    }
230 294
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
231 295
 		}
232 296
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -246,7 +310,9 @@  discard block
 block discarded – undo
246 310
 
247 311
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248 312
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
313
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) {
314
+				$this->all_tracked[$id]['putinarchive'] = true;
315
+			}
250 316
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251 317
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
252 318
 			//$dataFound = true;
@@ -258,15 +324,21 @@  discard block
 block discarded – undo
258 324
 		}
259 325
 		
260 326
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
327
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
328
+		    	$this->all_tracked[$id]['putinarchive'] = true;
329
+		    }
262 330
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263 331
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264 332
 		    //$dataFound = true;
265 333
   		} 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']) {
266 334
   		    $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']);
267 335
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
336
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
337
+		    	$this->all_tracked[$id]['putinarchive'] = true;
338
+		    }
339
+  		    if ($globalDebug) {
340
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
341
+  		    }
270 342
   		}
271 343
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
272 344
 
@@ -275,20 +347,31 @@  discard block
 block discarded – undo
275 347
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276 348
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277 349
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
350
+				if ($globalDebug) {
351
+					echo "Check if aircraft is already in DB...";
352
+				}
279 353
 				$timeelapsed = microtime(true);
280 354
 				$TrackerLive = new TrackerLive($this->db);
281 355
 				if (isset($line['id'])) {
282 356
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
357
+				    if ($globalDebugTimeElapsed) {
358
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
359
+				    }
284 360
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285 361
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287
-				} else $recent_ident = '';
362
+				    if ($globalDebugTimeElapsed) {
363
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
364
+				    }
365
+				} else {
366
+					$recent_ident = '';
367
+				}
288 368
 				$TrackerLive->db=null;
289 369
 
290
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
370
+				if ($globalDebug && $recent_ident == '') {
371
+					echo " Not in DB.\n";
372
+				} elseif ($globalDebug && $recent_ident != '') {
373
+					echo " Already in DB.\n";
374
+				}
292 375
 			    } else {
293 376
 				$recent_ident = '';
294 377
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -296,27 +379,41 @@  discard block
 block discarded – undo
296 379
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297 380
 			    if($recent_ident == "")
298 381
 			    {
299
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
382
+				if ($globalDebug) {
383
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
384
+				}
300 385
 				//adds the spotter data for the archive
301 386
 				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
387
+				    if (!isset($this->all_tracked[$id]['id'])) {
388
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
389
+				    }
303 390
 				    $timeelapsed = microtime(true);
304 391
 				    $Tracker = new Tracker($this->db);
305 392
 				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306 393
 				    $Tracker->db = null;
307
-				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
394
+				    if ($globalDebug && isset($result)) {
395
+				    	echo $result."\n";
396
+				    }
397
+				    if ($globalDebugTimeElapsed) {
398
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
399
+				    }
309 400
 				    
310 401
 				    
311 402
 				    // Add source stat in DB
312 403
 				    $Stats = new Stats($this->db);
313 404
 				    if (!empty($this->stats)) {
314
-					if ($globalDebug) echo 'Add source stats : ';
405
+					if ($globalDebug) {
406
+						echo 'Add source stats : ';
407
+					}
315 408
 				        foreach($this->stats as $date => $data) {
316 409
 					    foreach($data as $source => $sourced) {
317 410
 					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
411
+				    	        if (isset($sourced['polar'])) {
412
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
413
+				    	        }
414
+				    	        if (isset($sourced['hist'])) {
415
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
416
+				    	        }
320 417
 				    		if (isset($sourced['msg'])) {
321 418
 				    		    if (time() - $sourced['msg']['date'] > 10) {
322 419
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -329,7 +426,9 @@  discard block
 block discarded – undo
329 426
 			    			unset($this->stats[$date]);
330 427
 			    		    }
331 428
 				    	}
332
-				    	if ($globalDebug) echo 'Done'."\n";
429
+				    	if ($globalDebug) {
430
+				    		echo 'Done'."\n";
431
+				    	}
333 432
 
334 433
 				    }
335 434
 				    $Stats->db = null;
@@ -339,12 +438,16 @@  discard block
 block discarded – undo
339 438
 				$this->all_tracked[$id]['addedTracker'] = 1;
340 439
 				//print_r($this->all_tracked[$id]);
341 440
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
342
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
441
+				    if ($globalDebug) {
442
+				    	echo "---- Deleting Live Tracker data older than 9 hours...";
443
+				    }
343 444
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344 445
 				    $TrackerLive = new TrackerLive($this->db);
345 446
 				    $TrackerLive->deleteLiveTrackerData();
346 447
 				    $TrackerLive->db=null;
347
-				    if ($globalDebug) echo " Done\n";
448
+				    if ($globalDebug) {
449
+				    	echo " Done\n";
450
+				    }
348 451
 				    $this->last_delete = time();
349 452
 				}
350 453
 			    } else {
@@ -367,19 +470,25 @@  discard block
 block discarded – undo
367 470
 
368 471
 		    if (!$ignoreImport) {
369 472
 			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'])) {
370
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
473
+				if ($globalDebug) {
474
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
475
+				}
371 476
 				$timeelapsed = microtime(true);
372 477
 				$TrackerLive = new TrackerLive($this->db);
373 478
 				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
374 479
 				$TrackerLive->db = null;
375 480
 				$this->all_tracked[$id]['putinarchive'] = false;
376
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
481
+				if ($globalDebugTimeElapsed) {
482
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
483
+				}
377 484
 
378 485
 				// Put statistics in $this->stats variable
379 486
 				
380 487
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
381 488
 					$source = $this->all_tracked[$id]['source_name'];
382
-					if ($source == '') $source = $this->all_tracked[$id]['format_source'];
489
+					if ($source == '') {
490
+						$source = $this->all_tracked[$id]['format_source'];
491
+					}
383 492
 					if (!isset($this->source_location[$source])) {
384 493
 						$Location = new Source();
385 494
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -400,7 +509,9 @@  discard block
 block discarded – undo
400 509
 					$stats_heading = round($stats_heading/22.5);
401 510
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
402 511
 					$current_date = date('Y-m-d');
403
-					if ($stats_heading == 16) $stats_heading = 0;
512
+					if ($stats_heading == 16) {
513
+						$stats_heading = 0;
514
+					}
404 515
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405 516
 						for ($i=0;$i<=15;$i++) {
406 517
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -418,7 +529,9 @@  discard block
 block discarded – undo
418 529
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419 530
 						    end($this->stats[$current_date][$source]['hist']);
420 531
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
421
-						} else $mini = 0;
532
+						} else {
533
+							$mini = 0;
534
+						}
422 535
 						for ($i=$mini;$i<=$distance;$i+=10) {
423 536
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
424 537
 						}
@@ -429,19 +542,29 @@  discard block
 block discarded – undo
429 542
 				}
430 543
 
431 544
 				$this->all_tracked[$id]['lastupdate'] = time();
432
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
433
-				if ($globalDebug) echo $result."\n";
434
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
545
+				if ($this->all_tracked[$id]['putinarchive']) {
546
+					$send = true;
547
+				}
548
+				if ($globalDebug) {
549
+					echo $result."\n";
550
+				}
551
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
552
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
553
+			}
435 554
 			//$this->del();
436 555
 			
437 556
 			
438 557
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
558
+			    if ($globalDebug) {
559
+			    	echo "---- Deleting Live Tracker data Not updated since 2 hour...";
560
+			    }
440 561
 			    $TrackerLive = new TrackerLive($this->db);
441 562
 			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442 563
 			    $TrackerLive->db = null;
443 564
 			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
565
+			    if ($globalDebug) {
566
+			    	echo " Done\n";
567
+			    }
445 568
 			    $this->last_delete_hourly = time();
446 569
 			}
447 570
 			
@@ -449,7 +572,9 @@  discard block
 block discarded – undo
449 572
 		    //$ignoreImport = false;
450 573
 		}
451 574
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452
-		if ($send) return $this->all_tracked[$id];
575
+		if ($send) {
576
+			return $this->all_tracked[$id];
577
+		}
453 578
 	    }
454 579
 	}
455 580
     }
Please login to merge, or discard this patch.
require/class.TrackerLive.php 3 patches
Indentation   +198 added lines, -198 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 getLiveTrackerData($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 getMinLiveTrackerData($filter = array())
141 141
 	{
142 142
 		global $globalDBdriver, $globalLiveInterval;
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
 	}
171 171
 
172 172
 	/**
173
-	* Gets Minimal Live Spotter data since xx seconds
174
-	*
175
-	* @return Array the spotter information
176
-	*
177
-	*/
173
+	 * Gets Minimal Live Spotter data since xx seconds
174
+	 *
175
+	 * @return Array the spotter information
176
+	 *
177
+	 */
178 178
 	public function getMinLastLiveTrackerData($filter = array())
179 179
 	{
180 180
 		global $globalDBdriver, $globalLiveInterval;
@@ -187,13 +187,13 @@  discard block
 block discarded – undo
187 187
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
188 188
 			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
189 189
 			ORDER BY tracker_live.famtrackid, tracker_live.date";
190
-                } else {
190
+				} else {
191 191
 			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
192 192
 			FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
193 193
 			ORDER BY tracker_live.famtrackid, tracker_live.date";
194 194
 		}
195 195
 
196
-    		try {
196
+			try {
197 197
 			$sth = $this->db->prepare($query);
198 198
 			$sth->execute();
199 199
 		} catch(PDOException $e) {
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
 	}
206 206
 
207 207
 	/**
208
-	* Gets number of latest data entry
209
-	*
210
-	* @return String number of entry
211
-	*
212
-	*/
208
+	 * Gets number of latest data entry
209
+	 *
210
+	 * @return String number of entry
211
+	 *
212
+	 */
213 213
 	public function getLiveTrackerCount($filter = array())
214 214
 	{
215 215
 		global $globalDBdriver, $globalLiveInterval;
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
 	}
235 235
 
236 236
 	/**
237
-	* Gets all the spotter information based on the latest data entry and coord
238
-	*
239
-	* @return Array the spotter information
240
-	*
241
-	*/
237
+	 * Gets all the spotter information based on the latest data entry and coord
238
+	 *
239
+	 * @return Array the spotter information
240
+	 *
241
+	 */
242 242
 	public function getLiveTrackerDatabyCoord($coord, $filter = array())
243 243
 	{
244 244
 		global $globalDBdriver, $globalLiveInterval;
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
 	}
263 263
 
264 264
 	/**
265
-	* Gets all the spotter information based on the latest data entry and coord
266
-	*
267
-	* @return Array the spotter information
268
-	*
269
-	*/
265
+	 * Gets all the spotter information based on the latest data entry and coord
266
+	 *
267
+	 * @return Array the spotter information
268
+	 *
269
+	 */
270 270
 	public function getMinLiveTrackerDatabyCoord($coord, $filter = array())
271 271
 	{
272 272
 		global $globalDBdriver, $globalLiveInterval;
@@ -293,11 +293,11 @@  discard block
 block discarded – undo
293 293
 	}
294 294
 
295 295
 	/**
296
-	* Gets all the spotter information based on a user's latitude and longitude
297
-	*
298
-	* @return Array the spotter information
299
-	*
300
-	*/
296
+	 * Gets all the spotter information based on a user's latitude and longitude
297
+	 *
298
+	 * @return Array the spotter information
299
+	 *
300
+	 */
301 301
 	public function getLatestTrackerForLayar($lat, $lng, $radius, $interval)
302 302
 	{
303 303
 		$Tracker = new Tracker($this->db);
@@ -310,142 +310,142 @@  discard block
 block discarded – undo
310 310
 		if ($lng != '')
311 311
 		{
312 312
 			if (!is_numeric($lng))
313
-                        {
314
-                                return false;
315
-                        }
316
-                }
317
-
318
-                if ($radius != '')
319
-                {
320
-                        if (!is_numeric($radius))
321
-                        {
322
-                                return false;
323
-                        }
324
-                }
313
+						{
314
+								return false;
315
+						}
316
+				}
317
+
318
+				if ($radius != '')
319
+				{
320
+						if (!is_numeric($radius))
321
+						{
322
+								return false;
323
+						}
324
+				}
325 325
 		$additional_query = '';
326 326
 		if ($interval != '')
327
-                {
328
-                        if (!is_string($interval))
329
-                        {
330
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
331
-			        return false;
332
-                        } else {
333
-                if ($interval == '1m')
334
-                {
335
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
336
-                } else if ($interval == '15m'){
337
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
338
-                } 
339
-            }
340
-                } else {
341
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';   
342
-        }
343
-
344
-                $query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
327
+				{
328
+						if (!is_string($interval))
329
+						{
330
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
331
+					return false;
332
+						} else {
333
+				if ($interval == '1m')
334
+				{
335
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
336
+				} else if ($interval == '15m'){
337
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
338
+				} 
339
+			}
340
+				} else {
341
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';   
342
+		}
343
+
344
+				$query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
345 345
                    WHERE tracker_live.latitude <> '' 
346 346
                                    AND tracker_live.longitude <> '' 
347 347
                    ".$additional_query."
348 348
                    HAVING distance < :radius  
349 349
                                    ORDER BY distance";
350 350
 
351
-                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
351
+				$spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
352 352
 
353
-                return $spotter_array;
354
-        }
353
+				return $spotter_array;
354
+		}
355 355
 
356 356
     
357
-        /**
358
-	* Gets all the spotter information based on a particular callsign
359
-	*
360
-	* @return Array the spotter information
361
-	*
362
-	*/
357
+		/**
358
+		 * Gets all the spotter information based on a particular callsign
359
+		 *
360
+		 * @return Array the spotter information
361
+		 *
362
+		 */
363 363
 	public function getLastLiveTrackerDataByIdent($ident)
364 364
 	{
365 365
 		$Tracker = new Tracker($this->db);
366 366
 		date_default_timezone_set('UTC');
367 367
 
368 368
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
369
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
369
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
370 370
 
371 371
 		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true);
372 372
 
373 373
 		return $spotter_array;
374 374
 	}
375 375
 
376
-        /**
377
-	* Gets all the spotter information based on a particular callsign
378
-	*
379
-	* @return Array the spotter information
380
-	*
381
-	*/
376
+		/**
377
+		 * Gets all the spotter information based on a particular callsign
378
+		 *
379
+		 * @return Array the spotter information
380
+		 *
381
+		 */
382 382
 	public function getDateLiveTrackerDataByIdent($ident,$date)
383 383
 	{
384 384
 		$Tracker = new Tracker($this->db);
385 385
 		date_default_timezone_set('UTC');
386 386
 
387 387
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
388
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
388
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
389 389
 
390
-                $date = date('c',$date);
390
+				$date = date('c',$date);
391 391
 		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
392 392
 
393 393
 		return $spotter_array;
394 394
 	}
395 395
 
396
-        /**
397
-	* Gets last spotter information based on a particular callsign
398
-	*
399
-	* @return Array the spotter information
400
-	*
401
-	*/
396
+		/**
397
+		 * Gets last spotter information based on a particular callsign
398
+		 *
399
+		 * @return Array the spotter information
400
+		 *
401
+		 */
402 402
 	public function getLastLiveTrackerDataById($id)
403 403
 	{
404 404
 		$Tracker = new Tracker($this->db);
405 405
 		date_default_timezone_set('UTC');
406 406
 
407 407
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
408
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
408
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
409 409
 
410 410
 		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true);
411 411
 
412 412
 		return $spotter_array;
413 413
 	}
414 414
 
415
-        /**
416
-	* Gets last spotter information based on a particular callsign
417
-	*
418
-	* @return Array the spotter information
419
-	*
420
-	*/
415
+		/**
416
+		 * Gets last spotter information based on a particular callsign
417
+		 *
418
+		 * @return Array the spotter information
419
+		 *
420
+		 */
421 421
 	public function getDateLiveTrackerDataById($id,$date)
422 422
 	{
423 423
 		$Tracker = new Tracker($this->db);
424 424
 		date_default_timezone_set('UTC');
425 425
 
426 426
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
427
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
428
-                $date = date('c',$date);
427
+				$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
428
+				$date = date('c',$date);
429 429
 		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
430 430
 
431 431
 		return $spotter_array;
432 432
 	}
433 433
 
434
-        /**
435
-	* Gets altitude information based on a particular callsign
436
-	*
437
-	* @return Array the spotter information
438
-	*
439
-	*/
434
+		/**
435
+		 * Gets altitude information based on a particular callsign
436
+		 *
437
+		 * @return Array the spotter information
438
+		 *
439
+		 */
440 440
 	public function getAltitudeLiveTrackerDataByIdent($ident)
441 441
 	{
442 442
 
443 443
 		date_default_timezone_set('UTC');
444 444
 
445 445
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
446
-                $query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
446
+				$query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
447 447
 
448
-    		try {
448
+			try {
449 449
 			
450 450
 			$sth = $this->db->prepare($query);
451 451
 			$sth->execute(array(':ident' => $ident));
@@ -458,12 +458,12 @@  discard block
 block discarded – undo
458 458
 		return $spotter_array;
459 459
 	}
460 460
 
461
-        /**
462
-	* Gets all the spotter information based on a particular id
463
-	*
464
-	* @return Array the spotter information
465
-	*
466
-	*/
461
+		/**
462
+		 * Gets all the spotter information based on a particular id
463
+		 *
464
+		 * @return Array the spotter information
465
+		 *
466
+		 */
467 467
 	public function getAllLiveTrackerDataById($id,$liveinterval = false)
468 468
 	{
469 469
 		global $globalDBdriver, $globalLiveInterval;
@@ -491,18 +491,18 @@  discard block
 block discarded – undo
491 491
 		return $spotter_array;
492 492
 	}
493 493
 
494
-        /**
495
-	* Gets all the spotter information based on a particular ident
496
-	*
497
-	* @return Array the spotter information
498
-	*
499
-	*/
494
+		/**
495
+		 * Gets all the spotter information based on a particular ident
496
+		 *
497
+		 * @return Array the spotter information
498
+		 *
499
+		 */
500 500
 	public function getAllLiveTrackerDataByIdent($ident)
501 501
 	{
502 502
 		date_default_timezone_set('UTC');
503 503
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
504 504
 		$query  = self::$global_query.' WHERE tracker_live.ident = :ident';
505
-    		try {
505
+			try {
506 506
 			
507 507
 			$sth = $this->db->prepare($query);
508 508
 			$sth->execute(array(':ident' => $ident));
@@ -516,23 +516,23 @@  discard block
 block discarded – undo
516 516
 
517 517
 
518 518
 	/**
519
-	* Deletes all info in the table
520
-	*
521
-	* @return String success or false
522
-	*
523
-	*/
519
+	 * Deletes all info in the table
520
+	 *
521
+	 * @return String success or false
522
+	 *
523
+	 */
524 524
 	public function deleteLiveTrackerData()
525 525
 	{
526 526
 		global $globalDBdriver;
527 527
 		if ($globalDBdriver == 'mysql') {
528 528
 			//$query  = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date";
529 529
 			$query  = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date';
530
-            		//$query  = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)";
530
+					//$query  = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)";
531 531
 		} else {
532 532
 			$query  = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date";
533 533
 		}
534 534
         
535
-    		try {
535
+			try {
536 536
 			
537 537
 			$sth = $this->db->prepare($query);
538 538
 			$sth->execute();
@@ -544,18 +544,18 @@  discard block
 block discarded – undo
544 544
 	}
545 545
 
546 546
 	/**
547
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
548
-	*
549
-	* @return String success or false
550
-	*
551
-	*/
547
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
548
+	 *
549
+	 * @return String success or false
550
+	 *
551
+	 */
552 552
 	public function deleteLiveTrackerDataNotUpdated()
553 553
 	{
554 554
 		global $globalDBdriver, $globalDebug;
555 555
 		if ($globalDBdriver == 'mysql') {
556 556
 			//$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0';
557
-    			$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
558
-    			try {
557
+				$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
558
+				try {
559 559
 				
560 560
 				$sth = $this->db->prepare($query);
561 561
 				$sth->execute();
@@ -563,8 +563,8 @@  discard block
 block discarded – undo
563 563
 				return "error";
564 564
 			}
565 565
 			$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
566
-                        $i = 0;
567
-                        $j =0;
566
+						$i = 0;
567
+						$j =0;
568 568
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
569 569
 			foreach($all as $row)
570 570
 			{
@@ -572,20 +572,20 @@  discard block
 block discarded – undo
572 572
 				$j++;
573 573
 				if ($j == 30) {
574 574
 					if ($globalDebug) echo ".";
575
-				    	try {
575
+						try {
576 576
 						
577 577
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
578 578
 						$sth->execute();
579 579
 					} catch(PDOException $e) {
580 580
 						return "error";
581 581
 					}
582
-                                	$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
583
-                                	$j = 0;
582
+									$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
583
+									$j = 0;
584 584
 				}
585 585
 				$query_delete .= "'".$row['famtrackid']."',";
586 586
 			}
587 587
 			if ($i > 0) {
588
-    				try {
588
+					try {
589 589
 					
590 590
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
591 591
 					$sth->execute();
@@ -596,9 +596,9 @@  discard block
 block discarded – undo
596 596
 			return "success";
597 597
 		} elseif ($globalDBdriver == 'pgsql') {
598 598
 			//$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0";
599
-    			//$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
600
-    			$query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
601
-    			try {
599
+				//$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
600
+				$query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
601
+				try {
602 602
 				
603 603
 				$sth = $this->db->prepare($query);
604 604
 				$sth->execute();
@@ -642,17 +642,17 @@  discard block
 block discarded – undo
642 642
 	}
643 643
 
644 644
 	/**
645
-	* Deletes all info in the table for an ident
646
-	*
647
-	* @return String success or false
648
-	*
649
-	*/
645
+	 * Deletes all info in the table for an ident
646
+	 *
647
+	 * @return String success or false
648
+	 *
649
+	 */
650 650
 	public function deleteLiveTrackerDataByIdent($ident)
651 651
 	{
652 652
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
653 653
 		$query  = 'DELETE FROM tracker_live WHERE ident = :ident';
654 654
         
655
-    		try {
655
+			try {
656 656
 			
657 657
 			$sth = $this->db->prepare($query);
658 658
 			$sth->execute(array(':ident' => $ident));
@@ -664,17 +664,17 @@  discard block
 block discarded – undo
664 664
 	}
665 665
 
666 666
 	/**
667
-	* Deletes all info in the table for an id
668
-	*
669
-	* @return String success or false
670
-	*
671
-	*/
667
+	 * Deletes all info in the table for an id
668
+	 *
669
+	 * @return String success or false
670
+	 *
671
+	 */
672 672
 	public function deleteLiveTrackerDataById($id)
673 673
 	{
674 674
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
675 675
 		$query  = 'DELETE FROM tracker_live WHERE famtrackid = :id';
676 676
         
677
-    		try {
677
+			try {
678 678
 			
679 679
 			$sth = $this->db->prepare($query);
680 680
 			$sth->execute(array(':id' => $id));
@@ -687,11 +687,11 @@  discard block
 block discarded – undo
687 687
 
688 688
 
689 689
 	/**
690
-	* Gets the aircraft ident within the last hour
691
-	*
692
-	* @return String the ident
693
-	*
694
-	*/
690
+	 * Gets the aircraft ident within the last hour
691
+	 *
692
+	 * @return String the ident
693
+	 *
694
+	 */
695 695
 	public function getIdentFromLastHour($ident)
696 696
 	{
697 697
 		global $globalDBdriver, $globalTimezone;
@@ -717,14 +717,14 @@  discard block
 block discarded – undo
717 717
 			$ident_result = $row['ident'];
718 718
 		}
719 719
 		return $ident_result;
720
-        }
720
+		}
721 721
 
722 722
 	/**
723
-	* Check recent aircraft
724
-	*
725
-	* @return String the ident
726
-	*
727
-	*/
723
+	 * Check recent aircraft
724
+	 *
725
+	 * @return String the ident
726
+	 *
727
+	 */
728 728
 	public function checkIdentRecent($ident)
729 729
 	{
730 730
 		global $globalDBdriver, $globalTimezone;
@@ -750,14 +750,14 @@  discard block
 block discarded – undo
750 750
 			$ident_result = $row['famtrackid'];
751 751
 		}
752 752
 		return $ident_result;
753
-        }
753
+		}
754 754
 
755 755
 	/**
756
-	* Check recent aircraft by id
757
-	*
758
-	* @return String the ident
759
-	*
760
-	*/
756
+	 * Check recent aircraft by id
757
+	 *
758
+	 * @return String the ident
759
+	 *
760
+	 */
761 761
 	public function checkIdRecent($id)
762 762
 	{
763 763
 		global $globalDBdriver, $globalTimezone;
@@ -783,19 +783,19 @@  discard block
 block discarded – undo
783 783
 			$ident_result = $row['famtrackid'];
784 784
 		}
785 785
 		return $ident_result;
786
-        }
786
+		}
787 787
 
788 788
 	/**
789
-	* Adds a new spotter data
790
-	*
791
-	* @param String $famtrackid the ID from flightaware
792
-	* @param String $ident the flight ident
793
-	* @param String $aircraft_icao the aircraft type
794
-	* @param String $departure_airport_icao the departure airport
795
-	* @param String $arrival_airport_icao the arrival airport
796
-	* @return String success or false
797
-	*
798
-	*/
789
+	 * Adds a new spotter data
790
+	 *
791
+	 * @param String $famtrackid the ID from flightaware
792
+	 * @param String $ident the flight ident
793
+	 * @param String $aircraft_icao the aircraft type
794
+	 * @param String $departure_airport_icao the departure airport
795
+	 * @param String $arrival_airport_icao the arrival airport
796
+	 * @return String success or false
797
+	 *
798
+	 */
799 799
 	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
800 800
 	{
801 801
 		global $globalURL, $globalArchive, $globalDebug;
@@ -868,8 +868,8 @@  discard block
 block discarded – undo
868 868
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
869 869
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
870 870
 
871
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
872
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
871
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
872
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
873 873
             	
874 874
 		$query = '';
875 875
 		if ($globalArchive) {
@@ -884,18 +884,18 @@  discard block
 block discarded – undo
884 884
 			
885 885
 			$sth = $this->db->prepare($query);
886 886
 			$sth->execute($query_values);
887
-                } catch(PDOException $e) {
888
-                	return "error : ".$e->getMessage();
889
-                }
890
-                /*
887
+				} catch(PDOException $e) {
888
+					return "error : ".$e->getMessage();
889
+				}
890
+				/*
891 891
                 echo 'putinarchive : '.$putinarchive."\n";
892 892
                 echo 'noarchive : '.$noarchive."\n";
893 893
                 */
894 894
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
895
-		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
896
-		    $TrackerArchive = new TrackerArchive($this->db);
897
-		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
898
-		    if ($globalDebug) echo $result.')';
895
+			if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
896
+			$TrackerArchive = new TrackerArchive($this->db);
897
+			$result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
898
+			if ($globalDebug) echo $result.')';
899 899
 		}
900 900
 
901 901
 		return "success";
Please login to merge, or discard this patch.
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
 	* @param Array $filter the filter
17 17
 	* @return Array the SQL part
18 18
 	*/
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
37 37
 				if (isset($flt['source'])) {
38
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
38
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
39 39
 				} else {
40
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
40
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
41 41
 				}
42 42
 			}
43 43
 		}
44 44
 		if (isset($filter['source']) && !empty($filter['source'])) {
45
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
45
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
46 46
 		}
47 47
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
48 48
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
 					$filter_query_date .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
72 72
 				}
73 73
 			}
74
-			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid";
74
+			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid";
75 75
 		}
76 76
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
77
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
78 78
 		}
79 79
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80 80
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81 81
 		if ($filter_query_where != '') {
82
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
82
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
83 83
 		}
84 84
 		$filter_query = $filter_query_join.$filter_query_where;
85 85
 		return $filter_query;
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 		if ($limit != '')
103 103
 		{
104 104
 			$limit_array = explode(',', $limit);
105
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
106
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
105
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
106
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
107 107
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
108 108
 			{
109 109
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 		} else {
127 127
 			$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query.$orderby_query;
128 128
 		}
129
-		$spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true);
129
+		$spotter_array = $Tracker->getDataFromDB($query.$limit_query, array(), '', true);
130 130
 
131 131
 		return $spotter_array;
132 132
 	}
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		global $globalDBdriver, $globalLiveInterval;
143 143
 		date_default_timezone_set('UTC');
144 144
 
145
-		$filter_query = $this->getFilter($filter,true,true);
145
+		$filter_query = $this->getFilter($filter, true, true);
146 146
 
147 147
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
148 148
 		if ($globalDBdriver == 'mysql') {
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		try {
161 161
 			$sth = $this->db->prepare($query);
162 162
 			$sth->execute();
163
-		} catch(PDOException $e) {
163
+		} catch (PDOException $e) {
164 164
 			echo $e->getMessage();
165 165
 			die;
166 166
 		}
@@ -180,15 +180,15 @@  discard block
 block discarded – undo
180 180
 		global $globalDBdriver, $globalLiveInterval;
181 181
 		date_default_timezone_set('UTC');
182 182
 
183
-		$filter_query = $this->getFilter($filter,true,true);
183
+		$filter_query = $this->getFilter($filter, true, true);
184 184
 
185 185
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
186 186
 		if ($globalDBdriver == 'mysql') {
187
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
187
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
188 188
 			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
189 189
 			ORDER BY tracker_live.famtrackid, tracker_live.date";
190 190
                 } else {
191
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
191
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
192 192
 			FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
193 193
 			ORDER BY tracker_live.famtrackid, tracker_live.date";
194 194
 		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
     		try {
197 197
 			$sth = $this->db->prepare($query);
198 198
 			$sth->execute();
199
-		} catch(PDOException $e) {
199
+		} catch (PDOException $e) {
200 200
 			echo $e->getMessage();
201 201
 			die;
202 202
 		}
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	public function getLiveTrackerCount($filter = array())
214 214
 	{
215 215
 		global $globalDBdriver, $globalLiveInterval;
216
-		$filter_query = $this->getFilter($filter,true,true);
216
+		$filter_query = $this->getFilter($filter, true, true);
217 217
 
218 218
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
219 219
 		if ($globalDBdriver == 'mysql') {
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		try {
225 225
 			$sth = $this->db->prepare($query);
226 226
 			$sth->execute();
227
-		} catch(PDOException $e) {
227
+		} catch (PDOException $e) {
228 228
 			echo $e->getMessage();
229 229
 			die;
230 230
 		}
@@ -247,10 +247,10 @@  discard block
 block discarded – undo
247 247
 		$filter_query = $this->getFilter($filter);
248 248
 
249 249
 		if (is_array($coord)) {
250
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
251
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
252
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
253
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
250
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
251
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
252
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
253
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
254 254
 		} else return array();
255 255
 		if ($globalDBdriver == 'mysql') {
256 256
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
@@ -275,17 +275,17 @@  discard block
 block discarded – undo
275 275
 		$filter_query = $this->getFilter($filter);
276 276
 
277 277
 		if (is_array($coord)) {
278
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
279
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
280
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
281
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
278
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
279
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
280
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
281
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
282 282
 		} else return array();
283 283
 		if ($globalDBdriver == 'mysql') {
284 284
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
285 285
 			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
286 286
 			ORDER BY tracker_live.famtrackid, tracker_live.date";
287 287
 		} else {
288
-			$query  = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
288
+			$query = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
289 289
 			FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date l.latitude BETWEEN ".$minlat." AND ".$maxlat." AND l.longitude BETWEEN ".$minlong." AND ".$maxlong." GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query." tracker_live.latitude <> '0' AND tracker_live.longitude <> '0'";
290 290
 		}
291 291
 		$spotter_array = $Spotter->getDataFromDB($query);
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
                 if ($interval == '1m')
334 334
                 {
335 335
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
336
-                } else if ($interval == '15m'){
336
+                } else if ($interval == '15m') {
337 337
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
338 338
                 } 
339 339
             }
@@ -341,14 +341,14 @@  discard block
 block discarded – undo
341 341
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';   
342 342
         }
343 343
 
344
-                $query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
344
+                $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
345 345
                    WHERE tracker_live.latitude <> '' 
346 346
                                    AND tracker_live.longitude <> '' 
347 347
                    ".$additional_query."
348 348
                    HAVING distance < :radius  
349 349
                                    ORDER BY distance";
350 350
 
351
-                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
351
+                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
352 352
 
353 353
                 return $spotter_array;
354 354
         }
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
 		date_default_timezone_set('UTC');
367 367
 
368 368
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
369
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
369
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
370 370
 
371
-		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true);
371
+		$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident), '', true);
372 372
 
373 373
 		return $spotter_array;
374 374
 	}
@@ -379,16 +379,16 @@  discard block
 block discarded – undo
379 379
 	* @return Array the spotter information
380 380
 	*
381 381
 	*/
382
-	public function getDateLiveTrackerDataByIdent($ident,$date)
382
+	public function getDateLiveTrackerDataByIdent($ident, $date)
383 383
 	{
384 384
 		$Tracker = new Tracker($this->db);
385 385
 		date_default_timezone_set('UTC');
386 386
 
387 387
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
388
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
388
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
389 389
 
390
-                $date = date('c',$date);
391
-		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
390
+                $date = date('c', $date);
391
+		$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
392 392
 
393 393
 		return $spotter_array;
394 394
 	}
@@ -405,9 +405,9 @@  discard block
 block discarded – undo
405 405
 		date_default_timezone_set('UTC');
406 406
 
407 407
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
408
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
408
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
409 409
 
410
-		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true);
410
+		$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id), '', true);
411 411
 
412 412
 		return $spotter_array;
413 413
 	}
@@ -418,15 +418,15 @@  discard block
 block discarded – undo
418 418
 	* @return Array the spotter information
419 419
 	*
420 420
 	*/
421
-	public function getDateLiveTrackerDataById($id,$date)
421
+	public function getDateLiveTrackerDataById($id, $date)
422 422
 	{
423 423
 		$Tracker = new Tracker($this->db);
424 424
 		date_default_timezone_set('UTC');
425 425
 
426 426
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
427
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
428
-                $date = date('c',$date);
429
-		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
427
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
428
+                $date = date('c', $date);
429
+		$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
430 430
 
431 431
 		return $spotter_array;
432 432
 	}
@@ -443,13 +443,13 @@  discard block
 block discarded – undo
443 443
 		date_default_timezone_set('UTC');
444 444
 
445 445
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
446
-                $query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
446
+                $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
447 447
 
448 448
     		try {
449 449
 			
450 450
 			$sth = $this->db->prepare($query);
451 451
 			$sth->execute(array(':ident' => $ident));
452
-		} catch(PDOException $e) {
452
+		} catch (PDOException $e) {
453 453
 			echo $e->getMessage();
454 454
 			die;
455 455
 		}
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 	* @return Array the spotter information
465 465
 	*
466 466
 	*/
467
-	public function getAllLiveTrackerDataById($id,$liveinterval = false)
467
+	public function getAllLiveTrackerDataById($id, $liveinterval = false)
468 468
 	{
469 469
 		global $globalDBdriver, $globalLiveInterval;
470 470
 		date_default_timezone_set('UTC');
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 		try {
484 484
 			$sth = $this->db->prepare($query);
485 485
 			$sth->execute(array(':id' => $id));
486
-		} catch(PDOException $e) {
486
+		} catch (PDOException $e) {
487 487
 			echo $e->getMessage();
488 488
 			die;
489 489
 		}
@@ -501,12 +501,12 @@  discard block
 block discarded – undo
501 501
 	{
502 502
 		date_default_timezone_set('UTC');
503 503
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
504
-		$query  = self::$global_query.' WHERE tracker_live.ident = :ident';
504
+		$query = self::$global_query.' WHERE tracker_live.ident = :ident';
505 505
     		try {
506 506
 			
507 507
 			$sth = $this->db->prepare($query);
508 508
 			$sth->execute(array(':ident' => $ident));
509
-		} catch(PDOException $e) {
509
+		} catch (PDOException $e) {
510 510
 			echo $e->getMessage();
511 511
 			die;
512 512
 		}
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 			
537 537
 			$sth = $this->db->prepare($query);
538 538
 			$sth->execute();
539
-		} catch(PDOException $e) {
539
+		} catch (PDOException $e) {
540 540
 			return "error";
541 541
 		}
542 542
 
@@ -559,14 +559,14 @@  discard block
 block discarded – undo
559 559
 				
560 560
 				$sth = $this->db->prepare($query);
561 561
 				$sth->execute();
562
-			} catch(PDOException $e) {
562
+			} catch (PDOException $e) {
563 563
 				return "error";
564 564
 			}
565 565
 			$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
566 566
                         $i = 0;
567
-                        $j =0;
567
+                        $j = 0;
568 568
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
569
-			foreach($all as $row)
569
+			foreach ($all as $row)
570 570
 			{
571 571
 				$i++;
572 572
 				$j++;
@@ -574,9 +574,9 @@  discard block
 block discarded – undo
574 574
 					if ($globalDebug) echo ".";
575 575
 				    	try {
576 576
 						
577
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
577
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
578 578
 						$sth->execute();
579
-					} catch(PDOException $e) {
579
+					} catch (PDOException $e) {
580 580
 						return "error";
581 581
 					}
582 582
                                 	$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
@@ -587,9 +587,9 @@  discard block
 block discarded – undo
587 587
 			if ($i > 0) {
588 588
     				try {
589 589
 					
590
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
590
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
591 591
 					$sth->execute();
592
-				} catch(PDOException $e) {
592
+				} catch (PDOException $e) {
593 593
 					return "error";
594 594
 				}
595 595
 			}
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 				
603 603
 				$sth = $this->db->prepare($query);
604 604
 				$sth->execute();
605
-			} catch(PDOException $e) {
605
+			} catch (PDOException $e) {
606 606
 				return "error";
607 607
 			}
608 608
 /*			$query_delete = "DELETE FROM tracker_live WHERE famtrackid IN (";
@@ -650,13 +650,13 @@  discard block
 block discarded – undo
650 650
 	public function deleteLiveTrackerDataByIdent($ident)
651 651
 	{
652 652
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
653
-		$query  = 'DELETE FROM tracker_live WHERE ident = :ident';
653
+		$query = 'DELETE FROM tracker_live WHERE ident = :ident';
654 654
         
655 655
     		try {
656 656
 			
657 657
 			$sth = $this->db->prepare($query);
658 658
 			$sth->execute(array(':ident' => $ident));
659
-		} catch(PDOException $e) {
659
+		} catch (PDOException $e) {
660 660
 			return "error";
661 661
 		}
662 662
 
@@ -672,13 +672,13 @@  discard block
 block discarded – undo
672 672
 	public function deleteLiveTrackerDataById($id)
673 673
 	{
674 674
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
675
-		$query  = 'DELETE FROM tracker_live WHERE famtrackid = :id';
675
+		$query = 'DELETE FROM tracker_live WHERE famtrackid = :id';
676 676
         
677 677
     		try {
678 678
 			
679 679
 			$sth = $this->db->prepare($query);
680 680
 			$sth->execute(array(':id' => $id));
681
-		} catch(PDOException $e) {
681
+		} catch (PDOException $e) {
682 682
 			return "error";
683 683
 		}
684 684
 
@@ -696,13 +696,13 @@  discard block
 block discarded – undo
696 696
 	{
697 697
 		global $globalDBdriver, $globalTimezone;
698 698
 		if ($globalDBdriver == 'mysql') {
699
-			$query  = 'SELECT tracker_live.ident FROM tracker_live 
699
+			$query = 'SELECT tracker_live.ident FROM tracker_live 
700 700
 				WHERE tracker_live.ident = :ident 
701 701
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
702 702
 				AND tracker_live.date < UTC_TIMESTAMP()';
703 703
 			$query_data = array(':ident' => $ident);
704 704
 		} else {
705
-			$query  = "SELECT tracker_live.ident FROM tracker_live 
705
+			$query = "SELECT tracker_live.ident FROM tracker_live 
706 706
 				WHERE tracker_live.ident = :ident 
707 707
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
708 708
 				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -711,8 +711,8 @@  discard block
 block discarded – undo
711 711
 		
712 712
 		$sth = $this->db->prepare($query);
713 713
 		$sth->execute($query_data);
714
-		$ident_result='';
715
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
714
+		$ident_result = '';
715
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
716 716
 		{
717 717
 			$ident_result = $row['ident'];
718 718
 		}
@@ -729,13 +729,13 @@  discard block
 block discarded – undo
729 729
 	{
730 730
 		global $globalDBdriver, $globalTimezone;
731 731
 		if ($globalDBdriver == 'mysql') {
732
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
732
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
733 733
 				WHERE tracker_live.ident = :ident 
734 734
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
735 735
 //				AND tracker_live.date < UTC_TIMESTAMP()";
736 736
 			$query_data = array(':ident' => $ident);
737 737
 		} else {
738
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
738
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
739 739
 				WHERE tracker_live.ident = :ident 
740 740
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
741 741
 //				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -744,8 +744,8 @@  discard block
 block discarded – undo
744 744
 		
745 745
 		$sth = $this->db->prepare($query);
746 746
 		$sth->execute($query_data);
747
-		$ident_result='';
748
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
747
+		$ident_result = '';
748
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
749 749
 		{
750 750
 			$ident_result = $row['famtrackid'];
751 751
 		}
@@ -762,13 +762,13 @@  discard block
 block discarded – undo
762 762
 	{
763 763
 		global $globalDBdriver, $globalTimezone;
764 764
 		if ($globalDBdriver == 'mysql') {
765
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
765
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
766 766
 				WHERE tracker_live.famtrackid = :id 
767 767
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
768 768
 //				AND tracker_live.date < UTC_TIMESTAMP()";
769 769
 			$query_data = array(':id' => $id);
770 770
 		} else {
771
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
771
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
772 772
 				WHERE tracker_live.famtrackid = :id 
773 773
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
774 774
 //				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -777,8 +777,8 @@  discard block
 block discarded – undo
777 777
 		
778 778
 		$sth = $this->db->prepare($query);
779 779
 		$sth->execute($query_data);
780
-		$ident_result='';
781
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
780
+		$ident_result = '';
781
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
782 782
 		{
783 783
 			$ident_result = $row['famtrackid'];
784 784
 		}
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 	* @return String success or false
797 797
 	*
798 798
 	*/
799
-	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
799
+	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '')
800 800
 	{
801 801
 		global $globalURL, $globalArchive, $globalDebug;
802 802
 		$Common = new Common();
@@ -855,21 +855,21 @@  discard block
 block discarded – undo
855 855
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
856 856
 
857 857
         
858
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
859
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
860
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
861
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
862
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
863
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
864
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
865
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
866
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
867
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
868
-		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
869
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
870
-
871
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
872
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
858
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
859
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
860
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
861
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
862
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
863
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
864
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
865
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
866
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
867
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
868
+		$comment = filter_var($comment, FILTER_SANITIZE_STRING);
869
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
870
+
871
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
872
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
873 873
             	
874 874
 		$query = '';
875 875
 		if ($globalArchive) {
@@ -879,12 +879,12 @@  discard block
 block discarded – undo
879 879
 		$query  .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
880 880
 		VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
881 881
 
882
-		$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type);
882
+		$query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type);
883 883
 		try {
884 884
 			
885 885
 			$sth = $this->db->prepare($query);
886 886
 			$sth->execute($query_values);
887
-                } catch(PDOException $e) {
887
+                } catch (PDOException $e) {
888 888
                 	return "error : ".$e->getMessage();
889 889
                 }
890 890
                 /*
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
895 895
 		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
896 896
 		    $TrackerArchive = new TrackerArchive($this->db);
897
-		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
897
+		    $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident, $latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type, $noarchive, $format_source, $source_name, $over_country);
898 898
 		    if ($globalDebug) echo $result.')';
899 899
 		}
900 900
 
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
 
905 905
 	public function getOrderBy()
906 906
 	{
907
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC"));
907
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC"));
908 908
 		return $orderby;
909 909
 	}
910 910
 
Please login to merge, or discard this patch.
Braces   +74 added lines, -25 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -76,8 +78,11 @@  discard block
 block discarded – undo
76 78
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77 79
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
78 80
 		}
79
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81
+		if ($filter_query_where == '' && $where) {
82
+			$filter_query_where = ' WHERE';
83
+		} elseif ($filter_query_where != '' && $and) {
84
+			$filter_query_where .= ' AND';
85
+		}
81 86
 		if ($filter_query_where != '') {
82 87
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
83 88
 		}
@@ -119,7 +124,9 @@  discard block
 block discarded – undo
119 124
 			}
120 125
 		}
121 126
 
122
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
127
+		if (!isset($globalLiveInterval)) {
128
+			$globalLiveInterval = '200';
129
+		}
123 130
 		if ($globalDBdriver == 'mysql') {
124 131
 			//$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate";
125 132
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -144,7 +151,9 @@  discard block
 block discarded – undo
144 151
 
145 152
 		$filter_query = $this->getFilter($filter,true,true);
146 153
 
147
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
154
+		if (!isset($globalLiveInterval)) {
155
+			$globalLiveInterval = '200';
156
+		}
148 157
 		if ($globalDBdriver == 'mysql') {
149 158
 			$query  = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
150 159
 			FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0";
@@ -182,7 +191,9 @@  discard block
 block discarded – undo
182 191
 
183 192
 		$filter_query = $this->getFilter($filter,true,true);
184 193
 
185
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194
+		if (!isset($globalLiveInterval)) {
195
+			$globalLiveInterval = '200';
196
+		}
186 197
 		if ($globalDBdriver == 'mysql') {
187 198
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
188 199
 			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
@@ -215,7 +226,9 @@  discard block
 block discarded – undo
215 226
 		global $globalDBdriver, $globalLiveInterval;
216 227
 		$filter_query = $this->getFilter($filter,true,true);
217 228
 
218
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
229
+		if (!isset($globalLiveInterval)) {
230
+			$globalLiveInterval = '200';
231
+		}
219 232
 		if ($globalDBdriver == 'mysql') {
220 233
 			$query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
221 234
 		} else {
@@ -243,7 +256,9 @@  discard block
 block discarded – undo
243 256
 	{
244 257
 		global $globalDBdriver, $globalLiveInterval;
245 258
 		$Spotter = new Spotter($this->db);
246
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
259
+		if (!isset($globalLiveInterval)) {
260
+			$globalLiveInterval = '200';
261
+		}
247 262
 		$filter_query = $this->getFilter($filter);
248 263
 
249 264
 		if (is_array($coord)) {
@@ -251,7 +266,9 @@  discard block
 block discarded – undo
251 266
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
252 267
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
253 268
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
254
-		} else return array();
269
+		} else {
270
+			return array();
271
+		}
255 272
 		if ($globalDBdriver == 'mysql') {
256 273
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
257 274
 		} else {
@@ -271,7 +288,9 @@  discard block
 block discarded – undo
271 288
 	{
272 289
 		global $globalDBdriver, $globalLiveInterval;
273 290
 		$Spotter = new Spotter($this->db);
274
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
291
+		if (!isset($globalLiveInterval)) {
292
+			$globalLiveInterval = '200';
293
+		}
275 294
 		$filter_query = $this->getFilter($filter);
276 295
 
277 296
 		if (is_array($coord)) {
@@ -279,7 +298,9 @@  discard block
 block discarded – undo
279 298
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
280 299
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
281 300
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
282
-		} else return array();
301
+		} else {
302
+			return array();
303
+		}
283 304
 		if ($globalDBdriver == 'mysql') {
284 305
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
285 306
 			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
@@ -472,11 +493,15 @@  discard block
 block discarded – undo
472 493
 		//$query  = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date';
473 494
 		if ($globalDBdriver == 'mysql') {
474 495
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
475
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
496
+			if ($liveinterval) {
497
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
498
+			}
476 499
 			$query .= ' ORDER BY date';
477 500
 		} else {
478 501
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
479
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
502
+			if ($liveinterval) {
503
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
504
+			}
480 505
 			$query .= ' ORDER BY date';
481 506
 		}
482 507
 
@@ -571,7 +596,9 @@  discard block
 block discarded – undo
571 596
 				$i++;
572 597
 				$j++;
573 598
 				if ($j == 30) {
574
-					if ($globalDebug) echo ".";
599
+					if ($globalDebug) {
600
+						echo ".";
601
+					}
575 602
 				    	try {
576 603
 						
577 604
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -818,7 +845,9 @@  discard block
 block discarded – undo
818 845
 			{
819 846
 				return false;
820 847
 			}
821
-		} else return '';
848
+		} else {
849
+			return '';
850
+		}
822 851
 
823 852
 		if ($longitude != '')
824 853
 		{
@@ -826,7 +855,9 @@  discard block
 block discarded – undo
826 855
 			{
827 856
 				return false;
828 857
 			}
829
-		} else return '';
858
+		} else {
859
+			return '';
860
+		}
830 861
 
831 862
 		if ($altitude != '')
832 863
 		{
@@ -834,7 +865,9 @@  discard block
 block discarded – undo
834 865
 			{
835 866
 				return false;
836 867
 			}
837
-		} else $altitude = 0;
868
+		} else {
869
+			$altitude = 0;
870
+		}
838 871
 
839 872
 		if ($heading != '')
840 873
 		{
@@ -842,7 +875,9 @@  discard block
 block discarded – undo
842 875
 			{
843 876
 				return false;
844 877
 			}
845
-		} else $heading = 0;
878
+		} else {
879
+			$heading = 0;
880
+		}
846 881
 
847 882
 		if ($groundspeed != '')
848 883
 		{
@@ -850,9 +885,13 @@  discard block
 block discarded – undo
850 885
 			{
851 886
 				return false;
852 887
 			}
853
-		} else $groundspeed = 0;
888
+		} else {
889
+			$groundspeed = 0;
890
+		}
854 891
 		date_default_timezone_set('UTC');
855
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
892
+		if ($date == '') {
893
+			$date = date("Y-m-d H:i:s", time());
894
+		}
856 895
 
857 896
         
858 897
 		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
@@ -868,12 +907,18 @@  discard block
 block discarded – undo
868 907
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
869 908
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
870 909
 
871
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
872
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
910
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
911
+            		$groundspeed = 0;
912
+            	}
913
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
914
+            		$heading = 0;
915
+            	}
873 916
             	
874 917
 		$query = '';
875 918
 		if ($globalArchive) {
876
-			if ($globalDebug) echo '-- Delete previous data -- ';
919
+			if ($globalDebug) {
920
+				echo '-- Delete previous data -- ';
921
+			}
877 922
 			$query .= 'DELETE FROM tracker_live WHERE famtrackid = :famtrackid;';
878 923
 		}
879 924
 		$query  .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
@@ -892,10 +937,14 @@  discard block
 block discarded – undo
892 937
                 echo 'noarchive : '.$noarchive."\n";
893 938
                 */
894 939
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
895
-		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
940
+		    if ($globalDebug) {
941
+		    	echo '(Add to Tracker archive '.$famtrackid.' : ';
942
+		    }
896 943
 		    $TrackerArchive = new TrackerArchive($this->db);
897 944
 		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
898
-		    if ($globalDebug) echo $result.')';
945
+		    if ($globalDebug) {
946
+		    	echo $result.')';
947
+		    }
899 948
 		}
900 949
 
901 950
 		return "success";
Please login to merge, or discard this patch.
tracker-data.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
 
12 12
 $from_archive = false;
13 13
 if (isset($_GET['ident'])) {
14
-	$ident = urldecode(filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING));
14
+	$ident = urldecode(filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING));
15 15
 	if (isset($_GET['currenttime'])) {
16
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
16
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
17 17
 		$currenttime = round($currenttime/1000);
18
-		$spotter_array = $TrackerLive->getDateLiveTrackerDataByIdent($ident,$currenttime);
18
+		$spotter_array = $TrackerLive->getDateLiveTrackerDataByIdent($ident, $currenttime);
19 19
 		if (empty($spotter_array)) {
20 20
 			$from_archive = true;
21
-			$spotter_array = $TrackerArchive->getDateArchiveTrackerDataByIdent($ident,$currenttime);
21
+			$spotter_array = $TrackerArchive->getDateArchiveTrackerDataByIdent($ident, $currenttime);
22 22
 		}
23 23
 		
24 24
 	} else {
@@ -30,16 +30,16 @@  discard block
 block discarded – undo
30 30
 	}
31 31
 }
32 32
 if (isset($_GET['famtrackid'])) {
33
-	$famtrackid = urldecode(filter_input(INPUT_GET,'famtrackid',FILTER_SANITIZE_STRING));
33
+	$famtrackid = urldecode(filter_input(INPUT_GET, 'famtrackid', FILTER_SANITIZE_STRING));
34 34
 	if (isset($_GET['currenttime'])) {
35
-		$currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
35
+		$currenttime = filter_input(INPUT_GET, 'currenttime', FILTER_SANITIZE_NUMBER_INT);
36 36
 		$currenttime = round($currenttime/1000);
37
-		$spotter_array = $TrackerLive->getDateLiveTrackerDataById($famtrackid,$currenttime);
37
+		$spotter_array = $TrackerLive->getDateLiveTrackerDataById($famtrackid, $currenttime);
38 38
 		
39 39
 		if (empty($spotter_array)) {
40 40
 			$from_archive = true;
41 41
 //			$spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id);
42
-			$spotter_array = $TrackerArchive->getDateArchiveTrackerDataById($flightaware_id,$currenttime);
42
+			$spotter_array = $TrackerArchive->getDateArchiveTrackerDataById($flightaware_id, $currenttime);
43 43
 		}
44 44
 		
45 45
 	} else {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "")
60 60
 {
61 61
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
62
-		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
62
+		$image = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
63 63
 	} else $image = $spotter_item['image_thumbnail'];
64 64
 
65 65
 }
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 print '<div><span>'._("Altitude").'</span>';
80 80
 if (isset($globalGroundAltitude) && $globalGroundAltitude) {
81 81
     try {
82
-	$groundAltitude = $Elevation->getElevation($spotter_item['latitude'],$spotter_item['longitude']);
83
-    } catch(Exception $e) {
82
+	$groundAltitude = $Elevation->getElevation($spotter_item['latitude'], $spotter_item['longitude']);
83
+    } catch (Exception $e) {
84 84
     }
85 85
 }
86 86
 if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
Please login to merge, or discard this patch.