Completed
Push — master ( a425fa...b49250 )
by Yannick
16:03 queued 08:01
created
require/class.MarineImport.php 3 patches
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -9,25 +9,25 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Stats.php');
10 10
 require_once(dirname(__FILE__).'/class.Source.php');
11 11
 if (isset($globalServerAPRS) && $globalServerAPRS) {
12
-    require_once(dirname(__FILE__).'/class.APRS.php');
12
+	require_once(dirname(__FILE__).'/class.APRS.php');
13 13
 }
14 14
 
15 15
 class MarineImport {
16
-    private $all_tracked = array();
17
-    private $last_delete_hourly = 0;
18
-    private $last_delete = 0;
19
-    private $stats = array();
20
-    private $tmd = 0;
21
-    private $source_location = array();
22
-    public $db = null;
23
-    public $nb = 0;
16
+	private $all_tracked = array();
17
+	private $last_delete_hourly = 0;
18
+	private $last_delete = 0;
19
+	private $stats = array();
20
+	private $tmd = 0;
21
+	private $source_location = array();
22
+	public $db = null;
23
+	public $nb = 0;
24 24
 
25
-    public function __construct($dbc = null) {
25
+	public function __construct($dbc = null) {
26 26
 	global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB;
27 27
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
28
-	    $Connection = new Connection($dbc);
29
-	    $this->db = $Connection->db();
30
-	    date_default_timezone_set('UTC');
28
+		$Connection = new Connection($dbc);
29
+		$this->db = $Connection->db();
30
+		date_default_timezone_set('UTC');
31 31
 	}
32 32
 	// Get previous source stats
33 33
 	/*
@@ -46,53 +46,53 @@  discard block
 block discarded – undo
46 46
 	}
47 47
 	*/
48 48
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
49
-	    $APRSMarine = new APRSMarine();
50
-	    //$APRSSpotter->connect();
49
+		$APRSMarine = new APRSMarine();
50
+		//$APRSSpotter->connect();
51
+	}
51 52
 	}
52
-    }
53 53
 
54
-    public function checkAll() {
54
+	public function checkAll() {
55 55
 	global $globalDebug;
56 56
 	if ($globalDebug) echo "Update last seen tracked data...\n";
57 57
 	foreach ($this->all_tracked as $key => $flight) {
58
-	    if (isset($this->all_tracked[$key]['id'])) {
58
+		if (isset($this->all_tracked[$key]['id'])) {
59 59
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
60
-    		$Marine = new Marine($this->db);
61
-        	$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
62
-            }
60
+			$Marine = new Marine($this->db);
61
+			$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
62
+			}
63
+	}
63 64
 	}
64
-    }
65 65
 
66
-    public function del() {
66
+	public function del() {
67 67
 	global $globalDebug;
68 68
 	// Delete old infos
69 69
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
70 70
 	foreach ($this->all_tracked as $key => $flight) {
71
-    	    if (isset($flight['lastupdate'])) {
72
-        	if ($flight['lastupdate'] < (time()-3000)) {
73
-            	    if (isset($this->all_tracked[$key]['id'])) {
74
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
71
+			if (isset($flight['lastupdate'])) {
72
+			if ($flight['lastupdate'] < (time()-3000)) {
73
+					if (isset($this->all_tracked[$key]['id'])) {
74
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
75 75
 			/*
76 76
 			$MarineLive = new MarineLive();
77 77
             		$MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
78 78
 			$MarineLive->db = null;
79 79
 			*/
80
-            		//$real_arrival = $this->arrival($key);
81
-            		$Marine = new Marine($this->db);
82
-            		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
80
+					//$real_arrival = $this->arrival($key);
81
+					$Marine = new Marine($this->db);
82
+					if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
83 83
 				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed']);
84 84
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
85 85
 			}
86 86
 			// Put in archive
87 87
 //			$Marine->db = null;
88
-            	    }
89
-            	    unset($this->all_tracked[$key]);
90
-    	        }
91
-	    }
92
-        }
93
-    }
88
+					}
89
+					unset($this->all_tracked[$key]);
90
+				}
91
+		}
92
+		}
93
+	}
94 94
 
95
-    public function add($line) {
95
+	public function add($line) {
96 96
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB;
97 97
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
98 98
 	date_default_timezone_set('UTC');
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	
102 102
 	// SBS format is CSV format
103 103
 	if(is_array($line) && isset($line['mmsi'])) {
104
-	    //print_r($line);
105
-  	    if (isset($line['mmsi'])) {
104
+		//print_r($line);
105
+  		if (isset($line['mmsi'])) {
106 106
 
107 107
 		/*
108 108
 		// Increment message number
@@ -119,64 +119,64 @@  discard block
 block discarded – undo
119 119
 		
120 120
 		$Common = new Common();
121 121
 		$AIS = new AIS();
122
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
123
-	        else $id = trim($line['id']);
122
+			if (!isset($line['id'])) $id = trim($line['mmsi']);
123
+			else $id = trim($line['id']);
124 124
 		
125 125
 		if (!isset($this->all_tracked[$id])) {
126
-		    $this->all_tracked[$id] = array();
127
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
128
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => ''));
129
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
130
-		    if (!isset($line['id'])) {
126
+			$this->all_tracked[$id] = array();
127
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
128
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => ''));
129
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
130
+			if (!isset($line['id'])) {
131 131
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
132 132
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
133
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
134
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
133
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
134
+			if ($globalAllTracked !== FALSE) $dataFound = true;
135 135
 		}
136 136
 		
137 137
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
138
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
139
-		    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
138
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
139
+			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
140 140
 			$Marine = new Marine($this->db);
141 141
 			$identity = $Marine->getIdentity($line['mmsi']);
142 142
 			if (!empty($identity)) {
143
-			    $this->all_tracked[$id]['ident'] = $identity['ship_name'];
144
-			    $this->all_tracked[$id]['type'] = $identity['type'];
143
+				$this->all_tracked[$id]['ident'] = $identity['ship_name'];
144
+				$this->all_tracked[$id]['type'] = $identity['type'];
145 145
 			}
146 146
 			//print_r($identity);
147 147
 			unset($Marine);
148 148
 			//$dataFound = true;
149
-		    }
149
+			}
150 150
 		}
151 151
 		if (isset($line['type_id']) && $line['type_id'] != '') {
152
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
152
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
153 153
 		}
154 154
 		if (isset($line['type']) && $line['type'] != '') {
155
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
155
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
156 156
 		}
157 157
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
158
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
158
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
159 159
 		}
160 160
 		if (isset($line['imo']) && $line['imo'] != '') {
161
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
161
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
162 162
 		}
163 163
 		if (isset($line['callsign']) && $line['callsign'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
164
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
165 165
 		}
166 166
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
167
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
167
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
168 168
 		}
169 169
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
170
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
170
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
171 171
 		}
172 172
 
173 173
 
174 174
 		//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'])) {
175 175
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
176
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
177
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
176
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
177
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
178 178
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
179
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
179
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
180 180
 				$timeelapsed = microtime(true);
181 181
 				$Marine = new Marine($this->db);
182 182
 				$fromsource = NULL;
@@ -184,31 +184,31 @@  discard block
 block discarded – undo
184 184
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
185 185
 				$Marine->db = null;
186 186
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
187
-			    }
187
+				}
188
+			}
188 189
 			}
189
-		    }
190
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
190
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
191 191
 		}
192 192
 
193 193
 		if (isset($line['speed']) && $line['speed'] != '') {
194
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
195
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
194
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
195
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
196 196
 		} 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'])) {
197
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
198
-		    if ($distance > 1000 && $distance < 10000) {
197
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
198
+			if ($distance > 1000 && $distance < 10000) {
199 199
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
200 200
 			$speed = $speed*3.6;
201 201
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
202 202
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
203
-		    }
203
+			}
204 204
 		}
205 205
 
206
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
207
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
208
-	    	    else unset($timediff);
209
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
206
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
207
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
208
+				else unset($timediff);
209
+				if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
210 210
 			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'])) {
211
-			    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'])) {
211
+				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'])) {
212 212
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
213 213
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
214 214
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -216,84 +216,84 @@  discard block
 block discarded – undo
216 216
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
217 217
 				$timeelapsed = microtime(true);
218 218
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
219
-				    $Marine = new Marine($this->db);
220
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
221
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
222
-				    $Marine->db = null;
223
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
219
+					$Marine = new Marine($this->db);
220
+					$all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
221
+					if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
222
+					$Marine->db = null;
223
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
224 224
 				}
225 225
 				$this->tmd = 0;
226 226
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
227
-			    }
227
+				}
228 228
 			}
229 229
 
230 230
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
231 231
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
232 232
 				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') {
233
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
234
-				    $dataFound = true;
235
-				    $this->all_tracked[$id]['time_last_coord'] = time();
233
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
234
+					$dataFound = true;
235
+					$this->all_tracked[$id]['time_last_coord'] = time();
236 236
 				}
237 237
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
238 238
 			}
239 239
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
240
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
240
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
241 241
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
242 242
 				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') {
243
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
244
-				    $dataFound = true;
245
-				    $this->all_tracked[$id]['time_last_coord'] = time();
243
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
244
+					$dataFound = true;
245
+					$this->all_tracked[$id]['time_last_coord'] = time();
246 246
 				}
247 247
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
248 248
 			}
249 249
 
250
-		    } else if ($globalDebug && $timediff > 20) {
250
+			} else if ($globalDebug && $timediff > 20) {
251 251
 			$this->tmd = $this->tmd + 1;
252 252
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
253 253
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
254 254
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
255 255
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
256
-		    }
256
+			}
257 257
 		}
258 258
 		if (isset($line['last_update']) && $line['last_update'] != '') {
259
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
260
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
259
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
260
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
261 261
 		}
262 262
 		if (isset($line['format_source']) && $line['format_source'] != '') {
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
263
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
264 264
 		}
265 265
 		if (isset($line['source_name']) && $line['source_name'] != '') {
266
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
266
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
267 267
 		}
268 268
 		if (isset($line['status']) && $line['status'] != '') {
269
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
269
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
270 270
 		}
271 271
 
272 272
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
273
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
273
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
274 274
 		}
275 275
 		
276 276
 		if (isset($line['heading']) && $line['heading'] != '') {
277
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
278
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
279
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
280
-		    //$dataFound = true;
277
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
278
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
279
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
280
+			//$dataFound = true;
281 281
   		} 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']) {
282
-  		    $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']);
283
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
284
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
285
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
282
+  			$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']);
283
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
284
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
285
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
286 286
   		}
287 287
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
288 288
 
289 289
 		if (isset($line['datetime'])) {
290
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
290
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
291 291
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
292
-		    } else {
292
+			} else {
293 293
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
294 294
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
295 295
 				return '';
296
-		    }
296
+			}
297 297
 		} else {
298 298
 			date_default_timezone_set('UTC');
299 299
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -301,50 +301,50 @@  discard block
 block discarded – undo
301 301
 
302 302
 
303 303
 		if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) {
304
-		    $this->all_tracked[$id]['lastupdate'] = time();
305
-		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
306
-		        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'])) {
307
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
304
+			$this->all_tracked[$id]['lastupdate'] = time();
305
+			if ($this->all_tracked[$id]['addedMarine'] == 0) {
306
+				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'])) {
307
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
308 308
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
309
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
310
-				    $timeelapsed = microtime(true);
311
-				    $MarineLive = new MarineLive($this->db);
312
-				    if (isset($line['id'])) {
309
+					if ($globalDebug) echo "Check if aircraft is already in DB...";
310
+					$timeelapsed = microtime(true);
311
+					$MarineLive = new MarineLive($this->db);
312
+					if (isset($line['id'])) {
313 313
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
314 314
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
315
-				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
315
+					} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
316 316
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
317 317
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
318
-				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
318
+					} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
319 319
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
320 320
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
321
-				    } else $recent_ident = '';
322
-				    $MarineLive->db=null;
323
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
324
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
321
+					} else $recent_ident = '';
322
+					$MarineLive->db=null;
323
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
324
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
325 325
 				} else $recent_ident = '';
326
-			    } else {
326
+				} else {
327 327
 				$recent_ident = '';
328 328
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
329
-			    }
330
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
331
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
332
-			    {
329
+				}
330
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
331
+				if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
332
+				{
333 333
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
334 334
 				//adds the spotter data for the archive
335
-				    $highlight = '';
336
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
337
-				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
335
+					$highlight = '';
336
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
337
+					if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
338 338
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
339
-					    $timeelapsed = microtime(true);
340
-					    $Marine = new Marine($this->db);
341
-					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
342
-					    $Marine->db = null;
343
-					    if ($globalDebug && isset($result)) echo $result."\n";
344
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
339
+						$timeelapsed = microtime(true);
340
+						$Marine = new Marine($this->db);
341
+						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
342
+						$Marine->db = null;
343
+						if ($globalDebug && isset($result)) echo $result."\n";
344
+						if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
345 345
 					}
346
-				    }
347
-				    /*
346
+					}
347
+					/*
348 348
 				    // Add source stat in DB
349 349
 				    $Stats = new Stats($this->db);
350 350
 				    if (!empty($this->stats)) {
@@ -371,55 +371,55 @@  discard block
 block discarded – undo
371 371
 				    }
372 372
 				    $Stats->db = null;
373 373
 				    */
374
-				    $this->del();
374
+					$this->del();
375 375
 				//$ignoreImport = false;
376 376
 				$this->all_tracked[$id]['addedMarine'] = 1;
377 377
 				//print_r($this->all_tracked[$id]);
378 378
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
379
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
380
-				    //MarineLive->deleteLiveMarineDataNotUpdated();
381
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
379
+					if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
380
+					//MarineLive->deleteLiveMarineDataNotUpdated();
381
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
382 382
 					$MarineLive = new MarineLive($this->db);
383 383
 					$MarineLive->deleteLiveMarineData();
384 384
 					$MarineLive->db=null;
385 385
 					if ($globalDebug) echo " Done\n";
386
-				    }
387
-				    $this->last_delete = time();
386
+					}
387
+					$this->last_delete = time();
388 388
 				}
389
-			    } elseif ($recent_ident != '') {
389
+				} elseif ($recent_ident != '') {
390 390
 				$this->all_tracked[$id]['id'] = $recent_ident;
391 391
 				$this->all_tracked[$id]['addedMarine'] = 1;
392 392
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
393
-				    if (isset($globalDaemon) && !$globalDaemon) {
393
+					if (isset($globalDaemon) && !$globalDaemon) {
394 394
 					$Marine = new Marine($this->db);
395 395
 					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
396 396
 					$Marine->db = null;
397
-				    }
397
+					}
398 398
 				}
399 399
 				
400
-			    }
400
+				}
401 401
 			}
402
-		    }
403
-		    //adds the spotter LIVE data
404
-		    if ($globalDebug) {
402
+			}
403
+			//adds the spotter LIVE data
404
+			if ($globalDebug) {
405 405
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
406
-		    }
407
-		    $ignoreImport = false;
406
+			}
407
+			$ignoreImport = false;
408 408
 
409
-		    if (!$ignoreImport) {
409
+			if (!$ignoreImport) {
410 410
 			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'])) {
411 411
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
412 412
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
413
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
413
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
414 414
 					$timeelapsed = microtime(true);
415 415
 					$MarineLive = new MarineLive($this->db);
416 416
 					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
417 417
 					$MarineLive->db = null;
418 418
 					if ($globalDebug) echo $result."\n";
419
-				    }
419
+					}
420 420
 				}
421 421
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
422
-				    $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
422
+					$APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
423 423
 				}
424 424
 				$this->all_tracked[$id]['putinarchive'] = false;
425 425
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
@@ -485,24 +485,24 @@  discard block
 block discarded – undo
485 485
 			
486 486
 			
487 487
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
488
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
488
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
489 489
 				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
490 490
 				$MarineLive = new MarineLive($this->db);
491 491
 				$MarineLive->deleteLiveMarineDataNotUpdated();
492 492
 				$MarineLive->db = null;
493 493
 				//MarineLive->deleteLiveMarineData();
494 494
 				if ($globalDebug) echo " Done\n";
495
-			    }
496
-			    $this->last_delete_hourly = time();
495
+				}
496
+				$this->last_delete_hourly = time();
497 497
 			}
498 498
 			
499
-		    }
500
-		    //$ignoreImport = false;
499
+			}
500
+			//$ignoreImport = false;
501 501
 		}
502 502
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
503 503
 		if ($send) return $this->all_tracked[$id];
504
-	    }
504
+		}
505
+	}
505 506
 	}
506
-    }
507 507
 }
508 508
 ?>
Please login to merge, or discard this patch.
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	    if (isset($this->all_tracked[$key]['id'])) {
59 59
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
60 60
     		$Marine = new Marine($this->db);
61
-        	$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
61
+        	$Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
62 62
             }
63 63
 	}
64 64
     }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
70 70
 	foreach ($this->all_tracked as $key => $flight) {
71 71
     	    if (isset($flight['lastupdate'])) {
72
-        	if ($flight['lastupdate'] < (time()-3000)) {
72
+        	if ($flight['lastupdate'] < (time() - 3000)) {
73 73
             	    if (isset($this->all_tracked[$key]['id'])) {
74 74
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
75 75
 			/*
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
             		//$real_arrival = $this->arrival($key);
81 81
             		$Marine = new Marine($this->db);
82 82
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
83
-				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed']);
83
+				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed']);
84 84
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
85 85
 			}
86 86
 			// Put in archive
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	$send = false;
101 101
 	
102 102
 	// SBS format is CSV format
103
-	if(is_array($line) && isset($line['mmsi'])) {
103
+	if (is_array($line) && isset($line['mmsi'])) {
104 104
 	    //print_r($line);
105 105
   	    if (isset($line['mmsi'])) {
106 106
 
@@ -124,18 +124,18 @@  discard block
 block discarded – undo
124 124
 		
125 125
 		if (!isset($this->all_tracked[$id])) {
126 126
 		    $this->all_tracked[$id] = array();
127
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
128
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => ''));
129
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
127
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0));
128
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '', 'mmsi_type' => ''));
129
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
130 130
 		    if (!isset($line['id'])) {
131 131
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
132
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
133
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
132
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
133
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
134 134
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
135 135
 		}
136 136
 		
137 137
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
138
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
138
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi']));
139 139
 		    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
140 140
 			$Marine = new Marine($this->db);
141 141
 			$identity = $Marine->getIdentity($line['mmsi']);
@@ -149,66 +149,66 @@  discard block
 block discarded – undo
149 149
 		    }
150 150
 		}
151 151
 		if (isset($line['type_id']) && $line['type_id'] != '') {
152
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
152
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id'])));
153 153
 		}
154 154
 		if (isset($line['type']) && $line['type'] != '') {
155
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
155
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
156 156
 		}
157 157
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
158
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
158
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type']));
159 159
 		}
160 160
 		if (isset($line['imo']) && $line['imo'] != '') {
161
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
161
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo']));
162 162
 		}
163 163
 		if (isset($line['callsign']) && $line['callsign'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
164
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign']));
165 165
 		}
166 166
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
167
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
167
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code']));
168 168
 		}
169 169
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
170
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
170
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date']));
171 171
 		}
172 172
 
173 173
 
174 174
 		//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'])) {
175 175
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
176
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
176
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
177 177
 		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
178 178
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
179 179
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
180 180
 				$timeelapsed = microtime(true);
181 181
 				$Marine = new Marine($this->db);
182 182
 				$fromsource = NULL;
183
-				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
183
+				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
184 184
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
185 185
 				$Marine->db = null;
186
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
186
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
187 187
 			    }
188 188
 			}
189 189
 		    }
190
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
190
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
191 191
 		}
192 192
 
193 193
 		if (isset($line['speed']) && $line['speed'] != '') {
194
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
195
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
194
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
195
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
196 196
 		} 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'])) {
197
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
197
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
198 198
 		    if ($distance > 1000 && $distance < 10000) {
199 199
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
200 200
 			$speed = $speed*3.6;
201
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
201
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
202 202
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
203 203
 		    }
204 204
 		}
205 205
 
206 206
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
207
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
207
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
208 208
 	    	    else unset($timediff);
209
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
209
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) {
210 210
 			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'])) {
211
-			    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'])) {
211
+			    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'])) {
212 212
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
213 213
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
214 214
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
 				$timeelapsed = microtime(true);
218 218
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
219 219
 				    $Marine = new Marine($this->db);
220
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
220
+				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
221 221
 				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
222 222
 				    $Marine->db = null;
223
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
223
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
224 224
 				}
225 225
 				$this->tmd = 0;
226 226
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
@@ -229,66 +229,66 @@  discard block
 block discarded – undo
229 229
 
230 230
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
231 231
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
232
-				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') {
232
+				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') {
233 233
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
234 234
 				    $dataFound = true;
235 235
 				    $this->all_tracked[$id]['time_last_coord'] = time();
236 236
 				}
237
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
237
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
238 238
 			}
239 239
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
240 240
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
241 241
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
242
-				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') {
242
+				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') {
243 243
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
244 244
 				    $dataFound = true;
245 245
 				    $this->all_tracked[$id]['time_last_coord'] = time();
246 246
 				}
247
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
247
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
248 248
 			}
249 249
 
250 250
 		    } else if ($globalDebug && $timediff > 20) {
251 251
 			$this->tmd = $this->tmd + 1;
252 252
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
253
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
254
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
253
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
254
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
255 255
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
256 256
 		    }
257 257
 		}
258 258
 		if (isset($line['last_update']) && $line['last_update'] != '') {
259 259
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
260
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
260
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
261 261
 		}
262 262
 		if (isset($line['format_source']) && $line['format_source'] != '') {
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
263
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
264 264
 		}
265 265
 		if (isset($line['source_name']) && $line['source_name'] != '') {
266
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
266
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
267 267
 		}
268 268
 		if (isset($line['status']) && $line['status'] != '') {
269
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
269
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status']));
270 270
 		}
271 271
 
272 272
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
273
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
273
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
274 274
 		}
275 275
 		
276 276
 		if (isset($line['heading']) && $line['heading'] != '') {
277
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
278
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
279
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
277
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
278
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
279
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
280 280
 		    //$dataFound = true;
281 281
   		} 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']) {
282
-  		    $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']);
283
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
284
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
282
+  		    $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']);
283
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
284
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
285 285
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
286 286
   		}
287 287
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
288 288
 
289 289
 		if (isset($line['datetime'])) {
290 290
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
291
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
291
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
292 292
 		    } else {
293 293
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
294 294
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
@@ -296,14 +296,14 @@  discard block
 block discarded – undo
296 296
 		    }
297 297
 		} else {
298 298
 			date_default_timezone_set('UTC');
299
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
299
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
300 300
 		}
301 301
 
302 302
 
303 303
 		if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) {
304 304
 		    $this->all_tracked[$id]['lastupdate'] = time();
305 305
 		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
306
-		        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'])) {
306
+		        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'])) {
307 307
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
308 308
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
309 309
 				    if ($globalDebug) echo "Check if aircraft is already in DB...";
@@ -311,37 +311,37 @@  discard block
 block discarded – undo
311 311
 				    $MarineLive = new MarineLive($this->db);
312 312
 				    if (isset($line['id'])) {
313 313
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
314
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
314
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
315 315
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
316 316
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
317
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
317
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
318 318
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
319 319
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
320
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
320
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
321 321
 				    } else $recent_ident = '';
322
-				    $MarineLive->db=null;
322
+				    $MarineLive->db = null;
323 323
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
324 324
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
325 325
 				} else $recent_ident = '';
326 326
 			    } else {
327 327
 				$recent_ident = '';
328
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
328
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
329 329
 			    }
330 330
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
331
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
331
+			    if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
332 332
 			    {
333 333
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
334 334
 				//adds the spotter data for the archive
335 335
 				    $highlight = '';
336
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
336
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
337 337
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
338 338
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
339 339
 					    $timeelapsed = microtime(true);
340 340
 					    $Marine = new Marine($this->db);
341
-					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
341
+					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']);
342 342
 					    $Marine->db = null;
343 343
 					    if ($globalDebug && isset($result)) echo $result."\n";
344
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
344
+					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
345 345
 					}
346 346
 				    }
347 347
 				    /*
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
382 382
 					$MarineLive = new MarineLive($this->db);
383 383
 					$MarineLive->deleteLiveMarineData();
384
-					$MarineLive->db=null;
384
+					$MarineLive->db = null;
385 385
 					if ($globalDebug) echo " Done\n";
386 386
 				    }
387 387
 				    $this->last_delete = time();
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
393 393
 				    if (isset($globalDaemon) && !$globalDaemon) {
394 394
 					$Marine = new Marine($this->db);
395
-					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
395
+					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']);
396 396
 					$Marine->db = null;
397 397
 				    }
398 398
 				}
@@ -407,22 +407,22 @@  discard block
 block discarded – undo
407 407
 		    $ignoreImport = false;
408 408
 
409 409
 		    if (!$ignoreImport) {
410
-			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'])) {
410
+			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'])) {
411 411
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
412 412
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
413 413
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
414 414
 					$timeelapsed = microtime(true);
415 415
 					$MarineLive = new MarineLive($this->db);
416
-					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
416
+					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
417 417
 					$MarineLive->db = null;
418 418
 					if ($globalDebug) echo $result."\n";
419 419
 				    }
420 420
 				}
421 421
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
422
-				    $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
422
+				    $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
423 423
 				}
424 424
 				$this->all_tracked[$id]['putinarchive'] = false;
425
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
425
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
426 426
 
427 427
 				// Put statistics in $this->stats variable
428 428
 				/*
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 
481 481
 				$this->all_tracked[$id]['lastupdate'] = time();
482 482
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
483
-			} 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";
483
+			} 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";
484 484
 			//$this->del();
485 485
 			
486 486
 			
Please login to merge, or discard this patch.
Braces   +152 added lines, -52 removed lines patch added patch discarded remove patch
@@ -53,7 +53,9 @@  discard block
 block discarded – undo
53 53
 
54 54
     public function checkAll() {
55 55
 	global $globalDebug;
56
-	if ($globalDebug) echo "Update last seen tracked data...\n";
56
+	if ($globalDebug) {
57
+		echo "Update last seen tracked data...\n";
58
+	}
57 59
 	foreach ($this->all_tracked as $key => $flight) {
58 60
 	    if (isset($this->all_tracked[$key]['id'])) {
59 61
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -66,12 +68,16 @@  discard block
 block discarded – undo
66 68
     public function del() {
67 69
 	global $globalDebug;
68 70
 	// Delete old infos
69
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
71
+	if ($globalDebug) {
72
+		echo 'Delete old values and update latest data...'."\n";
73
+	}
70 74
 	foreach ($this->all_tracked as $key => $flight) {
71 75
     	    if (isset($flight['lastupdate'])) {
72 76
         	if ($flight['lastupdate'] < (time()-3000)) {
73 77
             	    if (isset($this->all_tracked[$key]['id'])) {
74
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
78
+            		if ($globalDebug) {
79
+            			echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
80
+            		}
75 81
 			/*
76 82
 			$MarineLive = new MarineLive();
77 83
             		$MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
@@ -81,7 +87,9 @@  discard block
 block discarded – undo
81 87
             		$Marine = new Marine($this->db);
82 88
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
83 89
 				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed']);
84
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
90
+				if ($globalDebug && $result != 'success') {
91
+					echo '!!! ERROR : '.$result."\n";
92
+				}
85 93
 			}
86 94
 			// Put in archive
87 95
 //			$Marine->db = null;
@@ -94,7 +102,9 @@  discard block
 block discarded – undo
94 102
 
95 103
     public function add($line) {
96 104
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB;
97
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
105
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
106
+		$globalCoordMinChange = '0.02';
107
+	}
98 108
 	date_default_timezone_set('UTC');
99 109
 	$dataFound = false;
100 110
 	$send = false;
@@ -119,8 +129,11 @@  discard block
 block discarded – undo
119 129
 		
120 130
 		$Common = new Common();
121 131
 		$AIS = new AIS();
122
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
123
-	        else $id = trim($line['id']);
132
+	        if (!isset($line['id'])) {
133
+	        	$id = trim($line['mmsi']);
134
+	        } else {
135
+	        	$id = trim($line['id']);
136
+	        }
124 137
 		
125 138
 		if (!isset($this->all_tracked[$id])) {
126 139
 		    $this->all_tracked[$id] = array();
@@ -128,10 +141,16 @@  discard block
 block discarded – undo
128 141
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => ''));
129 142
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
130 143
 		    if (!isset($line['id'])) {
131
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
144
+			if (!isset($globalDaemon)) {
145
+				$globalDaemon = TRUE;
146
+			}
132 147
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
133
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
134
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
148
+		     } else {
149
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
150
+		     }
151
+		    if ($globalAllTracked !== FALSE) {
152
+		    	$dataFound = true;
153
+		    }
135 154
 		}
136 155
 		
137 156
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
@@ -181,13 +200,19 @@  discard block
 block discarded – undo
181 200
 				$Marine = new Marine($this->db);
182 201
 				$fromsource = NULL;
183 202
 				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
184
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
203
+				if ($globalDebug && $result != 'success') {
204
+					echo '!!! ERROR : '.$result."\n";
205
+				}
185 206
 				$Marine->db = null;
186
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
207
+				if ($globalDebugTimeElapsed) {
208
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
209
+				}
187 210
 			    }
188 211
 			}
189 212
 		    }
190
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
213
+		    if (!isset($this->all_tracked[$id]['id'])) {
214
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
215
+		    }
191 216
 		}
192 217
 
193 218
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -198,14 +223,21 @@  discard block
 block discarded – undo
198 223
 		    if ($distance > 1000 && $distance < 10000) {
199 224
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
200 225
 			$speed = $speed*3.6;
201
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
202
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
226
+			if ($speed < 1000) {
227
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
228
+			}
229
+  			if ($globalDebug) {
230
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
231
+  			}
203 232
 		    }
204 233
 		}
205 234
 
206 235
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
207
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
208
-	    	    else unset($timediff);
236
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
237
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
238
+	    	    } else {
239
+	    	    	unset($timediff);
240
+	    	    }
209 241
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
210 242
 			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'])) {
211 243
 			    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'])) {
@@ -213,22 +245,32 @@  discard block
 block discarded – undo
213 245
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
214 246
 				$this->all_tracked[$id]['putinarchive'] = true;
215 247
 				
216
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
248
+				if ($globalDebug) {
249
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
250
+				}
217 251
 				$timeelapsed = microtime(true);
218 252
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
219 253
 				    $Marine = new Marine($this->db);
220 254
 				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
221
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
255
+				    if (!empty($all_country)) {
256
+				    	$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
257
+				    }
222 258
 				    $Marine->db = null;
223
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
259
+				    if ($globalDebugTimeElapsed) {
260
+				    	echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
261
+				    }
224 262
 				}
225 263
 				$this->tmd = 0;
226
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
264
+				if ($globalDebug) {
265
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
266
+				}
227 267
 			    }
228 268
 			}
229 269
 
230 270
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
231
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
271
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
272
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
273
+				}
232 274
 				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') {
233 275
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
234 276
 				    $dataFound = true;
@@ -237,8 +279,12 @@  discard block
 block discarded – undo
237 279
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
238 280
 			}
239 281
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
240
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
241
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
282
+			    if ($line['longitude'] > 180) {
283
+			    	$line['longitude'] = $line['longitude'] - 360;
284
+			    }
285
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
286
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
287
+				}
242 288
 				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') {
243 289
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
244 290
 				    $dataFound = true;
@@ -256,7 +302,9 @@  discard block
 block discarded – undo
256 302
 		    }
257 303
 		}
258 304
 		if (isset($line['last_update']) && $line['last_update'] != '') {
259
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
305
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
306
+		    	$dataFound = true;
307
+		    }
260 308
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
261 309
 		}
262 310
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -274,15 +322,21 @@  discard block
 block discarded – undo
274 322
 		}
275 323
 		
276 324
 		if (isset($line['heading']) && $line['heading'] != '') {
277
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
325
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
326
+		    	$this->all_tracked[$id]['putinarchive'] = true;
327
+		    }
278 328
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
279 329
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
280 330
 		    //$dataFound = true;
281 331
   		} 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']) {
282 332
   		    $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']);
283 333
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
284
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
285
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
334
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
335
+		    	$this->all_tracked[$id]['putinarchive'] = true;
336
+		    }
337
+  		    if ($globalDebug) {
338
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
339
+  		    }
286 340
   		}
287 341
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
288 342
 
@@ -290,8 +344,11 @@  discard block
 block discarded – undo
290 344
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
291 345
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
292 346
 		    } else {
293
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
294
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
347
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
348
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
349
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
350
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
351
+				}
295 352
 				return '';
296 353
 		    }
297 354
 		} else {
@@ -306,23 +363,38 @@  discard block
 block discarded – undo
306 363
 		        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'])) {
307 364
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
308 365
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
309
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
366
+				    if ($globalDebug) {
367
+				    	echo "Check if aircraft is already in DB...";
368
+				    }
310 369
 				    $timeelapsed = microtime(true);
311 370
 				    $MarineLive = new MarineLive($this->db);
312 371
 				    if (isset($line['id'])) {
313 372
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
314
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
373
+					if ($globalDebugTimeElapsed) {
374
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
375
+					}
315 376
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
316 377
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
317
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
378
+					if ($globalDebugTimeElapsed) {
379
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
380
+					}
318 381
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
319 382
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
320
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
321
-				    } else $recent_ident = '';
383
+					if ($globalDebugTimeElapsed) {
384
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
385
+					}
386
+				    } else {
387
+				    	$recent_ident = '';
388
+				    }
322 389
 				    $MarineLive->db=null;
323
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
324
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
325
-				} else $recent_ident = '';
390
+				    if ($globalDebug && $recent_ident == '') {
391
+				    	echo " Not in DB.\n";
392
+				    } elseif ($globalDebug && $recent_ident != '') {
393
+				    	echo " Already in DB.\n";
394
+				    }
395
+				} else {
396
+					$recent_ident = '';
397
+				}
326 398
 			    } else {
327 399
 				$recent_ident = '';
328 400
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -330,18 +402,26 @@  discard block
 block discarded – undo
330 402
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
331 403
 			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
332 404
 			    {
333
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
405
+				if ($globalDebug) {
406
+					echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
407
+				}
334 408
 				//adds the spotter data for the archive
335 409
 				    $highlight = '';
336
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
410
+				    if (!isset($this->all_tracked[$id]['id'])) {
411
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
412
+				    }
337 413
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
338 414
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
339 415
 					    $timeelapsed = microtime(true);
340 416
 					    $Marine = new Marine($this->db);
341 417
 					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
342 418
 					    $Marine->db = null;
343
-					    if ($globalDebug && isset($result)) echo $result."\n";
344
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
419
+					    if ($globalDebug && isset($result)) {
420
+					    	echo $result."\n";
421
+					    }
422
+					    if ($globalDebugTimeElapsed) {
423
+					    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
424
+					    }
345 425
 					}
346 426
 				    }
347 427
 				    /*
@@ -376,13 +456,17 @@  discard block
 block discarded – undo
376 456
 				$this->all_tracked[$id]['addedMarine'] = 1;
377 457
 				//print_r($this->all_tracked[$id]);
378 458
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
379
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
459
+				    if ($globalDebug) {
460
+				    	echo "---- Deleting Live Marine data older than 9 hours...";
461
+				    }
380 462
 				    //MarineLive->deleteLiveMarineDataNotUpdated();
381 463
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
382 464
 					$MarineLive = new MarineLive($this->db);
383 465
 					$MarineLive->deleteLiveMarineData();
384 466
 					$MarineLive->db=null;
385
-					if ($globalDebug) echo " Done\n";
467
+					if ($globalDebug) {
468
+						echo " Done\n";
469
+					}
386 470
 				    }
387 471
 				    $this->last_delete = time();
388 472
 				}
@@ -408,21 +492,27 @@  discard block
 block discarded – undo
408 492
 
409 493
 		    if (!$ignoreImport) {
410 494
 			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'])) {
411
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
495
+				if ($globalDebug) {
496
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
497
+				}
412 498
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
413 499
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
414 500
 					$timeelapsed = microtime(true);
415 501
 					$MarineLive = new MarineLive($this->db);
416 502
 					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
417 503
 					$MarineLive->db = null;
418
-					if ($globalDebug) echo $result."\n";
504
+					if ($globalDebug) {
505
+						echo $result."\n";
506
+					}
419 507
 				    }
420 508
 				}
421 509
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
422 510
 				    $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
423 511
 				}
424 512
 				$this->all_tracked[$id]['putinarchive'] = false;
425
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
513
+				if ($globalDebugTimeElapsed) {
514
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
515
+				}
426 516
 
427 517
 				// Put statistics in $this->stats variable
428 518
 				/*
@@ -479,19 +569,27 @@  discard block
 block discarded – undo
479 569
 				*/
480 570
 
481 571
 				$this->all_tracked[$id]['lastupdate'] = time();
482
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
483
-			} 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";
572
+				if ($this->all_tracked[$id]['putinarchive']) {
573
+					$send = true;
574
+				}
575
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
576
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
577
+			}
484 578
 			//$this->del();
485 579
 			
486 580
 			
487 581
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
488 582
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
489
-				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
583
+				if ($globalDebug) {
584
+					echo "---- Deleting Live Marine data Not updated since 2 hour...";
585
+				}
490 586
 				$MarineLive = new MarineLive($this->db);
491 587
 				$MarineLive->deleteLiveMarineDataNotUpdated();
492 588
 				$MarineLive->db = null;
493 589
 				//MarineLive->deleteLiveMarineData();
494
-				if ($globalDebug) echo " Done\n";
590
+				if ($globalDebug) {
591
+					echo " Done\n";
592
+				}
495 593
 			    }
496 594
 			    $this->last_delete_hourly = time();
497 595
 			}
@@ -500,7 +598,9 @@  discard block
 block discarded – undo
500 598
 		    //$ignoreImport = false;
501 599
 		}
502 600
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
503
-		if ($send) return $this->all_tracked[$id];
601
+		if ($send) {
602
+			return $this->all_tracked[$id];
603
+		}
504 604
 	    }
505 605
 	}
506 606
     }
Please login to merge, or discard this patch.