Completed
Push — master ( 46434e...ad133e )
by Yannick
32:08 queued 16:03
created
require/class.Accident.php 3 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 	}
37 37
 
38 38
 	/**
39
-	* Get Accidents data from DB
40
-	* @param String $limit Limit
41
-	* @param String $type Set type accident or incident
42
-	* @param String $date get data for a date
43
-	* @return array Return Accidents data in array
44
-	*/
39
+	 * Get Accidents data from DB
40
+	 * @param String $limit Limit
41
+	 * @param String $type Set type accident or incident
42
+	 * @param String $date get data for a date
43
+	 * @return array Return Accidents data in array
44
+	 */
45 45
 	public function getAccidentData($limit = '',$type = '',$date = '') {
46 46
 		global $globalDBdriver;
47 47
 		$Image = new Image($this->db);
@@ -384,11 +384,11 @@  discard block
 block discarded – undo
384 384
 		return $row['nb'];
385 385
 	}
386 386
 
387
-    /**
388
-     * Check if lastest accident update date is older than 1 day
389
-     * @return bool|string
390
-     */
391
-    public static function check_last_accidents_update() {
387
+	/**
388
+	 * Check if lastest accident update date is older than 1 day
389
+	 * @return bool|string
390
+	 */
391
+	public static function check_last_accidents_update() {
392 392
 		global $globalDBdriver;
393 393
 		if ($globalDBdriver == 'mysql') {
394 394
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_accident_db' AND value > DATE_SUB(NOW(), INTERVAL 1 DAY)";
@@ -407,11 +407,11 @@  discard block
 block discarded – undo
407 407
 		else return true;
408 408
 	}
409 409
 
410
-    /**
411
-     * Insert accident update date
412
-     * @return string
413
-     */
414
-    public static function insert_last_accidents_update() {
410
+	/**
411
+	 * Insert accident update date
412
+	 * @return string
413
+	 */
414
+	public static function insert_last_accidents_update() {
415 415
 		$query = "DELETE FROM config WHERE name = 'last_update_accident_db';
416 416
 		    INSERT INTO config (name,value) VALUES ('last_update_accident_db',NOW());";
417 417
 		try {
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -42,20 +42,20 @@  discard block
 block discarded – undo
42 42
 	* @param String $date get data for a date
43 43
 	* @return array Return Accidents data in array
44 44
 	*/
45
-	public function getAccidentData($limit = '',$type = '',$date = '') {
45
+	public function getAccidentData($limit = '', $type = '', $date = '') {
46 46
 		global $globalDBdriver;
47 47
 		$Image = new Image($this->db);
48 48
 		$Spotter = new Spotter($this->db);
49 49
 		$Translation = new Translation($this->db);
50
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
50
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
51 51
 		date_default_timezone_set('UTC');
52 52
 		$result = array();
53 53
 		$limit_query = '';
54 54
 		if ($limit != "")
55 55
 		{
56 56
 			$limit_array = explode(",", $limit);
57
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
58
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
57
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
58
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
59 59
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
60 60
 			{
61 61
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -64,29 +64,29 @@  discard block
 block discarded – undo
64 64
 
65 65
 		if ($type != '') {
66 66
 			if ($date != '') {
67
-				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) {
67
+				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) {
68 68
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
69 69
 					//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
70
-					$query_values = array(':type' => $type,':date' => $date);
71
-				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) {
70
+					$query_values = array(':type' => $type, ':date' => $date);
71
+				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) {
72 72
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date BETWEEN :dated AND :datef GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
73
-					$query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31');
74
-				} elseif (preg_match("/^[0-9]{4}$/",$date)) {
73
+					$query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31');
74
+				} elseif (preg_match("/^[0-9]{4}$/", $date)) {
75 75
 					if ($globalDBdriver == 'mysql') {
76 76
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND YEAR(date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
77 77
 					} else {
78 78
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND EXTRACT(YEAR FROM date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
79 79
 					}
80
-					$query_values = array(':type' => $type,':date' => $date);
80
+					$query_values = array(':type' => $type, ':date' => $date);
81 81
 				} else {
82 82
 					$date = $date.'%';
83 83
 					if ($globalDBdriver == 'mysql') {
84 84
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND DATE_FORMAT(date,'%Y-%m-%d') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
85
-						$query_values = array(':type' => $type,':date' => $date);
85
+						$query_values = array(':type' => $type, ':date' => $date);
86 86
 					} else {
87 87
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
88 88
 						//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
89
-						$query_values = array(':type' => $type,':date' => $date);
89
+						$query_values = array(':type' => $type, ':date' => $date);
90 90
 					}
91 91
 				}
92 92
 			} else {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			}
98 98
 		} else {
99 99
 			if ($date != '') {
100
-				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) {
100
+				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) {
101 101
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
102 102
 					//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
103 103
 				} else {
@@ -116,18 +116,18 @@  discard block
 block discarded – undo
116 116
 		try {
117 117
 			$sth = $this->db->prepare($query);
118 118
 			$sth->execute($query_values);
119
-		} catch(PDOException $e) {
119
+		} catch (PDOException $e) {
120 120
 			echo "error : ".$e->getMessage();
121 121
 			return array();
122 122
 		}
123 123
 		$i = 0;
124 124
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
125
-			if (preg_match('/^[\w\-]+$/',$row['registration'])) {
125
+			if (preg_match('/^[\w\-]+$/', $row['registration'])) {
126 126
 				$data = array();
127 127
 				if ($row['registration'] != '') {
128 128
 					$image_array = $Image->getSpotterImage($row['registration']);
129
-					if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
130
-					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
129
+					if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
130
+					else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
131 131
 					$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
132 132
 					$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
133 133
 					if (!empty($aircraft_info)) {
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 						$data['aircraft_name'] = $aircraft_info[0]['type'];
136 136
 						$data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer'];
137 137
 					} else {
138
-						$data = array_merge($data,array('aircraft_type' => 'NA'));
138
+						$data = array_merge($data, array('aircraft_type' => 'NA'));
139 139
 					}
140 140
 					$owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']);
141 141
 					if (!empty($owner_data)) {
@@ -143,18 +143,18 @@  discard block
 block discarded – undo
143 143
 						$data['aircraft_base'] = $owner_data['base'];
144 144
 						$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
145 145
 					}
146
-				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
146
+				} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
147 147
 				if ($row['registration'] == '') $row['registration'] = 'NA';
148 148
 				if ($row['ident'] == '') $row['ident'] = 'NA';
149
-				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
149
+				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3));
150 150
 				if (isset($identicao[0])) {
151
-					if (substr($row['ident'],0,2) == 'AF') {
152
-						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
153
-						else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
154
-					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
155
-					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
151
+					if (substr($row['ident'], 0, 2) == 'AF') {
152
+						if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
153
+						else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
154
+					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
155
+					$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
156 156
 				} else $icao = $row['ident'];
157
-				$icao = $Translation->checkTranslation($icao,false);
157
+				$icao = $Translation->checkTranslation($icao, false);
158 158
 				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
159 159
 				if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
160 160
 					//echo 'Check airline info... for '.$row['airline_name'].' ';
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
 					if (!empty($airline_info)) {
164 164
 						//echo 'data found !'."\n";
165 165
 						//print_r($airline_info);
166
-						$data = array_merge($data,$airline_info);
166
+						$data = array_merge($data, $airline_info);
167 167
 					} 
168 168
 					//else echo 'No data...'."\n";
169 169
 				}
170
-				$data = array_merge($row,$data);
170
+				$data = array_merge($row, $data);
171 171
 				if ($data['ident'] == null) $data['ident'] = $icao;
172 172
 				if ($data['title'] == null) {
173 173
 					$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
174 174
 				} else $data['message'] = strtolower($data['title']);
175
-				$ids = $Spotter->getAllIDByRegistration($data['registration'],true);
175
+				$ids = $Spotter->getAllIDByRegistration($data['registration'], true);
176 176
 				$date = $data['date'];
177 177
 				if (isset($ids[$date])) {
178 178
 					$data['spotted'] = TRUE;
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 		try {
205 205
 			$sth = $this->db->prepare($query);
206 206
 			$sth->execute();
207
-		} catch(PDOException $e) {
207
+		} catch (PDOException $e) {
208 208
 			echo "Error : ".$e->getMessage();
209 209
 			return array();
210 210
 		}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		try {
226 226
 			$sth = $this->db->prepare($query);
227 227
 			$sth->execute();
228
-		} catch(PDOException $e) {
228
+		} catch (PDOException $e) {
229 229
 			echo "Error : ".$e->getMessage();
230 230
 			return array();
231 231
 		}
@@ -241,15 +241,15 @@  discard block
 block discarded – undo
241 241
 		if ($globalDebug) echo 'Import '.$file."\n";
242 242
 		$result = array();
243 243
 		if (file_exists($file)) {
244
-			if (($handle = fopen($file,'r')) !== FALSE) {
245
-				while (($data = fgetcsv($handle,2000,",")) !== FALSE) {
244
+			if (($handle = fopen($file, 'r')) !== FALSE) {
245
+				while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) {
246 246
 					if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') {
247
-						$result[] = array('registration' => $data[0],'date' => strtotime($data[1]),'url' => $data[2],'country' => $data[3],'place' => $data[4],'title' => $data[5],'fatalities' => $data[6],'latitude' => $data[7],'longitude' => $data[8],'type' => $data[9],'ident' => $data[10],'aircraft_manufacturer' => $data[11],'aircraft_name' => $data[12],'operator' => $data[13],'source' => 'website_fam');
247
+						$result[] = array('registration' => $data[0], 'date' => strtotime($data[1]), 'url' => $data[2], 'country' => $data[3], 'place' => $data[4], 'title' => $data[5], 'fatalities' => $data[6], 'latitude' => $data[7], 'longitude' => $data[8], 'type' => $data[9], 'ident' => $data[10], 'aircraft_manufacturer' => $data[11], 'aircraft_name' => $data[12], 'operator' => $data[13], 'source' => 'website_fam');
248 248
 					}
249 249
 				}
250 250
 				fclose($handle);
251 251
 			}
252
-			if (!empty($result)) $this->add($result,true);
252
+			if (!empty($result)) $this->add($result, true);
253 253
 			elseif ($globalDebug) echo 'Nothing to import';
254 254
 		}
255 255
 	}
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 		$all_md5_new = array();
266 266
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
267 267
 			if ($this->check_accidents_nb() > 0) {
268
-				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
269
-					while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
268
+				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
269
+					while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
270 270
 						if (isset($data[1])) {
271 271
 							$year = $data[0];
272 272
 							$all_md5[$year] = $data[1];
@@ -276,10 +276,10 @@  discard block
 block discarded – undo
276 276
 				}
277 277
 			}
278 278
 		}
279
-		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5');
279
+		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5');
280 280
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
281
-			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
282
-				while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
281
+			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
282
+				while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
283 283
 					if (isset($data[1])) {
284 284
 						$year = $data[0];
285 285
 						$all_md5_new[$year] = $data[1];
@@ -288,10 +288,10 @@  discard block
 block discarded – undo
288 288
 				fclose($handle);
289 289
 			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
290 290
 		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
291
-		$result = $Common->arr_diff($all_md5_new,$all_md5);
291
+		$result = $Common->arr_diff($all_md5_new, $all_md5);
292 292
 		if (empty($result) && $globalDebug) echo 'Nothing to update';
293 293
 		foreach ($result as $file => $md5) {
294
-			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
294
+			$Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file);
295 295
 			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
296 296
 			elseif ($globalDebug) echo 'Download '.$file.' failed';
297 297
 		}
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	* Add data to DB
302 302
 	* @param Array $crash An array with accidents/incidents data
303 303
 	*/
304
-	public function add($crash,$new = false) {
304
+	public function add($crash, $new = false) {
305 305
 		global $globalTransaction, $globalDebug, $globalAircraftImageFetch;
306 306
 		require_once('class.Connection.php');
307 307
 		require_once('class.Image.php');
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 			$sthd->execute(array(':source' => $crash[0]['source']));
318 318
 		}
319 319
 		if ($globalTransaction) $Connection->db->beginTransaction();
320
-		$initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null);
320
+		$initial_array = array('ident' => null, 'type' => 'accident', 'url' => null, 'registration' => null, 'date' => null, 'place' => null, 'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '', 'source' => '', 'aircraft_manufacturer' => null, 'aircraft_name' => null, 'operator' => null);
321 321
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
322 322
 		$sth_check = $Connection->db->prepare($query_check);
323 323
 		$query = 'INSERT INTO accidents (aircraft_manufacturer,aircraft_name,ident,registration,date,url,country,place,title,fatalities,latitude,longitude,type,airline_name,source) VALUES (:aircraft_manufacturer,:aircraft_name,:ident,:registration,:date,:url,:country,:place,:title,:fatalities,:latitude,:longitude,:type,:airline_name,:source)';
@@ -330,15 +330,15 @@  discard block
 block discarded – undo
330 330
 				$cr = array_map(function($value) {
331 331
 					return $value === "" ? NULL : $value;
332 332
 				}, $cr);
333
-				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
334
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
335
-					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
333
+				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) {
334
+					if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
335
+					$query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']);
336 336
 					$sth_check->execute($query_check_values);
337 337
 					$result_check = $sth_check->fetchAll(PDO::FETCH_ASSOC);
338 338
 					if ($result_check[0]['nb'] == 0) {
339
-						$query_values = array(':registration' => trim($cr['registration']),':date' => date('Y-m-d',$cr['date']),':url' => $cr['url'],':country' => $cr['country'],':place' => $cr['place'],':title' => $cr['title'],':fatalities' => $cr['fatalities'],':latitude' => $cr['latitude'],':longitude' => $cr['longitude'],':type' => $cr['type'],':source' => $cr['source'],':ident' => $cr['ident'],':aircraft_manufacturer' => $cr['aircraft_manufacturer'],':aircraft_name' => $cr['aircraft_name'],':airline_name' => $cr['operator']);
339
+						$query_values = array(':registration' => trim($cr['registration']), ':date' => date('Y-m-d', $cr['date']), ':url' => $cr['url'], ':country' => $cr['country'], ':place' => $cr['place'], ':title' => $cr['title'], ':fatalities' => $cr['fatalities'], ':latitude' => $cr['latitude'], ':longitude' => $cr['longitude'], ':type' => $cr['type'], ':source' => $cr['source'], ':ident' => $cr['ident'], ':aircraft_manufacturer' => $cr['aircraft_manufacturer'], ':aircraft_name' => $cr['aircraft_name'], ':airline_name' => $cr['operator']);
340 340
 						$sth->execute($query_values);
341
-						if ($cr['date'] > time()-(30*86400)) {
341
+						if ($cr['date'] > time() - (30*86400)) {
342 342
 							if ($globalAircraftImageFetch) {
343 343
 								$imgchk = $Image->getSpotterImage($cr['registration']);
344 344
 								if (empty($imgchk)) {
@@ -349,17 +349,17 @@  discard block
 block discarded – undo
349 349
 								// elseif ($globalDebug) echo 'Image already in DB'."\n";
350 350
 							}
351 351
 							if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type'];
352
-							$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
352
+							$Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date']));
353 353
 						}
354 354
 					}
355 355
 				}
356
-				if ($globalTransaction && $j % 1000 == 0) {
356
+				if ($globalTransaction && $j%1000 == 0) {
357 357
 					$Connection->db->commit();
358 358
 					$Connection->db->beginTransaction();
359 359
 				}
360 360
 			}
361 361
 			if ($globalTransaction) $Connection->db->commit();
362
-		} catch(PDOException $e) {
362
+		} catch (PDOException $e) {
363 363
 			if ($globalTransaction) $Connection->db->rollBack();
364 364
 			echo $e->getMessage();
365 365
 		}
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 			$Connection = new Connection();
378 378
 			$sth = $Connection->db->prepare($query);
379 379
 			$sth->execute();
380
-		} catch(PDOException $e) {
380
+		} catch (PDOException $e) {
381 381
 			return "error : ".$e->getMessage();
382 382
 		}
383 383
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 			$Connection = new Connection();
400 400
 			$sth = $Connection->db->prepare($query);
401 401
 			$sth->execute();
402
-		} catch(PDOException $e) {
402
+		} catch (PDOException $e) {
403 403
 			return "error : ".$e->getMessage();
404 404
 		}
405 405
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 			$Connection = new Connection();
419 419
 			$sth = $Connection->db->prepare($query);
420 420
 			$sth->execute();
421
-		} catch(PDOException $e) {
421
+		} catch (PDOException $e) {
422 422
 			return "error : ".$e->getMessage();
423 423
 		}
424 424
 		return '';
Please login to merge, or discard this patch.
Braces   +87 added lines, -31 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@  discard block
 block discarded – undo
20 20
 	public function __construct($dbc = null) {
21 21
 		$Connection = new Connection($dbc);
22 22
 		$this->db = $Connection->db();
23
-		if ($this->db === null) die('Error: No DB connection. (Accident)');
23
+		if ($this->db === null) {
24
+			die('Error: No DB connection. (Accident)');
25
+		}
24 26
 	}
25 27
 
26 28
 	/*
@@ -126,8 +128,11 @@  discard block
 block discarded – undo
126 128
 				$data = array();
127 129
 				if ($row['registration'] != '') {
128 130
 					$image_array = $Image->getSpotterImage($row['registration']);
129
-					if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
130
-					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
131
+					if (count($image_array) > 0) {
132
+						$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
133
+					} else {
134
+						$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
135
+					}
131 136
 					$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
132 137
 					$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
133 138
 					if (!empty($aircraft_info)) {
@@ -143,17 +148,30 @@  discard block
 block discarded – undo
143 148
 						$data['aircraft_base'] = $owner_data['base'];
144 149
 						$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
145 150
 					}
146
-				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
147
-				if ($row['registration'] == '') $row['registration'] = 'NA';
148
-				if ($row['ident'] == '') $row['ident'] = 'NA';
151
+				} else {
152
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
153
+				}
154
+				if ($row['registration'] == '') {
155
+					$row['registration'] = 'NA';
156
+				}
157
+				if ($row['ident'] == '') {
158
+					$row['ident'] = 'NA';
159
+				}
149 160
 				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
150 161
 				if (isset($identicao[0])) {
151 162
 					if (substr($row['ident'],0,2) == 'AF') {
152
-						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
153
-						else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
154
-					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
163
+						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
164
+							$icao = $row['ident'];
165
+						} else {
166
+							$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
167
+						}
168
+					} else {
169
+						$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
170
+					}
155 171
 					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
156
-				} else $icao = $row['ident'];
172
+				} else {
173
+					$icao = $row['ident'];
174
+				}
157 175
 				$icao = $Translation->checkTranslation($icao,false);
158 176
 				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
159 177
 				if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
@@ -168,10 +186,14 @@  discard block
 block discarded – undo
168 186
 					//else echo 'No data...'."\n";
169 187
 				}
170 188
 				$data = array_merge($row,$data);
171
-				if ($data['ident'] == null) $data['ident'] = $icao;
189
+				if ($data['ident'] == null) {
190
+					$data['ident'] = $icao;
191
+				}
172 192
 				if ($data['title'] == null) {
173 193
 					$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
174
-				} else $data['message'] = strtolower($data['title']);
194
+				} else {
195
+					$data['message'] = strtolower($data['title']);
196
+				}
175 197
 				$ids = $Spotter->getAllIDByRegistration($data['registration'],true);
176 198
 				$date = $data['date'];
177 199
 				if (isset($ids[$date])) {
@@ -190,8 +212,9 @@  discard block
 block discarded – undo
190 212
 		if (isset($result)) {
191 213
 			$result[0]['query_number_rows'] = $i;
192 214
 			return $result;
215
+		} else {
216
+			return array();
193 217
 		}
194
-		else return array();
195 218
 	}
196 219
 
197 220
 	/*
@@ -238,7 +261,9 @@  discard block
 block discarded – undo
238 261
 	*/
239 262
 	public function import($file) {
240 263
 		global $globalDebug;
241
-		if ($globalDebug) echo 'Import '.$file."\n";
264
+		if ($globalDebug) {
265
+			echo 'Import '.$file."\n";
266
+		}
242 267
 		$result = array();
243 268
 		if (file_exists($file)) {
244 269
 			if (($handle = fopen($file,'r')) !== FALSE) {
@@ -249,8 +274,11 @@  discard block
 block discarded – undo
249 274
 				}
250 275
 				fclose($handle);
251 276
 			}
252
-			if (!empty($result)) $this->add($result,true);
253
-			elseif ($globalDebug) echo 'Nothing to import';
277
+			if (!empty($result)) {
278
+				$this->add($result,true);
279
+			} elseif ($globalDebug) {
280
+				echo 'Nothing to import';
281
+			}
254 282
 		}
255 283
 	}
256 284
 
@@ -286,14 +314,23 @@  discard block
 block discarded – undo
286 314
 					}
287 315
 				}
288 316
 				fclose($handle);
289
-			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
290
-		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
317
+			} elseif ($globalDebug) {
318
+				echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
319
+			}
320
+		} elseif ($globalDebug) {
321
+			echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
322
+		}
291 323
 		$result = $Common->arr_diff($all_md5_new,$all_md5);
292
-		if (empty($result) && $globalDebug) echo 'Nothing to update';
324
+		if (empty($result) && $globalDebug) {
325
+			echo 'Nothing to update';
326
+		}
293 327
 		foreach ($result as $file => $md5) {
294 328
 			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
295
-			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
296
-			elseif ($globalDebug) echo 'Download '.$file.' failed';
329
+			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) {
330
+				$this->import(dirname(__FILE__).'/../install/tmp/'.$file);
331
+			} elseif ($globalDebug) {
332
+				echo 'Download '.$file.' failed';
333
+			}
297 334
 		}
298 335
 	}
299 336
 
@@ -310,13 +347,17 @@  discard block
 block discarded – undo
310 347
 		$Image = new Image($this->db);
311 348
 		$Spotter = new Spotter($this->db);
312 349
 
313
-		if (empty($crash)) return false;
350
+		if (empty($crash)) {
351
+			return false;
352
+		}
314 353
 		if ($new === false) {
315 354
 			$query_delete = 'DELETE FROM accidents WHERE source = :source';
316 355
 			$sthd = $Connection->db->prepare($query_delete);
317 356
 			$sthd->execute(array(':source' => $crash[0]['source']));
318 357
 		}
319
-		if ($globalTransaction) $Connection->db->beginTransaction();
358
+		if ($globalTransaction) {
359
+			$Connection->db->beginTransaction();
360
+		}
320 361
 		$initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null);
321 362
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
322 363
 		$sth_check = $Connection->db->prepare($query_check);
@@ -331,7 +372,9 @@  discard block
 block discarded – undo
331 372
 					return $value === "" ? NULL : $value;
332 373
 				}, $cr);
333 374
 				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
334
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
375
+					if (strpos($cr['registration'],'-') === FALSE) {
376
+						$cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
377
+					}
335 378
 					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
336 379
 					$sth_check->execute($query_check_values);
337 380
 					$result_check = $sth_check->fetchAll(PDO::FETCH_ASSOC);
@@ -342,13 +385,19 @@  discard block
 block discarded – undo
342 385
 							if ($globalAircraftImageFetch) {
343 386
 								$imgchk = $Image->getSpotterImage($cr['registration']);
344 387
 								if (empty($imgchk)) {
345
-									if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...';
388
+									if ($globalDebug) {
389
+										echo "\t".'Get image for '.$cr['registration'].'...';
390
+									}
346 391
 									$Image->addSpotterImage($cr['registration']);
347
-									if ($globalDebug) echo "\t".'Done'."\n";
392
+									if ($globalDebug) {
393
+										echo "\t".'Done'."\n";
394
+									}
348 395
 								}
349 396
 								// elseif ($globalDebug) echo 'Image already in DB'."\n";
350 397
 							}
351
-							if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type'];
398
+							if ($cr['title'] == '') {
399
+								$cr['title'] = $cr['registration'].' '.$cr['type'];
400
+							}
352 401
 							$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
353 402
 						}
354 403
 					}
@@ -358,9 +407,13 @@  discard block
 block discarded – undo
358 407
 					$Connection->db->beginTransaction();
359 408
 				}
360 409
 			}
361
-			if ($globalTransaction) $Connection->db->commit();
410
+			if ($globalTransaction) {
411
+				$Connection->db->commit();
412
+			}
362 413
 		} catch(PDOException $e) {
363
-			if ($globalTransaction) $Connection->db->rollBack();
414
+			if ($globalTransaction) {
415
+				$Connection->db->rollBack();
416
+			}
364 417
 			echo $e->getMessage();
365 418
 		}
366 419
 		$sth_check->closeCursor();
@@ -403,8 +456,11 @@  discard block
 block discarded – undo
403 456
 			return "error : ".$e->getMessage();
404 457
 		}
405 458
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
406
-		if ($row['nb'] > 0) return false;
407
-		else return true;
459
+		if ($row['nb'] > 0) {
460
+			return false;
461
+		} else {
462
+			return true;
463
+		}
408 464
 	}
409 465
 
410 466
     /**
Please login to merge, or discard this patch.
require/class.ACARS.php 3 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
 	}
33 33
 
34 34
 	/**
35
-	* Change IATA to ICAO value for ident
36
-	*
37
-	* @param String $ident ident
38
-	* @return String the icao
39
-	*/
35
+	 * Change IATA to ICAO value for ident
36
+	 *
37
+	 * @param String $ident ident
38
+	 * @return String the icao
39
+	 */
40 40
 	public function ident2icao($ident) {
41 41
 		if (substr($ident,0,2) == 'AF') {
42 42
 			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 
54 54
 	/**
55
-	* Deletes all info in the live table
56
-	*
57
-	* @return String success or false
58
-	*
59
-	*/
55
+	 * Deletes all info in the live table
56
+	 *
57
+	 * @return String success or false
58
+	 *
59
+	 */
60 60
 	public function deleteLiveAcarsData()
61 61
 	{
62 62
 		global $globalDBdriver;
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
 	}
77 77
 
78 78
 	/**
79
-	* Deletes all info in the archive table
80
-	*
81
-	* @return String success or false
82
-	*
83
-	*/
79
+	 * Deletes all info in the archive table
80
+	 *
81
+	 * @return String success or false
82
+	 *
83
+	 */
84 84
 	public function deleteArchiveAcarsData()
85 85
 	{
86 86
 		global $globalACARSArchiveKeepMonths, $globalDBdriver;
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 	}
101 101
 
102 102
 
103
-    /**
104
-     * Parse ACARS data
105
-     *
106
-     * @param String ACARS data in acarsdec data
107
-     *
108
-     * @return array
109
-     */
103
+	/**
104
+	 * Parse ACARS data
105
+	 *
106
+	 * @param String ACARS data in acarsdec data
107
+	 *
108
+	 * @return array
109
+	 */
110 110
 	public function parse($data) {
111 111
 		global $globalDebug;
112 112
 		//$Image = new Image($this->db);
@@ -736,11 +736,11 @@  discard block
 block discarded – undo
736 736
 	}
737 737
 
738 738
 	/**
739
-	* Add ACARS data
740
-	*
741
-	* @param String ACARS data in acarsdec data
742
-	*
743
-	*/
739
+	 * Add ACARS data
740
+	 *
741
+	 * @param String ACARS data in acarsdec data
742
+	 *
743
+	 */
744 744
 	public function add($data,$message = array()) {
745 745
 		global $globalDebug, $globalACARSArchive;
746 746
 		$Image = new Image($this->db);
@@ -787,18 +787,18 @@  discard block
 block discarded – undo
787 787
 		}
788 788
 	}
789 789
 
790
-    /**
791
-     * Add Live ACARS data in DB
792
-     *
793
-     * @param String $ident ident
794
-     * @param String $registration Registration of the aircraft
795
-     * @param String $label Label of the ACARS message
796
-     * @param String $block_id Block id of the ACARS message
797
-     * @param String $msg_no Number of the ACARS message
798
-     * @param String $message ACARS message
799
-     * @param string $decode
800
-     * @return bool
801
-     */
790
+	/**
791
+	 * Add Live ACARS data in DB
792
+	 *
793
+	 * @param String $ident ident
794
+	 * @param String $registration Registration of the aircraft
795
+	 * @param String $label Label of the ACARS message
796
+	 * @param String $block_id Block id of the ACARS message
797
+	 * @param String $msg_no Number of the ACARS message
798
+	 * @param String $message ACARS message
799
+	 * @param string $decode
800
+	 * @return bool
801
+	 */
802 802
 	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
803 803
 		global $globalDebug;
804 804
 		date_default_timezone_set('UTC');
@@ -836,18 +836,18 @@  discard block
 block discarded – undo
836 836
 		return false;
837 837
 	}
838 838
 
839
-    /**
840
-     * Add Archive ACARS data in DB
841
-     *
842
-     * @param String $ident ident
843
-     * @param String $registration Registration of the aircraft
844
-     * @param String $label Label of the ACARS message
845
-     * @param String $block_id Block id of the ACARS message
846
-     * @param String $msg_no Number of the ACARS message
847
-     * @param String $message ACARS message
848
-     * @param string $decode
849
-     * @return string
850
-     */
839
+	/**
840
+	 * Add Archive ACARS data in DB
841
+	 *
842
+	 * @param String $ident ident
843
+	 * @param String $registration Registration of the aircraft
844
+	 * @param String $label Label of the ACARS message
845
+	 * @param String $block_id Block id of the ACARS message
846
+	 * @param String $msg_no Number of the ACARS message
847
+	 * @param String $message ACARS message
848
+	 * @param string $decode
849
+	 * @return string
850
+	 */
851 851
 	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
852 852
 		global $globalDebug;
853 853
 		date_default_timezone_set('UTC');
@@ -879,11 +879,11 @@  discard block
 block discarded – undo
879 879
 	}
880 880
 
881 881
 	/**
882
-	* Get Message title from label from DB
883
-	*
884
-	* @param String $label
885
-	* @return String Return ACARS title
886
-	*/
882
+	 * Get Message title from label from DB
883
+	 *
884
+	 * @param String $label
885
+	 * @return String Return ACARS title
886
+	 */
887 887
 	public function getTitlefromLabel($label) {
888 888
 		$Connection = new Connection($this->db);
889 889
 		$this->db = $Connection->db;
@@ -902,10 +902,10 @@  discard block
 block discarded – undo
902 902
 	}
903 903
 
904 904
 	/**
905
-	* List all Message title & label from DB
906
-	*
907
-	* @return array Return ACARS data in array
908
-	*/
905
+	 * List all Message title & label from DB
906
+	 *
907
+	 * @return array Return ACARS data in array
908
+	 */
909 909
 	public function getAllTitleLabel() {
910 910
 		$query = "SELECT * FROM acars_label ORDER BY title";
911 911
 		$query_values = array();
@@ -922,11 +922,11 @@  discard block
 block discarded – undo
922 922
 	}
923 923
 
924 924
 	/**
925
-	* Get Live ACARS data from DB
926
-	*
927
-	* @param String $ident
928
-	* @return array Return ACARS data in array
929
-	*/
925
+	 * Get Live ACARS data from DB
926
+	 *
927
+	 * @param String $ident
928
+	 * @return array Return ACARS data in array
929
+	 */
930 930
 	public function getLiveAcarsData($ident) {
931 931
 		$query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC";
932 932
 		$query_values = array(':ident' => $ident);
@@ -942,13 +942,13 @@  discard block
 block discarded – undo
942 942
 		else return array();
943 943
 	}
944 944
 
945
-    /**
946
-     * Get Latest ACARS data from DB
947
-     *
948
-     * @param string $limit
949
-     * @param string $label
950
-     * @return array Return ACARS data in array
951
-     */
945
+	/**
946
+	 * Get Latest ACARS data from DB
947
+	 *
948
+	 * @param string $limit
949
+	 * @param string $label
950
+	 * @return array Return ACARS data in array
951
+	 */
952 952
 	public function getLatestAcarsData($limit = '',$label = '') {
953 953
 		global $globalURL;
954 954
 		$Image = new Image($this->db);
@@ -1036,13 +1036,13 @@  discard block
 block discarded – undo
1036 1036
 		else return array();
1037 1037
 	}
1038 1038
 
1039
-    /**
1040
-     * Get Archive ACARS data from DB
1041
-     *
1042
-     * @param string $limit
1043
-     * @param string $label
1044
-     * @return array Return ACARS data in array
1045
-     */
1039
+	/**
1040
+	 * Get Archive ACARS data from DB
1041
+	 *
1042
+	 * @param string $limit
1043
+	 * @param string $label
1044
+	 * @return array Return ACARS data in array
1045
+	 */
1046 1046
 	public function getArchiveAcarsData($limit = '',$label = '') {
1047 1047
 		global $globalURL;
1048 1048
 		$Image = new Image($this->db);
@@ -1131,17 +1131,17 @@  discard block
 block discarded – undo
1131 1131
 		} else return array();
1132 1132
 	}
1133 1133
 
1134
-    /**
1135
-     * Add ModeS data to DB
1136
-     *
1137
-     * @param String $ident ident
1138
-     * @param String $registration Registration of the aircraft
1139
-     * @param String $icao
1140
-     * @param String $ICAOTypeCode
1141
-     * @param string $latitude
1142
-     * @param string $longitude
1143
-     * @return string
1144
-     */
1134
+	/**
1135
+	 * Add ModeS data to DB
1136
+	 *
1137
+	 * @param String $ident ident
1138
+	 * @param String $registration Registration of the aircraft
1139
+	 * @param String $icao
1140
+	 * @param String $ICAOTypeCode
1141
+	 * @param string $latitude
1142
+	 * @param string $longitude
1143
+	 * @return string
1144
+	 */
1145 1145
 	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1146 1146
 		global $globalDebug, $globalDBdriver;
1147 1147
 		$ident = trim($ident);
Please login to merge, or discard this patch.
Spacing   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	/*
22 22
 	 * Initialize DB connection
23 23
 	*/
24
-	public function __construct($dbc = null,$fromACARSscript = false) {
24
+	public function __construct($dbc = null, $fromACARSscript = false) {
25 25
 		$Connection = new Connection($dbc);
26 26
 		$this->db = $Connection->db();
27 27
 		if ($this->db === null) die('Error: No DB connection. (ACARS)');
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 	* @return String the icao
39 39
 	*/
40 40
 	public function ident2icao($ident) {
41
-		if (substr($ident,0,2) == 'AF') {
42
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
43
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
41
+		if (substr($ident, 0, 2) == 'AF') {
42
+			if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
43
+			else $icao = 'AFR'.ltrim(substr($ident, 2), '0');
44 44
 		} else {
45 45
 			$Spotter = new Spotter($this->db);
46
-			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
46
+			$identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2));
47 47
 			if (isset($identicao[0])) {
48
-				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
48
+				$icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0');
49 49
 			} else $icao = $ident;
50 50
 		}
51 51
 		return $icao;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
 			$sth = $this->db->prepare($query);
71 71
 			$sth->execute();
72
-		} catch(PDOException $e) {
72
+		} catch (PDOException $e) {
73 73
 			return "error";
74 74
 		}
75 75
 		return "success";
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
 			$sth = $this->db->prepare($query);
95 95
 			$sth->execute();
96
-		} catch(PDOException $e) {
96
+		} catch (PDOException $e) {
97 97
 			return "error";
98 98
 		}
99 99
 		return "success";
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 		$ident = '';
120 120
 		$message = '';
121 121
 		$result = array();
122
-		$n = sscanf($data,'%*[0-9a-z.] %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
123
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
124
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
125
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
122
+		$n = sscanf($data, '%*[0-9a-z.] %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
123
+		if ($n == 0) $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
124
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
125
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
126 126
 		if ($n != 0 && ($registration != '' || $ident != '' || $label != '' || $block_id != '' || $msg_no != '')) {
127
-			$registration = str_replace('.','',$registration);
128
-			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
127
+			$registration = str_replace('.', '', $registration);
128
+			$result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message);
129 129
 			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
130 130
 		} else $message = $data;
131 131
 		$decode = array();
@@ -145,14 +145,14 @@  discard block
 block discarded – undo
145 145
 				$temp = '';
146 146
 				$n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp);
147 147
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
148
-					$latitude = $la / 10000.0;
149
-					$longitude = $ln / 10000.0;
148
+					$latitude = $la/10000.0;
149
+					$longitude = $ln/10000.0;
150 150
 					if ($lac == 'S') $latitude = '-'.$latitude;
151 151
 					if ($lnc == 'W') $longitude = '-'.$longitude;
152 152
 					// Temp not always available
153 153
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
154
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
155
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
154
+					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt);
155
+					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C');
156 156
 
157 157
 					//$icao = $Translation->checkTranslation($ident);
158 158
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -164,19 +164,19 @@  discard block
 block discarded – undo
164 164
 				$dhour = '';
165 165
 				$darr = '';
166 166
 				$ahour = '';
167
-				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
167
+				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour);
168 168
 				if ($n == 4 && strlen($darr) == 4) {
169
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
170
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
171
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
169
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
170
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
171
+					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n";
172 172
 					//$icao = ACARS->ident2icao($ident);
173 173
 					//$icao = $Translation->checkTranslation($ident);
174 174
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
175 175
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
176 176
 					$found = true;
177 177
 				}
178
-				elseif ($n == 2 || $n  == 4) {
179
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
178
+				elseif ($n == 2 || $n == 4) {
179
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
180 180
 					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
181 181
 					//$icao = ACARS->ident2icao($ident);
182 182
 					//$icao = $Translation->checkTranslation($ident);
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
 				$ahour = '';
235 235
 				$aair = '';
236 236
 				$apiste = '';
237
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
237
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste);
238 238
 				if ($n > 8) {
239
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
240
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
241
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
239
+					if ($globalDebug) echo 'airicao : '.$airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '.$darr.' - date depart : '.$ddate.' - departure hour : '.$dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
240
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
241
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
242 242
 					$icao = trim($aident);
243 243
 
244 244
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
 				if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
264 264
 					$las = $las.'.'.$lass;
265 265
 					$lns = $lns.'.'.$lns;
266
-					$latitude = $las / 1000.0;
267
-					$longitude = $lns / 1000.0;
266
+					$latitude = $las/1000.0;
267
+					$longitude = $lns/1000.0;
268 268
 					if ($lac == 'S') $latitude = '-'.$latitude;
269 269
 					if ($lnc == 'W') $longitude = '-'.$longitude;
270 270
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
@@ -359,17 +359,17 @@  discard block
 block discarded – undo
359 359
 				$alt = '';
360 360
 				$fuel = '';
361 361
 				$speed = '';
362
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
362
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
363 363
 				if ($n == 9) {
364 364
 					//if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
365 365
 					$icao = trim($aident);
366 366
 					$decode['icao'] = $icao;
367
-					$latitude = $las / 100.0;
368
-					$longitude = $lns / 100.0;
367
+					$latitude = $las/100.0;
368
+					$longitude = $lns/100.0;
369 369
 					if ($lac == 'S') $latitude = '-'.$latitude;
370 370
 					if ($lnc == 'W') $longitude = '-'.$longitude;
371 371
 
372
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
372
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed);
373 373
 					$found = true;
374 374
 				}
375 375
 			}
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 					if ($lac == 'S') $latitude = '-'.$latitude;
389 389
 					if ($lnc == 'W') $longitude = '-'.$longitude;
390 390
 
391
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
391
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
392 392
 					$found = true;
393 393
 				}
394 394
 			}
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 				$dair = '';
422 422
 				$darr = '';
423 423
 				$aident = '';
424
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
424
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
425 425
 				if ($n == 8) {
426 426
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
427 427
 					$icao = trim($aident);
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 				*/
454 454
 				$dair = '';
455 455
 				$darr = '';
456
-				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
456
+				$n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr);
457 457
 				if ($n == 3) {
458 458
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
459 459
 					//$icao = $Translation->checkTranslation($ident);
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 				*/
469 469
 				$dair = '';
470 470
 				$darr = '';
471
-				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
471
+				$n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr);
472 472
 				if ($n == 3) {
473 473
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
474 474
 					//$icao = $Translation->checkTranslation($ident);
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 				}
479 479
 			}
480 480
 			if (!$found) {
481
-				$n = sscanf($message,'MET01%4c',$airport);
481
+				$n = sscanf($message, 'MET01%4c', $airport);
482 482
 				if ($n == 1) {
483 483
 					if ($globalDebug) echo 'airport name : '.$airport;
484 484
 					$decode = array('Airport/Waypoint name' => $airport);
@@ -486,241 +486,241 @@  discard block
 block discarded – undo
486 486
 				}
487 487
 			}
488 488
 			if ($label == 'H1') {
489
-				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
490
-					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
489
+				if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) {
490
+					$decode = array_merge(array('Message nature' => 'Equipment failure'), $decode);
491 491
 				}
492
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
493
-					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
492
+				elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) {
493
+					$decode = array_merge(array('Message nature' => 'Take off performance data'), $decode);
494 494
 				}
495
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
496
-					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
495
+				elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) {
496
+					$decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode);
497 497
 				}
498
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
499
-					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
498
+				elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) {
499
+					$decode = array_merge(array('Message nature' => 'Weather observation'), $decode);
500 500
 				}
501
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
502
-					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
501
+				elseif (preg_match(':^#DFB/PIREP:', $message)) {
502
+					$decode = array_merge(array('Message nature' => 'Pilot Report'), $decode);
503 503
 				}
504
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
505
-					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
504
+				elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) {
505
+					$decode = array_merge(array('Message nature' => 'Engine Data'), $decode);
506 506
 				}
507
-				elseif (preg_match(':^#M1AAEP:',$message)) {
508
-					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
507
+				elseif (preg_match(':^#M1AAEP:', $message)) {
508
+					$decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode);
509 509
 				}
510
-				elseif (preg_match(':^#M2APWD:',$message)) {
511
-					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
510
+				elseif (preg_match(':^#M2APWD:', $message)) {
511
+					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode);
512 512
 				}
513
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
514
-					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
513
+				elseif (preg_match(':^#M1BREQPWI:', $message)) {
514
+					$decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode);
515 515
 				}
516
-				elseif (preg_match(':^#CF:',$message)) {
517
-					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
516
+				elseif (preg_match(':^#CF:', $message)) {
517
+					$decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode);
518 518
 				}
519
-				elseif (preg_match(':^#DF:',$message)) {
520
-					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
519
+				elseif (preg_match(':^#DF:', $message)) {
520
+					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode);
521 521
 				}
522
-				elseif (preg_match(':^#EC:',$message)) {
523
-					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
522
+				elseif (preg_match(':^#EC:', $message)) {
523
+					$decode = array_merge(array('Message nature' => 'Engine Display System'), $decode);
524 524
 				}
525
-				elseif (preg_match(':^#EI:',$message)) {
526
-					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
525
+				elseif (preg_match(':^#EI:', $message)) {
526
+					$decode = array_merge(array('Message nature' => 'Engine Report'), $decode);
527 527
 				}
528
-				elseif (preg_match(':^#H1:',$message)) {
529
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
528
+				elseif (preg_match(':^#H1:', $message)) {
529
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode);
530 530
 				}
531
-				elseif (preg_match(':^#H2:',$message)) {
532
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
531
+				elseif (preg_match(':^#H2:', $message)) {
532
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode);
533 533
 				}
534
-				elseif (preg_match(':^#HD:',$message)) {
535
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
534
+				elseif (preg_match(':^#HD:', $message)) {
535
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode);
536 536
 				}
537
-				elseif (preg_match(':^#M1:',$message)) {
538
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
537
+				elseif (preg_match(':^#M1:', $message)) {
538
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode);
539 539
 				}
540
-				elseif (preg_match(':^#M2:',$message)) {
541
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
540
+				elseif (preg_match(':^#M2:', $message)) {
541
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode);
542 542
 				}
543
-				elseif (preg_match(':^#M3:',$message)) {
544
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
543
+				elseif (preg_match(':^#M3:', $message)) {
544
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode);
545 545
 				}
546
-				elseif (preg_match(':^#MD:',$message)) {
547
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
546
+				elseif (preg_match(':^#MD:', $message)) {
547
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode);
548 548
 				}
549
-				elseif (preg_match(':^#PS:',$message)) {
550
-					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
549
+				elseif (preg_match(':^#PS:', $message)) {
550
+					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode);
551 551
 				}
552
-				elseif (preg_match(':^#S1:',$message)) {
553
-					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
552
+				elseif (preg_match(':^#S1:', $message)) {
553
+					$decode = array_merge(array('Message nature' => 'SDU - Left'), $decode);
554 554
 				}
555
-				elseif (preg_match(':^#S2:',$message)) {
556
-					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
555
+				elseif (preg_match(':^#S2:', $message)) {
556
+					$decode = array_merge(array('Message nature' => 'SDU - Right'), $decode);
557 557
 				}
558
-				elseif (preg_match(':^#SD:',$message)) {
559
-					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
558
+				elseif (preg_match(':^#SD:', $message)) {
559
+					$decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode);
560 560
 				}
561
-				elseif (preg_match(':^#T[0-8]:',$message)) {
562
-					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
561
+				elseif (preg_match(':^#T[0-8]:', $message)) {
562
+					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode);
563 563
 				}
564
-				elseif (preg_match(':^#WO:',$message)) {
565
-					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
564
+				elseif (preg_match(':^#WO:', $message)) {
565
+					$decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode);
566 566
 				}
567
-				elseif (preg_match(':^#A1:',$message)) {
568
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
567
+				elseif (preg_match(':^#A1:', $message)) {
568
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode);
569 569
 				}
570
-				elseif (preg_match(':^#A3:',$message)) {
571
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
570
+				elseif (preg_match(':^#A3:', $message)) {
571
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode);
572 572
 				}
573
-				elseif (preg_match(':^#A4:',$message)) {
574
-					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
573
+				elseif (preg_match(':^#A4:', $message)) {
574
+					$decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode);
575 575
 				}
576
-				elseif (preg_match(':^#A6:',$message)) {
577
-					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
576
+				elseif (preg_match(':^#A6:', $message)) {
577
+					$decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode);
578 578
 				}
579
-				elseif (preg_match(':^#A8:',$message)) {
580
-					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
579
+				elseif (preg_match(':^#A8:', $message)) {
580
+					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode);
581 581
 				}
582
-				elseif (preg_match(':^#A9:',$message)) {
583
-					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
582
+				elseif (preg_match(':^#A9:', $message)) {
583
+					$decode = array_merge(array('Message nature' => 'ATIS report'), $decode);
584 584
 				}
585
-				elseif (preg_match(':^#A0:',$message)) {
586
-					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
585
+				elseif (preg_match(':^#A0:', $message)) {
586
+					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode);
587 587
 				}
588
-				elseif (preg_match(':^#AA:',$message)) {
589
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
588
+				elseif (preg_match(':^#AA:', $message)) {
589
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
590 590
 				}
591
-				elseif (preg_match(':^#AB:',$message)) {
592
-					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
591
+				elseif (preg_match(':^#AB:', $message)) {
592
+					$decode = array_merge(array('Message nature' => 'TWIP Report'), $decode);
593 593
 				}
594
-				elseif (preg_match(':^#AC:',$message)) {
595
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
594
+				elseif (preg_match(':^#AC:', $message)) {
595
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode);
596 596
 				}
597
-				elseif (preg_match(':^#AD:',$message)) {
598
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
597
+				elseif (preg_match(':^#AD:', $message)) {
598
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode);
599 599
 				}
600
-				elseif (preg_match(':^#AF:',$message)) {
601
-					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
600
+				elseif (preg_match(':^#AF:', $message)) {
601
+					$decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode);
602 602
 				}
603
-				elseif (preg_match(':^#B1:',$message)) {
604
-					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
603
+				elseif (preg_match(':^#B1:', $message)) {
604
+					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode);
605 605
 				}
606
-				elseif (preg_match(':^#B2:',$message)) {
607
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
606
+				elseif (preg_match(':^#B2:', $message)) {
607
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode);
608 608
 				}
609
-				elseif (preg_match(':^#B3:',$message)) {
610
-					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
609
+				elseif (preg_match(':^#B3:', $message)) {
610
+					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode);
611 611
 				}
612
-				elseif (preg_match(':^#B4:',$message)) {
613
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
612
+				elseif (preg_match(':^#B4:', $message)) {
613
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode);
614 614
 				}
615
-				elseif (preg_match(':^#B6:',$message)) {
616
-					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
615
+				elseif (preg_match(':^#B6:', $message)) {
616
+					$decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode);
617 617
 				}
618
-				elseif (preg_match(':^#B8:',$message)) {
619
-					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
618
+				elseif (preg_match(':^#B8:', $message)) {
619
+					$decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode);
620 620
 				}
621
-				elseif (preg_match(':^#B9:',$message)) {
622
-					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
621
+				elseif (preg_match(':^#B9:', $message)) {
622
+					$decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode);
623 623
 				}
624
-				elseif (preg_match(':^#B0:',$message)) {
625
-					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
624
+				elseif (preg_match(':^#B0:', $message)) {
625
+					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode);
626 626
 				}
627
-				elseif (preg_match(':^#BA:',$message)) {
628
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
627
+				elseif (preg_match(':^#BA:', $message)) {
628
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
629 629
 				}
630
-				elseif (preg_match(':^#BB:',$message)) {
631
-					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
630
+				elseif (preg_match(':^#BB:', $message)) {
631
+					$decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode);
632 632
 				}
633
-				elseif (preg_match(':^#BC:',$message)) {
634
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
633
+				elseif (preg_match(':^#BC:', $message)) {
634
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode);
635 635
 				}
636
-				elseif (preg_match(':^#BD:',$message)) {
637
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
636
+				elseif (preg_match(':^#BD:', $message)) {
637
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode);
638 638
 				}
639
-				elseif (preg_match(':^#BE:',$message)) {
640
-					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
639
+				elseif (preg_match(':^#BE:', $message)) {
640
+					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode);
641 641
 				}
642
-				elseif (preg_match(':^#BF:',$message)) {
643
-					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
642
+				elseif (preg_match(':^#BF:', $message)) {
643
+					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode);
644 644
 				}
645
-				elseif (preg_match(':^#H3:',$message)) {
646
-					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
645
+				elseif (preg_match(':^#H3:', $message)) {
646
+					$decode = array_merge(array('Message nature' => 'Icing Report'), $decode);
647 647
 				}
648 648
 			}
649 649
 			if ($label == '10') {
650
-				if (preg_match(':^DTO01:',$message)) {
651
-					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
650
+				if (preg_match(':^DTO01:', $message)) {
651
+					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode);
652 652
 				}
653
-				elseif (preg_match(':^AIS01:',$message)) {
654
-					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
653
+				elseif (preg_match(':^AIS01:', $message)) {
654
+					$decode = array_merge(array('Message nature' => 'AIS Request'), $decode);
655 655
 				}
656
-				elseif (preg_match(':^FTX01:',$message)) {
657
-					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
656
+				elseif (preg_match(':^FTX01:', $message)) {
657
+					$decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode);
658 658
 				}
659
-				elseif (preg_match(':^FPL01:',$message)) {
660
-					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
659
+				elseif (preg_match(':^FPL01:', $message)) {
660
+					$decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode);
661 661
 				}
662
-				elseif (preg_match(':^WAB01:',$message)) {
663
-					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
662
+				elseif (preg_match(':^WAB01:', $message)) {
663
+					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode);
664 664
 				}
665
-				elseif (preg_match(':^MET01:',$message)) {
666
-					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
665
+				elseif (preg_match(':^MET01:', $message)) {
666
+					$decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode);
667 667
 				}
668
-				elseif (preg_match(':^WAB02:',$message)) {
669
-					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
668
+				elseif (preg_match(':^WAB02:', $message)) {
669
+					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode);
670 670
 				}
671 671
 			}
672 672
 			if ($label == '15') {
673
-				if (preg_match(':^FST01:',$message)) {
674
-					$decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode);
673
+				if (preg_match(':^FST01:', $message)) {
674
+					$decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode);
675 675
 				}
676 676
 			}
677 677
 			if (!$found && $label == 'SA') {
678
-				$n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at);
678
+				$n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at);
679 679
 				if ($n == 4) {
680 680
 					$vsta = array('Version' => $version);
681 681
 					if ($state == 'E') {
682
-						$vsta = array_merge($vsta,array('Link state' => 'Established'));
682
+						$vsta = array_merge($vsta, array('Link state' => 'Established'));
683 683
 					}
684 684
 					elseif ($state == 'L') {
685
-						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
685
+						$vsta = array_merge($vsta, array('Link state' => 'Lost'));
686 686
 					}
687 687
 					else {
688
-						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
688
+						$vsta = array_merge($vsta, array('Link state' => 'Unknown'));
689 689
 					}
690 690
 					if ($type == 'V') {
691
-						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
691
+						$vsta = array_merge($vsta, array('Link type' => 'VHF ACARS'));
692 692
 					}
693 693
 					elseif ($type == 'S') {
694
-						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
694
+						$vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM'));
695 695
 					}
696 696
 					elseif ($type == 'H') {
697
-						$vsta = array_merge($vsta,array('Link type' => 'HF'));
697
+						$vsta = array_merge($vsta, array('Link type' => 'HF'));
698 698
 					}
699 699
 					elseif ($type == 'G') {
700
-						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
700
+						$vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM'));
701 701
 					}
702 702
 					elseif ($type == 'C') {
703
-						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
703
+						$vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM'));
704 704
 					}
705 705
 					elseif ($type == '2') {
706
-						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
706
+						$vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2'));
707 707
 					}
708 708
 					elseif ($type == 'X') {
709
-						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
709
+						$vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero'));
710 710
 					}
711 711
 					elseif ($type == 'I') {
712
-						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
712
+						$vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM'));
713 713
 					}
714 714
 					else {
715
-						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
715
+						$vsta = array_merge($vsta, array('Link type' => 'Unknown'));
716 716
 					}
717
-					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
718
-					$decode = array_merge($vsta,$decode);
717
+					$vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2))));
718
+					$decode = array_merge($vsta, $decode);
719 719
 				}
720 720
 			}
721 721
 
722 722
 			$title = $this->getTitlefromLabel($label);
723
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
723
+			if ($title != '') $decode = array_merge(array('Message title' => $title), $decode);
724 724
 			/*
725 725
 			// Business jets always use GS0001
726 726
 			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
@@ -741,21 +741,21 @@  discard block
 block discarded – undo
741 741
 	* @param String ACARS data in acarsdec data
742 742
 	*
743 743
 	*/
744
-	public function add($data,$message = array()) {
744
+	public function add($data, $message = array()) {
745 745
 		global $globalDebug, $globalACARSArchive;
746 746
 		$Image = new Image($this->db);
747 747
 		$Schedule = new Schedule($this->db);
748 748
 		$Translation = new Translation($this->db);
749 749
 
750
-		$message = array_merge($message,$this->parse($data));
750
+		$message = array_merge($message, $this->parse($data));
751 751
 		if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') {
752
-			$ident = (string)$message['ident'];
752
+			$ident = (string) $message['ident'];
753 753
 			$label = $message['label'];
754 754
 			$block_id = $message['block_id'];
755 755
 			$msg_no = $message['msg_no'];
756 756
 			$msg = $message['message'];
757 757
 			$decode = $message['decode'];
758
-			$registration = (string)$message['registration'];
758
+			$registration = (string) $message['registration'];
759 759
 			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
760 760
 			else $latitude = '';
761 761
 			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
@@ -769,20 +769,20 @@  discard block
 block discarded – undo
769 769
 				$Image->addSpotterImage($registration);
770 770
 			}
771 771
 			// Business jets always use GS0001
772
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
772
+			if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude);
773 773
 			if ($globalDebug && isset($info) && $info != '') echo $info;
774 774
 			if (count($decode) > 0) $decode_json = json_encode($decode);
775 775
 			else $decode_json = '';
776 776
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
777
-				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
777
+				$Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS');
778 778
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
779
-				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
779
+				$Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS');
780 780
 			}
781
-			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
782
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
783
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
781
+			$result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
782
+			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F');
783
+			if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
784 784
 			if ($globalDebug && count($decode) > 0) {
785
-				echo "Human readable data : ".implode(' - ',$decode)."\n";
785
+				echo "Human readable data : ".implode(' - ', $decode)."\n";
786 786
 			}
787 787
 		}
788 788
 	}
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
      * @param string $decode
800 800
      * @return bool
801 801
      */
802
-	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
802
+	public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
803 803
 		global $globalDebug;
804 804
 		date_default_timezone_set('UTC');
805 805
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
@@ -807,22 +807,22 @@  discard block
 block discarded – undo
807 807
 			$this->db = $Connection->db;
808 808
 			if ($globalDebug) echo "Test if not already in Live ACARS table...";
809 809
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
810
-			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
810
+			$query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message);
811 811
 			try {
812 812
 				$stht = $this->db->prepare($query_test);
813 813
 				$stht->execute($query_test_values);
814
-			} catch(PDOException $e) {
814
+			} catch (PDOException $e) {
815 815
 				echo "error : ".$e->getMessage();
816 816
 				return false;
817 817
 			}
818 818
 			if ($stht->fetchColumn() == 0) {
819 819
 				if ($globalDebug) echo "Add Live ACARS data...";
820 820
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
821
-				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
821
+				$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s"));
822 822
 				try {
823 823
 					$sth = $this->db->prepare($query);
824 824
 					$sth->execute($query_values);
825
-				} catch(PDOException $e) {
825
+				} catch (PDOException $e) {
826 826
 					echo "error : ".$e->getMessage();
827 827
 					return false;
828 828
 				}
@@ -848,10 +848,10 @@  discard block
 block discarded – undo
848 848
      * @param string $decode
849 849
      * @return string
850 850
      */
851
-	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
851
+	public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
852 852
 		global $globalDebug;
853 853
 		date_default_timezone_set('UTC');
854
-		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) {
854
+		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) {
855 855
 			/*
856 856
 				    if ($globalDebug) echo "Test if not already in Archive ACARS table...";
857 857
 			    	    $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message";
@@ -866,11 +866,11 @@  discard block
 block discarded – undo
866 866
 			*/
867 867
 			if ($globalDebug) echo "Add Live ACARS data...";
868 868
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
869
-			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
869
+			$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
870 870
 			try {
871 871
 				$sth = $this->db->prepare($query);
872 872
 				$sth->execute($query_values);
873
-			} catch(PDOException $e) {
873
+			} catch (PDOException $e) {
874 874
 				return "error : ".$e->getMessage();
875 875
 			}
876 876
 			if ($globalDebug) echo "Done\n";
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 		try {
893 893
 			$sth = $this->db->prepare($query);
894 894
 			$sth->execute($query_values);
895
-		} catch(PDOException $e) {
895
+		} catch (PDOException $e) {
896 896
 			echo "error : ".$e->getMessage();
897 897
 			return '';
898 898
 		}
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 		try {
913 913
 			$sth = $this->db->prepare($query);
914 914
 			$sth->execute($query_values);
915
-		} catch(PDOException $e) {
915
+		} catch (PDOException $e) {
916 916
 			echo "error : ".$e->getMessage();
917 917
 			return array();
918 918
 		}
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
 		try {
934 934
 			$sth = $this->db->prepare($query);
935 935
 			$sth->execute($query_values);
936
-		} catch(PDOException $e) {
936
+		} catch (PDOException $e) {
937 937
 			echo "error : ".$e->getMessage();
938 938
 			return array();
939 939
 		}
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
      * @param string $label
950 950
      * @return array Return ACARS data in array
951 951
      */
952
-	public function getLatestAcarsData($limit = '',$label = '') {
952
+	public function getLatestAcarsData($limit = '', $label = '') {
953 953
 		global $globalURL;
954 954
 		$Image = new Image($this->db);
955 955
 		$Spotter = new Spotter($this->db);
@@ -960,8 +960,8 @@  discard block
 block discarded – undo
960 960
 		if ($limit != "")
961 961
 		{
962 962
 			$limit_array = explode(",", $limit);
963
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
964
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
963
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
964
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
965 965
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
966 966
 			{
967 967
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
 		try {
978 978
 			$sth = $this->db->prepare($query);
979 979
 			$sth->execute($query_values);
980
-		} catch(PDOException $e) {
980
+		} catch (PDOException $e) {
981 981
 			echo "error : ".$e->getMessage();
982 982
 			return array();
983 983
 		}
@@ -985,39 +985,39 @@  discard block
 block discarded – undo
985 985
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
986 986
 			$data = array();
987 987
 			if ($row['registration'] != '') {
988
-				$row['registration'] = str_replace('.','',$row['registration']);
988
+				$row['registration'] = str_replace('.', '', $row['registration']);
989 989
 				$image_array = $Image->getSpotterImage($row['registration']);
990
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
991
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
992
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
990
+				if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
991
+				else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
992
+			} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
993 993
 			if ($row['registration'] == '') $row['registration'] = 'NA';
994 994
 			if ($row['ident'] == '') $row['ident'] = 'NA';
995
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
995
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
996 996
 			if (isset($identicao[0])) {
997
-				if (substr($row['ident'],0,2) == 'AF') {
998
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
999
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1000
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1001
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
997
+				if (substr($row['ident'], 0, 2) == 'AF') {
998
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
999
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1000
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1001
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1002 1002
 			} else $icao = $row['ident'];
1003
-			$icao = $Translation->checkTranslation($icao,false);
1004
-			$decode = json_decode($row['decode'],true);
1003
+			$icao = $Translation->checkTranslation($icao, false);
1004
+			$decode = json_decode($row['decode'], true);
1005 1005
 			$found = false;
1006
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1006
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1007 1007
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1008 1008
 				if (isset($airport_info[0]['icao'])) {
1009 1009
 					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1010 1010
 					$found = true;
1011 1011
 				}
1012 1012
 			}
1013
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1013
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1014 1014
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1015 1015
 				if (isset($airport_info[0]['icao'])) {
1016 1016
 					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1017 1017
 					$found = true;
1018 1018
 				}
1019 1019
 			}
1020
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1020
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1021 1021
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1022 1022
 				if (isset($airport_info[0]['icao'])) {
1023 1023
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 				}
1026 1026
 			}
1027 1027
 			if ($found) $row['decode'] = json_encode($decode);
1028
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1028
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1029 1029
 			$result[] = $data;
1030 1030
 			$i++;
1031 1031
 		}
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
      * @param string $label
1044 1044
      * @return array Return ACARS data in array
1045 1045
      */
1046
-	public function getArchiveAcarsData($limit = '',$label = '') {
1046
+	public function getArchiveAcarsData($limit = '', $label = '') {
1047 1047
 		global $globalURL;
1048 1048
 		$Image = new Image($this->db);
1049 1049
 		$Spotter = new Spotter($this->db);
@@ -1053,8 +1053,8 @@  discard block
 block discarded – undo
1053 1053
 		if ($limit != "")
1054 1054
 		{
1055 1055
 			$limit_array = explode(",", $limit);
1056
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1057
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1056
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1057
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1058 1058
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1059 1059
 			{
1060 1060
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -1075,45 +1075,45 @@  discard block
 block discarded – undo
1075 1075
 		try {
1076 1076
 			$sth = $this->db->prepare($query);
1077 1077
 			$sth->execute($query_values);
1078
-		} catch(PDOException $e) {
1078
+		} catch (PDOException $e) {
1079 1079
 			echo "error : ".$e->getMessage();
1080 1080
 			return array();
1081 1081
 		}
1082
-		$i=0;
1082
+		$i = 0;
1083 1083
 		$result = array();
1084 1084
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1085 1085
 			$data = array();
1086 1086
 			if ($row['registration'] != '') {
1087
-				$row['registration'] = str_replace('.','',$row['registration']);
1087
+				$row['registration'] = str_replace('.', '', $row['registration']);
1088 1088
 				$image_array = $Image->getSpotterImage($row['registration']);
1089
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1090
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1091
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1089
+				if (count($image_array) > 0) $data = array_merge($data, array('image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
1090
+				else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1091
+			} else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1092 1092
 			$icao = '';
1093 1093
 			if ($row['registration'] == '') $row['registration'] = 'NA';
1094 1094
 			if ($row['ident'] == '') $row['ident'] = 'NA';
1095
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1095
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
1096 1096
 			if (isset($identicao[0])) {
1097
-				if (substr($row['ident'],0,2) == 'AF') {
1098
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1099
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1100
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1101
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1097
+				if (substr($row['ident'], 0, 2) == 'AF') {
1098
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1099
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1100
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1101
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1102 1102
 			} else $icao = $row['ident'];
1103 1103
 			$icao = $Translation->checkTranslation($icao);
1104
-			$decode = json_decode($row['decode'],true);
1104
+			$decode = json_decode($row['decode'], true);
1105 1105
 			$found = false;
1106
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1106
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1107 1107
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1108 1108
 				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1109 1109
 				$found = true;
1110 1110
 			}
1111
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1111
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1112 1112
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1113 1113
 				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1114 1114
 				$found = true;
1115 1115
 			}
1116
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1116
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1117 1117
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1118 1118
 				if (isset($airport_info[0]['icao'])) {
1119 1119
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 				}
1122 1122
 			}
1123 1123
 			if ($found) $row['decode'] = json_encode($decode);
1124
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1124
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1125 1125
 			$result[] = $data;
1126 1126
 			$i++;
1127 1127
 		}
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
      * @param string $longitude
1143 1143
      * @return string
1144 1144
      */
1145
-	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1145
+	public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') {
1146 1146
 		global $globalDebug, $globalDBdriver;
1147 1147
 		$ident = trim($ident);
1148 1148
 		$Translation = new Translation($this->db);
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 			if ($globalDebug) echo "Ident or registration null, exit\n";
1156 1156
 			return '';
1157 1157
 		}
1158
-		$registration = str_replace('.','',$registration);
1158
+		$registration = str_replace('.', '', $registration);
1159 1159
 		$ident = $Translation->ident2icao($ident);
1160 1160
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1161 1161
 		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
 		try {
1165 1165
 			$sthsi = $this->db->prepare($querysi);
1166 1166
 			$sthsi->execute($querysi_values);
1167
-		} catch(PDOException $e) {
1167
+		} catch (PDOException $e) {
1168 1168
 			if ($globalDebug) echo $e->getMessage();
1169 1169
 			return "error : ".$e->getMessage();
1170 1170
 		}
@@ -1174,8 +1174,8 @@  discard block
 block discarded – undo
1174 1174
 			$Translation = new Translation($this->db);
1175 1175
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1176 1176
 			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1177
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1178
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1177
+			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS');
1178
+			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS');
1179 1179
 		} else {
1180 1180
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1181 1181
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
 				try {
1184 1184
 					$sth = $this->db->prepare($query);
1185 1185
 					$sth->execute($query_values);
1186
-				} catch(PDOException $e) {
1186
+				} catch (PDOException $e) {
1187 1187
 					if ($globalDebug) echo $e->getMessage();
1188 1188
 					return "error : ".$e->getMessage();
1189 1189
 				}
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
 				$sth->closeCursor();
1192 1192
 				if (isset($result['modes'])) $hex = $result['modes'];
1193 1193
 				else $hex = '';
1194
-				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1194
+				$SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS');
1195 1195
 				if ($this->fromACARSscript) $this->SI->add($SI_data);
1196 1196
 			}
1197 1197
 		}
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
 		try {
1202 1202
 			$sth = $this->db->prepare($query);
1203 1203
 			$sth->execute($query_values);
1204
-		} catch(PDOException $e) {
1204
+		} catch (PDOException $e) {
1205 1205
 			if ($globalDebug) echo $e->getMessage();
1206 1206
 			return "error : ".$e->getMessage();
1207 1207
 		}
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
 			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1212 1212
 			else $ModeS = '';
1213 1213
 			if ($ModeS == '') {
1214
-				$id = explode('-',$result['flightaware_id']);
1214
+				$id = explode('-', $result['flightaware_id']);
1215 1215
 				$ModeS = $id[0];
1216 1216
 			}
1217 1217
 			if ($ModeS != '') {
@@ -1221,20 +1221,20 @@  discard block
 block discarded – undo
1221 1221
 				try {
1222 1222
 					$sthc = $this->db->prepare($queryc);
1223 1223
 					$sthc->execute($queryc_values);
1224
-				} catch(PDOException $e) {
1224
+				} catch (PDOException $e) {
1225 1225
 					if ($globalDebug) echo $e->getMessage();
1226 1226
 					return "error : ".$e->getMessage();
1227 1227
 				}
1228 1228
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1229 1229
 				$sthc->closeCursor();
1230
-				if (count($row) ==  0) {
1230
+				if (count($row) == 0) {
1231 1231
 					if ($globalDebug) echo " Add to ModeS table - ";
1232 1232
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1233
-					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1233
+					$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1234 1234
 					try {
1235 1235
 						$sthi = $this->db->prepare($queryi);
1236 1236
 						$sthi->execute($queryi_values);
1237
-					} catch(PDOException $e) {
1237
+					} catch (PDOException $e) {
1238 1238
 						if ($globalDebug) echo $e->getMessage();
1239 1239
 						return "error : ".$e->getMessage();
1240 1240
 					}
@@ -1242,15 +1242,15 @@  discard block
 block discarded – undo
1242 1242
 					if ($globalDebug) echo " Update ModeS table - ";
1243 1243
 					if ($ICAOTypeCode != '') {
1244 1244
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1245
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1245
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1246 1246
 					} else {
1247 1247
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1248
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration);
1248
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration);
1249 1249
 					}
1250 1250
 					try {
1251 1251
 						$sthi = $this->db->prepare($queryi);
1252 1252
 						$sthi->execute($queryi_values);
1253
-					} catch(PDOException $e) {
1253
+					} catch (PDOException $e) {
1254 1254
 						if ($globalDebug) echo $e->getMessage();
1255 1255
 						return "error : ".$e->getMessage();
1256 1256
 					}
@@ -1287,12 +1287,12 @@  discard block
 block discarded – undo
1287 1287
 					elseif ($globalDBdriver == 'pgsql') {
1288 1288
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1289 1289
 					}
1290
-					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
1290
+					$queryi_values = array(':Registration' => $registration, ':ident' => $icao);
1291 1291
 				}
1292 1292
 				try {
1293 1293
 					$sthi = $this->db->prepare($queryi);
1294 1294
 					$sthi->execute($queryi_values);
1295
-				} catch(PDOException $e) {
1295
+				} catch (PDOException $e) {
1296 1296
 					if ($globalDebug) echo $e->getMessage();
1297 1297
 					return "error : ".$e->getMessage();
1298 1298
 				}
Please login to merge, or discard this patch.
Braces   +415 added lines, -263 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@  discard block
 block discarded – undo
24 24
 	public function __construct($dbc = null,$fromACARSscript = false) {
25 25
 		$Connection = new Connection($dbc);
26 26
 		$this->db = $Connection->db();
27
-		if ($this->db === null) die('Error: No DB connection. (ACARS)');
27
+		if ($this->db === null) {
28
+			die('Error: No DB connection. (ACARS)');
29
+		}
28 30
 		if ($fromACARSscript) {
29 31
 			$this->fromACARSscript = true;
30 32
 			$this->SI = new SpotterImport($this->db);
@@ -39,14 +41,19 @@  discard block
 block discarded – undo
39 41
 	*/
40 42
 	public function ident2icao($ident) {
41 43
 		if (substr($ident,0,2) == 'AF') {
42
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
43
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
44
+			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
45
+				$icao = $ident;
46
+			} else {
47
+				$icao = 'AFR'.ltrim(substr($ident,2),'0');
48
+			}
44 49
 		} else {
45 50
 			$Spotter = new Spotter($this->db);
46 51
 			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
47 52
 			if (isset($identicao[0])) {
48 53
 				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
49
-			} else $icao = $ident;
54
+			} else {
55
+				$icao = $ident;
56
+			}
50 57
 		}
51 58
 		return $icao;
52 59
 	}
@@ -120,14 +127,24 @@  discard block
 block discarded – undo
120 127
 		$message = '';
121 128
 		$result = array();
122 129
 		$n = sscanf($data,'%*[0-9a-z.] %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
123
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
124
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
125
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
130
+		if ($n == 0) {
131
+			$n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
132
+		}
133
+		if ($n == 0) {
134
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
135
+		}
136
+		if ($n == 0) {
137
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
138
+		}
126 139
 		if ($n != 0 && ($registration != '' || $ident != '' || $label != '' || $block_id != '' || $msg_no != '')) {
127 140
 			$registration = str_replace('.','',$registration);
128 141
 			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
129
-			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
130
-		} else $message = $data;
142
+			if ($globalDebug) {
143
+				echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
144
+			}
145
+		} else {
146
+			$message = $data;
147
+		}
131 148
 		$decode = array();
132 149
 		$found = false;
133 150
 //		if ($registration != '' && $ident != '' && $registration != '!') {
@@ -147,12 +164,21 @@  discard block
 block discarded – undo
147 164
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
148 165
 					$latitude = $la / 10000.0;
149 166
 					$longitude = $ln / 10000.0;
150
-					if ($lac == 'S') $latitude = '-'.$latitude;
151
-					if ($lnc == 'W') $longitude = '-'.$longitude;
167
+					if ($lac == 'S') {
168
+						$latitude = '-'.$latitude;
169
+					}
170
+					if ($lnc == 'W') {
171
+						$longitude = '-'.$longitude;
172
+					}
152 173
 					// Temp not always available
153
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
154
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
155
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
174
+					if ($globalDebug) {
175
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
176
+					}
177
+					if ($temp == '') {
178
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
179
+					} else {
180
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
181
+					}
156 182
 
157 183
 					//$icao = $Translation->checkTranslation($ident);
158 184
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -166,25 +192,35 @@  discard block
 block discarded – undo
166 192
 				$ahour = '';
167 193
 				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
168 194
 				if ($n == 4 && strlen($darr) == 4) {
169
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
170
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
171
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
195
+					if ($dhour != '') {
196
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
197
+					}
198
+					if ($ahour != '') {
199
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
200
+					}
201
+					if ($globalDebug) {
202
+						echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
203
+					}
172 204
 					//$icao = ACARS->ident2icao($ident);
173 205
 					//$icao = $Translation->checkTranslation($ident);
174 206
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
175 207
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
176 208
 					$found = true;
177
-				}
178
-				elseif ($n == 2 || $n  == 4) {
179
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
180
-					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
209
+				} elseif ($n == 2 || $n  == 4) {
210
+					if ($dhour != '') {
211
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
212
+					}
213
+					if ($globalDebug) {
214
+						echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
215
+					}
181 216
 					//$icao = ACARS->ident2icao($ident);
182 217
 					//$icao = $Translation->checkTranslation($ident);
183 218
 					$decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour);
184 219
 					$found = true;
185
-				}
186
-				elseif ($n == 1) {
187
-					if ($globalDebug) echo 'airport arrival : '.$darr."\n";
220
+				} elseif ($n == 1) {
221
+					if ($globalDebug) {
222
+						echo 'airport arrival : '.$darr."\n";
223
+					}
188 224
 					//$icao = ACARS->ident2icao($ident);
189 225
 					//$icao = $Translation->checkTranslation($ident);
190 226
 					$decode = array('Arrival airport' => $darr);
@@ -202,7 +238,9 @@  discard block
 block discarded – undo
202 238
 				$darr = '';
203 239
 				$n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr);
204 240
 				if ($n == 4) {
205
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
241
+					if ($globalDebug) {
242
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
243
+					}
206 244
 					//$icao = ACARS->ident2icao($ident);
207 245
 					//$icao = $Translation->checkTranslation($ident);
208 246
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -236,14 +274,23 @@  discard block
 block discarded – undo
236 274
 				$apiste = '';
237 275
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
238 276
 				if ($n > 8) {
239
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
240
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
241
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
277
+					if ($globalDebug) {
278
+						echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
279
+					}
280
+					if ($dhour != '') {
281
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
282
+					}
283
+					if ($ahour != '') {
284
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
285
+					}
242 286
 					$icao = trim($aident);
243 287
 
244 288
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
245
-					if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
246
-					else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
289
+					if ($ahour == '') {
290
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
291
+					} else {
292
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
293
+					}
247 294
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
248 295
 					$decode['icao'] = $icao;
249 296
 					$found = true;
@@ -265,9 +312,15 @@  discard block
 block discarded – undo
265 312
 					$lns = $lns.'.'.$lns;
266 313
 					$latitude = $las / 1000.0;
267 314
 					$longitude = $lns / 1000.0;
268
-					if ($lac == 'S') $latitude = '-'.$latitude;
269
-					if ($lnc == 'W') $longitude = '-'.$longitude;
270
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
315
+					if ($lac == 'S') {
316
+						$latitude = '-'.$latitude;
317
+					}
318
+					if ($lnc == 'W') {
319
+						$longitude = '-'.$longitude;
320
+					}
321
+					if ($globalDebug) {
322
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
323
+					}
271 324
 					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
272 325
 					$found = true;
273 326
 				}
@@ -285,7 +338,9 @@  discard block
 block discarded – undo
285 338
 				$darr = '';
286 339
 				$n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr);
287 340
 				if ($n == 4) {
288
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
341
+					if ($globalDebug) {
342
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
343
+					}
289 344
 					//$icao = $Translation->checkTranslation($ident);
290 345
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
291 346
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -298,7 +353,9 @@  discard block
 block discarded – undo
298 353
 				$darr = '';
299 354
 				$n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr);
300 355
 				if ($n == 4) {
301
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
356
+					if ($globalDebug) {
357
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
358
+					}
302 359
 					//$icao = $Translation->checkTranslation($ident);
303 360
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
304 361
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -311,7 +368,9 @@  discard block
 block discarded – undo
311 368
 				$darr = '';
312 369
 				$n = sscanf($message, "002AF %4c %4c ", $dair, $darr);
313 370
 				if ($n == 2) {
314
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
371
+					if ($globalDebug) {
372
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
373
+					}
315 374
 					//$icao = $Translation->checkTranslation($ident);
316 375
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
317 376
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -325,7 +384,9 @@  discard block
 block discarded – undo
325 384
 				$darr = '';
326 385
 				$n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
327 386
 				if ($n == 6) {
328
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
387
+					if ($globalDebug) {
388
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
389
+					}
329 390
 					//$icao = $Translation->checkTranslation($ident);
330 391
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
331 392
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -338,7 +399,9 @@  discard block
 block discarded – undo
338 399
 				$darr = '';
339 400
 				$n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
340 401
 				if ($n == 7) {
341
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
402
+					if ($globalDebug) {
403
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
404
+					}
342 405
 					//$icao = $Translation->checkTranslation($ident);
343 406
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
344 407
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -366,8 +429,12 @@  discard block
 block discarded – undo
366 429
 					$decode['icao'] = $icao;
367 430
 					$latitude = $las / 100.0;
368 431
 					$longitude = $lns / 100.0;
369
-					if ($lac == 'S') $latitude = '-'.$latitude;
370
-					if ($lnc == 'W') $longitude = '-'.$longitude;
432
+					if ($lac == 'S') {
433
+						$latitude = '-'.$latitude;
434
+					}
435
+					if ($lnc == 'W') {
436
+						$longitude = '-'.$longitude;
437
+					}
371 438
 
372 439
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
373 440
 					$found = true;
@@ -385,8 +452,12 @@  discard block
 block discarded – undo
385 452
 				if ($n == 4) {
386 453
 					$latitude = $las;
387 454
 					$longitude = $lns;
388
-					if ($lac == 'S') $latitude = '-'.$latitude;
389
-					if ($lnc == 'W') $longitude = '-'.$longitude;
455
+					if ($lac == 'S') {
456
+						$latitude = '-'.$latitude;
457
+					}
458
+					if ($lnc == 'W') {
459
+						$longitude = '-'.$longitude;
460
+					}
390 461
 
391 462
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
392 463
 					$found = true;
@@ -402,7 +473,9 @@  discard block
 block discarded – undo
402 473
 				$darr = '';
403 474
 				$n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr);
404 475
 				if ($n == 5) {
405
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
476
+					if ($globalDebug) {
477
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
478
+					}
406 479
 					//$icao = $Translation->checkTranslation($ident);
407 480
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
408 481
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -423,7 +496,9 @@  discard block
 block discarded – undo
423 496
 				$aident = '';
424 497
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
425 498
 				if ($n == 8) {
426
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
499
+					if ($globalDebug) {
500
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
501
+					}
427 502
 					$icao = trim($aident);
428 503
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
429 504
 					$decode['icao'] = $icao;
@@ -440,7 +515,9 @@  discard block
 block discarded – undo
440 515
 				$darr = '';
441 516
 				$n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr);
442 517
 				if ($n == 5) {
443
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
518
+					if ($globalDebug) {
519
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
520
+					}
444 521
 					//$icao = $Translation->checkTranslation($ident);
445 522
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
446 523
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -455,7 +532,9 @@  discard block
 block discarded – undo
455 532
 				$darr = '';
456 533
 				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
457 534
 				if ($n == 3) {
458
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
535
+					if ($globalDebug) {
536
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
537
+					}
459 538
 					//$icao = $Translation->checkTranslation($ident);
460 539
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
461 540
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -470,7 +549,9 @@  discard block
 block discarded – undo
470 549
 				$darr = '';
471 550
 				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
472 551
 				if ($n == 3) {
473
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
552
+					if ($globalDebug) {
553
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
554
+					}
474 555
 					//$icao = $Translation->checkTranslation($ident);
475 556
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
476 557
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -480,7 +561,9 @@  discard block
 block discarded – undo
480 561
 			if (!$found) {
481 562
 				$n = sscanf($message,'MET01%4c',$airport);
482 563
 				if ($n == 1) {
483
-					if ($globalDebug) echo 'airport name : '.$airport;
564
+					if ($globalDebug) {
565
+						echo 'airport name : '.$airport;
566
+					}
484 567
 					$decode = array('Airport/Waypoint name' => $airport);
485 568
 					$found = true;
486 569
 				}
@@ -488,184 +571,126 @@  discard block
 block discarded – undo
488 571
 			if ($label == 'H1') {
489 572
 				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
490 573
 					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
491
-				}
492
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
574
+				} elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
493 575
 					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
494
-				}
495
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
576
+				} elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
496 577
 					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
497
-				}
498
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
578
+				} elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
499 579
 					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
500
-				}
501
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
580
+				} elseif (preg_match(':^#DFB/PIREP:',$message)) {
502 581
 					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
503
-				}
504
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
582
+				} elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
505 583
 					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
506
-				}
507
-				elseif (preg_match(':^#M1AAEP:',$message)) {
584
+				} elseif (preg_match(':^#M1AAEP:',$message)) {
508 585
 					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
509
-				}
510
-				elseif (preg_match(':^#M2APWD:',$message)) {
586
+				} elseif (preg_match(':^#M2APWD:',$message)) {
511 587
 					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
512
-				}
513
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
588
+				} elseif (preg_match(':^#M1BREQPWI:',$message)) {
514 589
 					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
515
-				}
516
-				elseif (preg_match(':^#CF:',$message)) {
590
+				} elseif (preg_match(':^#CF:',$message)) {
517 591
 					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
518
-				}
519
-				elseif (preg_match(':^#DF:',$message)) {
592
+				} elseif (preg_match(':^#DF:',$message)) {
520 593
 					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
521
-				}
522
-				elseif (preg_match(':^#EC:',$message)) {
594
+				} elseif (preg_match(':^#EC:',$message)) {
523 595
 					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
524
-				}
525
-				elseif (preg_match(':^#EI:',$message)) {
596
+				} elseif (preg_match(':^#EI:',$message)) {
526 597
 					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
527
-				}
528
-				elseif (preg_match(':^#H1:',$message)) {
598
+				} elseif (preg_match(':^#H1:',$message)) {
529 599
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
530
-				}
531
-				elseif (preg_match(':^#H2:',$message)) {
600
+				} elseif (preg_match(':^#H2:',$message)) {
532 601
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
533
-				}
534
-				elseif (preg_match(':^#HD:',$message)) {
602
+				} elseif (preg_match(':^#HD:',$message)) {
535 603
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
536
-				}
537
-				elseif (preg_match(':^#M1:',$message)) {
604
+				} elseif (preg_match(':^#M1:',$message)) {
538 605
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
539
-				}
540
-				elseif (preg_match(':^#M2:',$message)) {
606
+				} elseif (preg_match(':^#M2:',$message)) {
541 607
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
542
-				}
543
-				elseif (preg_match(':^#M3:',$message)) {
608
+				} elseif (preg_match(':^#M3:',$message)) {
544 609
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
545
-				}
546
-				elseif (preg_match(':^#MD:',$message)) {
610
+				} elseif (preg_match(':^#MD:',$message)) {
547 611
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
548
-				}
549
-				elseif (preg_match(':^#PS:',$message)) {
612
+				} elseif (preg_match(':^#PS:',$message)) {
550 613
 					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
551
-				}
552
-				elseif (preg_match(':^#S1:',$message)) {
614
+				} elseif (preg_match(':^#S1:',$message)) {
553 615
 					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
554
-				}
555
-				elseif (preg_match(':^#S2:',$message)) {
616
+				} elseif (preg_match(':^#S2:',$message)) {
556 617
 					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
557
-				}
558
-				elseif (preg_match(':^#SD:',$message)) {
618
+				} elseif (preg_match(':^#SD:',$message)) {
559 619
 					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
560
-				}
561
-				elseif (preg_match(':^#T[0-8]:',$message)) {
620
+				} elseif (preg_match(':^#T[0-8]:',$message)) {
562 621
 					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
563
-				}
564
-				elseif (preg_match(':^#WO:',$message)) {
622
+				} elseif (preg_match(':^#WO:',$message)) {
565 623
 					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
566
-				}
567
-				elseif (preg_match(':^#A1:',$message)) {
624
+				} elseif (preg_match(':^#A1:',$message)) {
568 625
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
569
-				}
570
-				elseif (preg_match(':^#A3:',$message)) {
626
+				} elseif (preg_match(':^#A3:',$message)) {
571 627
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
572
-				}
573
-				elseif (preg_match(':^#A4:',$message)) {
628
+				} elseif (preg_match(':^#A4:',$message)) {
574 629
 					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
575
-				}
576
-				elseif (preg_match(':^#A6:',$message)) {
630
+				} elseif (preg_match(':^#A6:',$message)) {
577 631
 					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
578
-				}
579
-				elseif (preg_match(':^#A8:',$message)) {
632
+				} elseif (preg_match(':^#A8:',$message)) {
580 633
 					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
581
-				}
582
-				elseif (preg_match(':^#A9:',$message)) {
634
+				} elseif (preg_match(':^#A9:',$message)) {
583 635
 					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
584
-				}
585
-				elseif (preg_match(':^#A0:',$message)) {
636
+				} elseif (preg_match(':^#A0:',$message)) {
586 637
 					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
587
-				}
588
-				elseif (preg_match(':^#AA:',$message)) {
638
+				} elseif (preg_match(':^#AA:',$message)) {
589 639
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
590
-				}
591
-				elseif (preg_match(':^#AB:',$message)) {
640
+				} elseif (preg_match(':^#AB:',$message)) {
592 641
 					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
593
-				}
594
-				elseif (preg_match(':^#AC:',$message)) {
642
+				} elseif (preg_match(':^#AC:',$message)) {
595 643
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
596
-				}
597
-				elseif (preg_match(':^#AD:',$message)) {
644
+				} elseif (preg_match(':^#AD:',$message)) {
598 645
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
599
-				}
600
-				elseif (preg_match(':^#AF:',$message)) {
646
+				} elseif (preg_match(':^#AF:',$message)) {
601 647
 					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
602
-				}
603
-				elseif (preg_match(':^#B1:',$message)) {
648
+				} elseif (preg_match(':^#B1:',$message)) {
604 649
 					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
605
-				}
606
-				elseif (preg_match(':^#B2:',$message)) {
650
+				} elseif (preg_match(':^#B2:',$message)) {
607 651
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
608
-				}
609
-				elseif (preg_match(':^#B3:',$message)) {
652
+				} elseif (preg_match(':^#B3:',$message)) {
610 653
 					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
611
-				}
612
-				elseif (preg_match(':^#B4:',$message)) {
654
+				} elseif (preg_match(':^#B4:',$message)) {
613 655
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
614
-				}
615
-				elseif (preg_match(':^#B6:',$message)) {
656
+				} elseif (preg_match(':^#B6:',$message)) {
616 657
 					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
617
-				}
618
-				elseif (preg_match(':^#B8:',$message)) {
658
+				} elseif (preg_match(':^#B8:',$message)) {
619 659
 					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
620
-				}
621
-				elseif (preg_match(':^#B9:',$message)) {
660
+				} elseif (preg_match(':^#B9:',$message)) {
622 661
 					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
623
-				}
624
-				elseif (preg_match(':^#B0:',$message)) {
662
+				} elseif (preg_match(':^#B0:',$message)) {
625 663
 					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
626
-				}
627
-				elseif (preg_match(':^#BA:',$message)) {
664
+				} elseif (preg_match(':^#BA:',$message)) {
628 665
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
629
-				}
630
-				elseif (preg_match(':^#BB:',$message)) {
666
+				} elseif (preg_match(':^#BB:',$message)) {
631 667
 					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
632
-				}
633
-				elseif (preg_match(':^#BC:',$message)) {
668
+				} elseif (preg_match(':^#BC:',$message)) {
634 669
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
635
-				}
636
-				elseif (preg_match(':^#BD:',$message)) {
670
+				} elseif (preg_match(':^#BD:',$message)) {
637 671
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
638
-				}
639
-				elseif (preg_match(':^#BE:',$message)) {
672
+				} elseif (preg_match(':^#BE:',$message)) {
640 673
 					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
641
-				}
642
-				elseif (preg_match(':^#BF:',$message)) {
674
+				} elseif (preg_match(':^#BF:',$message)) {
643 675
 					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
644
-				}
645
-				elseif (preg_match(':^#H3:',$message)) {
676
+				} elseif (preg_match(':^#H3:',$message)) {
646 677
 					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
647 678
 				}
648 679
 			}
649 680
 			if ($label == '10') {
650 681
 				if (preg_match(':^DTO01:',$message)) {
651 682
 					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
652
-				}
653
-				elseif (preg_match(':^AIS01:',$message)) {
683
+				} elseif (preg_match(':^AIS01:',$message)) {
654 684
 					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
655
-				}
656
-				elseif (preg_match(':^FTX01:',$message)) {
685
+				} elseif (preg_match(':^FTX01:',$message)) {
657 686
 					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
658
-				}
659
-				elseif (preg_match(':^FPL01:',$message)) {
687
+				} elseif (preg_match(':^FPL01:',$message)) {
660 688
 					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
661
-				}
662
-				elseif (preg_match(':^WAB01:',$message)) {
689
+				} elseif (preg_match(':^WAB01:',$message)) {
663 690
 					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
664
-				}
665
-				elseif (preg_match(':^MET01:',$message)) {
691
+				} elseif (preg_match(':^MET01:',$message)) {
666 692
 					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
667
-				}
668
-				elseif (preg_match(':^WAB02:',$message)) {
693
+				} elseif (preg_match(':^WAB02:',$message)) {
669 694
 					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
670 695
 				}
671 696
 			}
@@ -680,38 +705,28 @@  discard block
 block discarded – undo
680 705
 					$vsta = array('Version' => $version);
681 706
 					if ($state == 'E') {
682 707
 						$vsta = array_merge($vsta,array('Link state' => 'Established'));
683
-					}
684
-					elseif ($state == 'L') {
708
+					} elseif ($state == 'L') {
685 709
 						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
686
-					}
687
-					else {
710
+					} else {
688 711
 						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
689 712
 					}
690 713
 					if ($type == 'V') {
691 714
 						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
692
-					}
693
-					elseif ($type == 'S') {
715
+					} elseif ($type == 'S') {
694 716
 						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
695
-					}
696
-					elseif ($type == 'H') {
717
+					} elseif ($type == 'H') {
697 718
 						$vsta = array_merge($vsta,array('Link type' => 'HF'));
698
-					}
699
-					elseif ($type == 'G') {
719
+					} elseif ($type == 'G') {
700 720
 						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
701
-					}
702
-					elseif ($type == 'C') {
721
+					} elseif ($type == 'C') {
703 722
 						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
704
-					}
705
-					elseif ($type == '2') {
723
+					} elseif ($type == '2') {
706 724
 						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
707
-					}
708
-					elseif ($type == 'X') {
725
+					} elseif ($type == 'X') {
709 726
 						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
710
-					}
711
-					elseif ($type == 'I') {
727
+					} elseif ($type == 'I') {
712 728
 						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
713
-					}
714
-					else {
729
+					} else {
715 730
 						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
716 731
 					}
717 732
 					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
@@ -720,7 +735,9 @@  discard block
 block discarded – undo
720 735
 			}
721 736
 
722 737
 			$title = $this->getTitlefromLabel($label);
723
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
738
+			if ($title != '') {
739
+				$decode = array_merge(array('Message title' => $title),$decode);
740
+			}
724 741
 			/*
725 742
 			// Business jets always use GS0001
726 743
 			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
@@ -756,31 +773,54 @@  discard block
 block discarded – undo
756 773
 			$msg = $message['message'];
757 774
 			$decode = $message['decode'];
758 775
 			$registration = (string)$message['registration'];
759
-			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
760
-			else $latitude = '';
761
-			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
762
-			else $longitude = '';
763
-			if (isset($decode['airicao'])) $airicao = $decode['airicao'];
764
-			else $airicao = '';
765
-			if (isset($decode['icao'])) $icao = $decode['icao'];
766
-			else $icao = $Translation->checkTranslation($ident);
776
+			if (isset($decode['latitude'])) {
777
+				$latitude = $decode['latitude'];
778
+			} else {
779
+				$latitude = '';
780
+			}
781
+			if (isset($decode['longitude'])) {
782
+				$longitude = $decode['longitude'];
783
+			} else {
784
+				$longitude = '';
785
+			}
786
+			if (isset($decode['airicao'])) {
787
+				$airicao = $decode['airicao'];
788
+			} else {
789
+				$airicao = '';
790
+			}
791
+			if (isset($decode['icao'])) {
792
+				$icao = $decode['icao'];
793
+			} else {
794
+				$icao = $Translation->checkTranslation($ident);
795
+			}
767 796
 			$image_array = $Image->getSpotterImage($registration);
768 797
 			if (!isset($image_array[0]['registration'])) {
769 798
 				$Image->addSpotterImage($registration);
770 799
 			}
771 800
 			// Business jets always use GS0001
772
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
773
-			if ($globalDebug && isset($info) && $info != '') echo $info;
774
-			if (count($decode) > 0) $decode_json = json_encode($decode);
775
-			else $decode_json = '';
801
+			if ($ident != 'GS0001') {
802
+				$info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
803
+			}
804
+			if ($globalDebug && isset($info) && $info != '') {
805
+				echo $info;
806
+			}
807
+			if (count($decode) > 0) {
808
+				$decode_json = json_encode($decode);
809
+			} else {
810
+				$decode_json = '';
811
+			}
776 812
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
777 813
 				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
778 814
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
779 815
 				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
780 816
 			}
781 817
 			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
782
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
783
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
818
+			if (!isset($globalACARSArchive)) {
819
+				$globalACARSArchive = array('10','80','81','82','3F');
820
+			}
821
+			if ($result && in_array($label,$globalACARSArchive)) {
822
+				$this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
823
+			}
784 824
 			if ($globalDebug && count($decode) > 0) {
785 825
 				echo "Human readable data : ".implode(' - ',$decode)."\n";
786 826
 			}
@@ -805,7 +845,9 @@  discard block
 block discarded – undo
805 845
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
806 846
 			$Connection = new Connection($this->db);
807 847
 			$this->db = $Connection->db;
808
-			if ($globalDebug) echo "Test if not already in Live ACARS table...";
848
+			if ($globalDebug) {
849
+				echo "Test if not already in Live ACARS table...";
850
+			}
809 851
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
810 852
 			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
811 853
 			try {
@@ -816,7 +858,9 @@  discard block
 block discarded – undo
816 858
 				return false;
817 859
 			}
818 860
 			if ($stht->fetchColumn() == 0) {
819
-				if ($globalDebug) echo "Add Live ACARS data...";
861
+				if ($globalDebug) {
862
+					echo "Add Live ACARS data...";
863
+				}
820 864
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
821 865
 				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
822 866
 				try {
@@ -827,10 +871,14 @@  discard block
 block discarded – undo
827 871
 					return false;
828 872
 				}
829 873
 			} else {
830
-				if ($globalDebug) echo "Data already in DB...\n";
874
+				if ($globalDebug) {
875
+					echo "Data already in DB...\n";
876
+				}
831 877
 				return false;
832 878
 			}
833
-			if ($globalDebug) echo "Done\n";
879
+			if ($globalDebug) {
880
+				echo "Done\n";
881
+			}
834 882
 			return true;
835 883
 		}
836 884
 		return false;
@@ -864,7 +912,9 @@  discard block
 block discarded – undo
864 912
 			    	    }
865 913
 				    if ($stht->fetchColumn() == 0) {
866 914
 			*/
867
-			if ($globalDebug) echo "Add Live ACARS data...";
915
+			if ($globalDebug) {
916
+				echo "Add Live ACARS data...";
917
+			}
868 918
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
869 919
 			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
870 920
 			try {
@@ -873,7 +923,9 @@  discard block
 block discarded – undo
873 923
 			} catch(PDOException $e) {
874 924
 				return "error : ".$e->getMessage();
875 925
 			}
876
-			if ($globalDebug) echo "Done\n";
926
+			if ($globalDebug) {
927
+				echo "Done\n";
928
+			}
877 929
 		}
878 930
 		return '';
879 931
 	}
@@ -897,8 +949,11 @@  discard block
 block discarded – undo
897 949
 			return '';
898 950
 		}
899 951
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
900
-		if (count($row) > 0) return $row[0]['title'];
901
-		else return '';
952
+		if (count($row) > 0) {
953
+			return $row[0]['title'];
954
+		} else {
955
+			return '';
956
+		}
902 957
 	}
903 958
 
904 959
 	/**
@@ -917,8 +972,11 @@  discard block
 block discarded – undo
917 972
 			return array();
918 973
 		}
919 974
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
920
-		if (count($row) > 0) return $row;
921
-		else return array();
975
+		if (count($row) > 0) {
976
+			return $row;
977
+		} else {
978
+			return array();
979
+		}
922 980
 	}
923 981
 
924 982
 	/**
@@ -938,8 +996,11 @@  discard block
 block discarded – undo
938 996
 			return array();
939 997
 		}
940 998
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
941
-		if (count($row) > 0) return $row[0];
942
-		else return array();
999
+		if (count($row) > 0) {
1000
+			return $row[0];
1001
+		} else {
1002
+			return array();
1003
+		}
943 1004
 	}
944 1005
 
945 1006
     /**
@@ -987,19 +1048,35 @@  discard block
 block discarded – undo
987 1048
 			if ($row['registration'] != '') {
988 1049
 				$row['registration'] = str_replace('.','',$row['registration']);
989 1050
 				$image_array = $Image->getSpotterImage($row['registration']);
990
-				if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
991
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
992
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
993
-			if ($row['registration'] == '') $row['registration'] = 'NA';
994
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1051
+				if (count($image_array) > 0) {
1052
+					$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1053
+				} else {
1054
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1055
+				}
1056
+			} else {
1057
+				$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1058
+			}
1059
+			if ($row['registration'] == '') {
1060
+				$row['registration'] = 'NA';
1061
+			}
1062
+			if ($row['ident'] == '') {
1063
+				$row['ident'] = 'NA';
1064
+			}
995 1065
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
996 1066
 			if (isset($identicao[0])) {
997 1067
 				if (substr($row['ident'],0,2) == 'AF') {
998
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
999
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1000
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1068
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1069
+						$icao = $row['ident'];
1070
+					} else {
1071
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1072
+					}
1073
+				} else {
1074
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1075
+				}
1001 1076
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1002
-			} else $icao = $row['ident'];
1077
+			} else {
1078
+				$icao = $row['ident'];
1079
+			}
1003 1080
 			$icao = $Translation->checkTranslation($icao,false);
1004 1081
 			$decode = json_decode($row['decode'],true);
1005 1082
 			$found = false;
@@ -1024,7 +1101,9 @@  discard block
 block discarded – undo
1024 1101
 					$found = true;
1025 1102
 				}
1026 1103
 			}
1027
-			if ($found) $row['decode'] = json_encode($decode);
1104
+			if ($found) {
1105
+				$row['decode'] = json_encode($decode);
1106
+			}
1028 1107
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1029 1108
 			$result[] = $data;
1030 1109
 			$i++;
@@ -1032,8 +1111,9 @@  discard block
 block discarded – undo
1032 1111
 		if (isset($result)) {
1033 1112
 			$result[0]['query_number_rows'] = $i;
1034 1113
 			return $result;
1114
+		} else {
1115
+			return array();
1035 1116
 		}
1036
-		else return array();
1037 1117
 	}
1038 1118
 
1039 1119
     /**
@@ -1086,31 +1166,51 @@  discard block
 block discarded – undo
1086 1166
 			if ($row['registration'] != '') {
1087 1167
 				$row['registration'] = str_replace('.','',$row['registration']);
1088 1168
 				$image_array = $Image->getSpotterImage($row['registration']);
1089
-				if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1090
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1091
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1169
+				if (count($image_array) > 0) {
1170
+					$data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
1171
+				} else {
1172
+					$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1173
+				}
1174
+			} else {
1175
+				$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1176
+			}
1092 1177
 			$icao = '';
1093
-			if ($row['registration'] == '') $row['registration'] = 'NA';
1094
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1178
+			if ($row['registration'] == '') {
1179
+				$row['registration'] = 'NA';
1180
+			}
1181
+			if ($row['ident'] == '') {
1182
+				$row['ident'] = 'NA';
1183
+			}
1095 1184
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1096 1185
 			if (isset($identicao[0])) {
1097 1186
 				if (substr($row['ident'],0,2) == 'AF') {
1098
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1099
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1100
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1187
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1188
+						$icao = $row['ident'];
1189
+					} else {
1190
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1191
+					}
1192
+				} else {
1193
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1194
+				}
1101 1195
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1102
-			} else $icao = $row['ident'];
1196
+			} else {
1197
+				$icao = $row['ident'];
1198
+			}
1103 1199
 			$icao = $Translation->checkTranslation($icao);
1104 1200
 			$decode = json_decode($row['decode'],true);
1105 1201
 			$found = false;
1106 1202
 			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1107 1203
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1108
-				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1204
+				if (isset($airport_info[0]['icao'])) {
1205
+					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1206
+				}
1109 1207
 				$found = true;
1110 1208
 			}
1111 1209
 			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1112 1210
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1113
-				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1211
+				if (isset($airport_info[0]['icao'])) {
1212
+					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1213
+				}
1114 1214
 				$found = true;
1115 1215
 			}
1116 1216
 			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
@@ -1120,7 +1220,9 @@  discard block
 block discarded – undo
1120 1220
 					$found = true;
1121 1221
 				}
1122 1222
 			}
1123
-			if ($found) $row['decode'] = json_encode($decode);
1223
+			if ($found) {
1224
+				$row['decode'] = json_encode($decode);
1225
+			}
1124 1226
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1125 1227
 			$result[] = $data;
1126 1228
 			$i++;
@@ -1128,7 +1230,9 @@  discard block
 block discarded – undo
1128 1230
 		if (!empty($result)) {
1129 1231
 			$result[0]['query_number_rows'] = $i;
1130 1232
 			return $result;
1131
-		} else return array();
1233
+		} else {
1234
+			return array();
1235
+		}
1132 1236
 	}
1133 1237
 
1134 1238
     /**
@@ -1147,25 +1251,37 @@  discard block
 block discarded – undo
1147 1251
 		$ident = trim($ident);
1148 1252
 		$Translation = new Translation($this->db);
1149 1253
 		$Spotter = new Spotter($this->db);
1150
-		if ($globalDebug) echo "Test if we add ModeS data...";
1254
+		if ($globalDebug) {
1255
+			echo "Test if we add ModeS data...";
1256
+		}
1151 1257
 		//if ($icao == '') $icao = ACARS->ident2icao($ident);
1152
-		if ($icao == '') $icao = $Translation->checkTranslation($ident);
1153
-		if ($globalDebug) echo '- Ident : '.$icao.' - ';
1258
+		if ($icao == '') {
1259
+			$icao = $Translation->checkTranslation($ident);
1260
+		}
1261
+		if ($globalDebug) {
1262
+			echo '- Ident : '.$icao.' - ';
1263
+		}
1154 1264
 		if ($ident == '' || $registration == '') {
1155
-			if ($globalDebug) echo "Ident or registration null, exit\n";
1265
+			if ($globalDebug) {
1266
+				echo "Ident or registration null, exit\n";
1267
+			}
1156 1268
 			return '';
1157 1269
 		}
1158 1270
 		$registration = str_replace('.','',$registration);
1159 1271
 		$ident = $Translation->ident2icao($ident);
1160 1272
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1161
-		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
1273
+		if ($globalDebug) {
1274
+			echo "Check if needed to add translation ".$ident.'... ';
1275
+		}
1162 1276
 		$querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration AND s.format_source <> 'ACARS' LIMIT 1";
1163 1277
 		$querysi_values = array(':registration' => $registration);
1164 1278
 		try {
1165 1279
 			$sthsi = $this->db->prepare($querysi);
1166 1280
 			$sthsi->execute($querysi_values);
1167 1281
 		} catch(PDOException $e) {
1168
-			if ($globalDebug) echo $e->getMessage();
1282
+			if ($globalDebug) {
1283
+				echo $e->getMessage();
1284
+			}
1169 1285
 			return "error : ".$e->getMessage();
1170 1286
 		}
1171 1287
 		$resultsi = $sthsi->fetch(PDO::FETCH_ASSOC);
@@ -1173,9 +1289,14 @@  discard block
 block discarded – undo
1173 1289
 		if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') {
1174 1290
 			$Translation = new Translation($this->db);
1175 1291
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1176
-			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1177
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1178
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1292
+			if ($globalDebug) {
1293
+				echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1294
+			}
1295
+			if ($ident != $trans_ident) {
1296
+				$Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1297
+			} elseif ($trans_ident == $ident) {
1298
+				$Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1299
+			}
1179 1300
 		} else {
1180 1301
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1181 1302
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1184,32 +1305,46 @@  discard block
 block discarded – undo
1184 1305
 					$sth = $this->db->prepare($query);
1185 1306
 					$sth->execute($query_values);
1186 1307
 				} catch(PDOException $e) {
1187
-					if ($globalDebug) echo $e->getMessage();
1308
+					if ($globalDebug) {
1309
+						echo $e->getMessage();
1310
+					}
1188 1311
 					return "error : ".$e->getMessage();
1189 1312
 				}
1190 1313
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
1191 1314
 				$sth->closeCursor();
1192
-				if (isset($result['modes'])) $hex = $result['modes'];
1193
-				else $hex = '';
1315
+				if (isset($result['modes'])) {
1316
+					$hex = $result['modes'];
1317
+				} else {
1318
+					$hex = '';
1319
+				}
1194 1320
 				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1195
-				if ($this->fromACARSscript) $this->SI->add($SI_data);
1321
+				if ($this->fromACARSscript) {
1322
+					$this->SI->add($SI_data);
1323
+				}
1196 1324
 			}
1197 1325
 		}
1198
-		if ($globalDebug) echo 'Done'."\n";
1326
+		if ($globalDebug) {
1327
+			echo 'Done'."\n";
1328
+		}
1199 1329
 		$query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1";
1200 1330
 		$query_values = array(':ident' => $icao);
1201 1331
 		try {
1202 1332
 			$sth = $this->db->prepare($query);
1203 1333
 			$sth->execute($query_values);
1204 1334
 		} catch(PDOException $e) {
1205
-			if ($globalDebug) echo $e->getMessage();
1335
+			if ($globalDebug) {
1336
+				echo $e->getMessage();
1337
+			}
1206 1338
 			return "error : ".$e->getMessage();
1207 1339
 		}
1208 1340
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
1209 1341
 		$sth->closeCursor();
1210 1342
 		if (isset($result['flightaware_id'])) {
1211
-			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1212
-			else $ModeS = '';
1343
+			if (isset($result['ModeS'])) {
1344
+				$ModeS = $result['ModeS'];
1345
+			} else {
1346
+				$ModeS = '';
1347
+			}
1213 1348
 			if ($ModeS == '') {
1214 1349
 				$id = explode('-',$result['flightaware_id']);
1215 1350
 				$ModeS = $id[0];
@@ -1222,24 +1357,32 @@  discard block
 block discarded – undo
1222 1357
 					$sthc = $this->db->prepare($queryc);
1223 1358
 					$sthc->execute($queryc_values);
1224 1359
 				} catch(PDOException $e) {
1225
-					if ($globalDebug) echo $e->getMessage();
1360
+					if ($globalDebug) {
1361
+						echo $e->getMessage();
1362
+					}
1226 1363
 					return "error : ".$e->getMessage();
1227 1364
 				}
1228 1365
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1229 1366
 				$sthc->closeCursor();
1230 1367
 				if (count($row) ==  0) {
1231
-					if ($globalDebug) echo " Add to ModeS table - ";
1368
+					if ($globalDebug) {
1369
+						echo " Add to ModeS table - ";
1370
+					}
1232 1371
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1233 1372
 					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1234 1373
 					try {
1235 1374
 						$sthi = $this->db->prepare($queryi);
1236 1375
 						$sthi->execute($queryi_values);
1237 1376
 					} catch(PDOException $e) {
1238
-						if ($globalDebug) echo $e->getMessage();
1377
+						if ($globalDebug) {
1378
+							echo $e->getMessage();
1379
+						}
1239 1380
 						return "error : ".$e->getMessage();
1240 1381
 					}
1241 1382
 				} else {
1242
-					if ($globalDebug) echo " Update ModeS table - ";
1383
+					if ($globalDebug) {
1384
+						echo " Update ModeS table - ";
1385
+					}
1243 1386
 					if ($ICAOTypeCode != '') {
1244 1387
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1245 1388
 						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
@@ -1251,7 +1394,9 @@  discard block
 block discarded – undo
1251 1394
 						$sthi = $this->db->prepare($queryi);
1252 1395
 						$sthi->execute($queryi_values);
1253 1396
 					} catch(PDOException $e) {
1254
-						if ($globalDebug) echo $e->getMessage();
1397
+						if ($globalDebug) {
1398
+							echo $e->getMessage();
1399
+						}
1255 1400
 						return "error : ".$e->getMessage();
1256 1401
 					}
1257 1402
 				}
@@ -1272,7 +1417,9 @@  discard block
 block discarded – undo
1272 1417
 					    return "error : ".$e->getMessage();
1273 1418
 				}
1274 1419
 				*/
1275
-				if ($globalDebug) echo " Update Spotter_output table - ";
1420
+				if ($globalDebug) {
1421
+					echo " Update Spotter_output table - ";
1422
+				}
1276 1423
 				if ($ICAOTypeCode != '') {
1277 1424
 					if ($globalDBdriver == 'mysql') {
1278 1425
 						$queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
@@ -1283,8 +1430,7 @@  discard block
 block discarded – undo
1283 1430
 				} else {
1284 1431
 					if ($globalDBdriver == 'mysql') {
1285 1432
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
1286
-					}
1287
-					elseif ($globalDBdriver == 'pgsql') {
1433
+					} elseif ($globalDBdriver == 'pgsql') {
1288 1434
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1289 1435
 					}
1290 1436
 					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
@@ -1293,14 +1439,20 @@  discard block
 block discarded – undo
1293 1439
 					$sthi = $this->db->prepare($queryi);
1294 1440
 					$sthi->execute($queryi_values);
1295 1441
 				} catch(PDOException $e) {
1296
-					if ($globalDebug) echo $e->getMessage();
1442
+					if ($globalDebug) {
1443
+						echo $e->getMessage();
1444
+					}
1297 1445
 					return "error : ".$e->getMessage();
1298 1446
 				}
1299 1447
 			}
1300 1448
 		} else {
1301
-			if ($globalDebug) echo " Can't find ModeS in spotter_output - ";
1449
+			if ($globalDebug) {
1450
+				echo " Can't find ModeS in spotter_output - ";
1451
+			}
1452
+		}
1453
+		if ($globalDebug) {
1454
+			echo "Done\n";
1302 1455
 		}
1303
-		if ($globalDebug) echo "Done\n";
1304 1456
 		return '';
1305 1457
 	}
1306 1458
 }
Please login to merge, or discard this patch.
airline-detailed.php 2 patches
Braces   +31 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 		$limit_start = 0;
15 15
 		$limit_end = 25;
16 16
 		$absolute_difference = 25;
17
-	}  else {
17
+	} else {
18 18
 		$limit_explode = explode(",", $_GET['limit']);
19 19
 		$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
20 20
 		$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -55,7 +55,9 @@  discard block
 block discarded – undo
55 55
 				$title = sprintf(_("Detailed View for %s (%s)"),$airline_info[0]['name'],$airline_info[0]['icao']);
56 56
 			} elseif (isset($spotter_array[0]['airline_name']) && isset($spotter_array[0]['airline_icao'])) {
57 57
 				$title = sprintf(_("Detailed View for %s (%s)"),$spotter_array[0]['airline_name'],$spotter_array[0]['airline_icao']);
58
-			} else $title = '';
58
+			} else {
59
+				$title = '';
60
+			}
59 61
 		}
60 62
 		require_once('header.php');
61 63
 	  
@@ -76,7 +78,9 @@  discard block
 block discarded – undo
76 78
 		}
77 79
 		$Stats = new Stats();
78 80
 		$airline_names = $Stats->getAllAirlineNames();
79
-		if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames();
81
+		if (empty($airline_names)) {
82
+			$airline_names = $Spotter->getAllAirlineNames();
83
+		}
80 84
 		foreach($airline_names as $airline_name)
81 85
 		{
82 86
 			if($airline == $airline_name['airline_icao'])
@@ -108,12 +112,22 @@  discard block
 block discarded – undo
108 112
 					print '<div><span class="label">'._("Name").'</span>'.$airline_info[0]['name'].'</div>';
109 113
 					print '<div><span class="label">'._("Country").'</span>'.$airline_info[0]['country'].'</div>';
110 114
 					print '<div><span class="label">'._("ICAO").'</span>'.$airline_info[0]['icao'].'</div>';
111
-					if ($airline_info[0]['iata'] != '') print '<div><span class="label">'._("IATA").'</span>'.$airline_info[0]['iata'].'</div>';
112
-					if ($airline_info[0]['callsign'] != '') print '<div><span class="label">'._("Callsign").'</span>'.$airline_info[0]['callsign'].'</div>'; 
115
+					if ($airline_info[0]['iata'] != '') {
116
+						print '<div><span class="label">'._("IATA").'</span>'.$airline_info[0]['iata'].'</div>';
117
+					}
118
+					if ($airline_info[0]['callsign'] != '') {
119
+						print '<div><span class="label">'._("Callsign").'</span>'.$airline_info[0]['callsign'].'</div>';
120
+					}
113 121
 					print '<div><span class="label">'._("Type").'</span>'.ucwords($airline_info[0]['type']).'</div>';
114
-					if (isset($airline_info[0]['home_link']) && $airline_info[0]['home_link'] != '') print '<div><a href="'.$airline_info[0]['home_link'].'"><i class="fa fa-home"></i></a></div>';
115
-					if (isset($airline_info[0]['wikipedia_link']) && $airline_info[0]['wikipedia_link'] != '') print '<div><a href="'.$airline_info[0]['wikipedia_link'].'"><i class="fa fa-wikipedia-w"></i></a></div>';
116
-					if (isset($airline_info[0]['ban_eu']) && $airline_info[0]['ban_eu'] == 1) print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>';
122
+					if (isset($airline_info[0]['home_link']) && $airline_info[0]['home_link'] != '') {
123
+						print '<div><a href="'.$airline_info[0]['home_link'].'"><i class="fa fa-home"></i></a></div>';
124
+					}
125
+					if (isset($airline_info[0]['wikipedia_link']) && $airline_info[0]['wikipedia_link'] != '') {
126
+						print '<div><a href="'.$airline_info[0]['wikipedia_link'].'"><i class="fa fa-wikipedia-w"></i></a></div>';
127
+					}
128
+					if (isset($airline_info[0]['ban_eu']) && $airline_info[0]['ban_eu'] == 1) {
129
+						print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>';
130
+					}
117 131
 					print '</div>';
118 132
 				
119 133
 				} else {
@@ -129,10 +143,16 @@  discard block
 block discarded – undo
129 143
 					print '<div><span class="label">'._("Name").'</span>'.$spotter_array[0]['airline_name'].'</div>';
130 144
 					print '<div><span class="label">'._("Country").'</span>'.$spotter_array[0]['airline_country'].'</div>';
131 145
 					print '<div><span class="label">'._("ICAO").'</span>'.$spotter_array[0]['airline_icao'].'</div>';
132
-					if (isset($spotter_array[0]['airline_iata']) && $spotter_array[0]['airline_iata'] != '') print '<div><span class="label">'._("IATA").'</span>'.$spotter_array[0]['airline_iata'].'</div>';
133
-					if (isset($spotter_array[0]['airline_callsign']) && $spotter_array[0]['airline_callsign'] != '') print '<div><span class="label">'._("Callsign").'</span>'.$spotter_array[0]['airline_callsign'].'</div>'; 
146
+					if (isset($spotter_array[0]['airline_iata']) && $spotter_array[0]['airline_iata'] != '') {
147
+						print '<div><span class="label">'._("IATA").'</span>'.$spotter_array[0]['airline_iata'].'</div>';
148
+					}
149
+					if (isset($spotter_array[0]['airline_callsign']) && $spotter_array[0]['airline_callsign'] != '') {
150
+						print '<div><span class="label">'._("Callsign").'</span>'.$spotter_array[0]['airline_callsign'].'</div>';
151
+					}
134 152
 					print '<div><span class="label">'._("Type").'</span>'.ucwords($spotter_array[0]['airline_type']).'</div>';
135
-					if (isset($spotter_array[0]['ban_eu']) && $spotter_array[0]['ban_eu'] == 1) print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>';
153
+					if (isset($spotter_array[0]['ban_eu']) && $spotter_array[0]['ban_eu'] == 1) {
154
+						print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>';
155
+					}
136 156
 					print '</div>';
137 157
 				}
138 158
 			} else {
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -4,20 +4,20 @@  discard block
 block discarded – undo
4 4
 require_once('require/class.Stats.php');
5 5
 require_once('require/class.Language.php');
6 6
 
7
-if (!isset($_GET['airline'])){
7
+if (!isset($_GET['airline'])) {
8 8
 	header('Location: '.$globalURL.'/airline');
9
-} else{
9
+} else {
10 10
 	$Spotter = new Spotter();
11 11
 	//calculuation for the pagination
12
-	if(!isset($_GET['limit']) || $_GET['limit'] == "")
12
+	if (!isset($_GET['limit']) || $_GET['limit'] == "")
13 13
 	{
14 14
 		$limit_start = 0;
15 15
 		$limit_end = 25;
16 16
 		$absolute_difference = 25;
17
-	}  else {
17
+	} else {
18 18
 		$limit_explode = explode(",", $_GET['limit']);
19
-		$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
20
-		$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
19
+		$limit_start = filter_var($limit_explode[0], FILTER_SANITIZE_NUMBER_INT);
20
+		$limit_end = filter_var($limit_explode[1], FILTER_SANITIZE_NUMBER_INT);
21 21
 		if (!ctype_digit(strval($limit_start)) || !ctype_digit(strval($limit_end))) {
22 22
 			$limit_start = 0;
23 23
 			$limit_end = 25;
@@ -28,20 +28,20 @@  discard block
 block discarded – undo
28 28
 	$limit_previous_1 = $limit_start - $absolute_difference;
29 29
 	$limit_previous_2 = $limit_end - $absolute_difference;
30 30
 	
31
-	$airline = urldecode(filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING));
31
+	$airline = urldecode(filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING));
32 32
 	$page_url = $globalURL.'/airline/'.$airline;
33 33
 	$alliance = false;
34
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
34
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
35 35
 	$airline_info = array();
36
-	if (strpos($airline,'alliance_') !== FALSE) {
37
-		$spotter_array = $Spotter->getSpotterDataByAirline('',$limit_start.",".$absolute_difference, $sort,array('alliance' => str_replace('_',' ',str_replace('alliance_','',$airline))));
36
+	if (strpos($airline, 'alliance_') !== FALSE) {
37
+		$spotter_array = $Spotter->getSpotterDataByAirline('', $limit_start.",".$absolute_difference, $sort, array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $airline))));
38 38
 		$alliance = true;
39 39
 	} else {
40
-		$spotter_array = $Spotter->getSpotterDataByAirline($airline,$limit_start.",".$absolute_difference, $sort);
40
+		$spotter_array = $Spotter->getSpotterDataByAirline($airline, $limit_start.",".$absolute_difference, $sort);
41 41
 		if (isset($globalIVAO)) {
42
-			$airline_info = $Spotter->getAllAirlineInfo($airline,'ivao');
42
+			$airline_info = $Spotter->getAllAirlineInfo($airline, 'ivao');
43 43
 		} elseif (isset($globalVATSIM)) {
44
-			$airline_info = $Spotter->getAllAirlineInfo($airline,'vatsim');
44
+			$airline_info = $Spotter->getAllAirlineInfo($airline, 'vatsim');
45 45
 		} else {
46 46
 			$airline_info = $Spotter->getAllAirlineInfo($airline);
47 47
 		}
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
 	if (!empty($spotter_array) || !empty($airline_info))
50 50
 	{
51 51
 		if ($alliance) {
52
-			$title = sprintf(_("Detailed View for %s"),str_replace('_',' ',str_replace('alliance_','',$airline)));
52
+			$title = sprintf(_("Detailed View for %s"), str_replace('_', ' ', str_replace('alliance_', '', $airline)));
53 53
 		} else {
54 54
 			if (isset($airline_info[0]['name']) && isset($airline_info[0]['icao'])) {
55
-				$title = sprintf(_("Detailed View for %s (%s)"),$airline_info[0]['name'],$airline_info[0]['icao']);
55
+				$title = sprintf(_("Detailed View for %s (%s)"), $airline_info[0]['name'], $airline_info[0]['icao']);
56 56
 			} elseif (isset($spotter_array[0]['airline_name']) && isset($spotter_array[0]['airline_icao'])) {
57
-				$title = sprintf(_("Detailed View for %s (%s)"),$spotter_array[0]['airline_name'],$spotter_array[0]['airline_icao']);
57
+				$title = sprintf(_("Detailed View for %s (%s)"), $spotter_array[0]['airline_name'], $spotter_array[0]['airline_icao']);
58 58
 			} else $title = '';
59 59
 		}
60 60
 		require_once('header.php');
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 		$alliances = $Spotter->getAllAllianceNames();
67 67
 		if (!empty($alliances)) {
68 68
 			foreach ($alliances as $al) {
69
-				if ($alliance && str_replace('_',' ',str_replace('alliance_','',$airline)) == $al['alliance']) {
70
-					print '<option value="alliance_'.str_replace(' ','_',$al['alliance']).'" selected>'.$al['alliance'].'</option>';
69
+				if ($alliance && str_replace('_', ' ', str_replace('alliance_', '', $airline)) == $al['alliance']) {
70
+					print '<option value="alliance_'.str_replace(' ', '_', $al['alliance']).'" selected>'.$al['alliance'].'</option>';
71 71
 				} else {
72
-					print '<option value="alliance_'.str_replace(' ','_',$al['alliance']).'">'.$al['alliance'].'</option>';
72
+					print '<option value="alliance_'.str_replace(' ', '_', $al['alliance']).'">'.$al['alliance'].'</option>';
73 73
 				}
74 74
 			}
75 75
 			print '<option disabled>───────────────</option>';
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
 		$Stats = new Stats();
78 78
 		$airline_names = $Stats->getAllAirlineNames();
79 79
 		if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames();
80
-		foreach($airline_names as $airline_name)
80
+		foreach ($airline_names as $airline_name)
81 81
 		{
82
-			if($airline == $airline_name['airline_icao'])
82
+			if ($airline == $airline_name['airline_icao'])
83 83
 			{
84 84
 				print '<option value="'.$airline_name['airline_icao'].'" selected="selected">'.$airline_name['airline_name'].' ('.$airline_name['airline_icao'].')</option>';
85 85
 			} else {
@@ -137,12 +137,12 @@  discard block
 block discarded – undo
137 137
 				}
138 138
 			} else {
139 139
 				print '<div class="info column">';
140
-				print '<h1>'.str_replace('_',' ',str_replace('alliance_','',$airline)).'</h1>';
141
-				if (@getimagesize($globalURL.'/images/airlines/'.str_replace('alliance_','',$airline).'.png') || @getimagesize('images/airlines/'.str_replace('alliance_','',$airline).'.png'))
140
+				print '<h1>'.str_replace('_', ' ', str_replace('alliance_', '', $airline)).'</h1>';
141
+				if (@getimagesize($globalURL.'/images/airlines/'.str_replace('alliance_', '', $airline).'.png') || @getimagesize('images/airlines/'.str_replace('alliance_', '', $airline).'.png'))
142 142
 				{
143
-					print '<img src="'.$globalURL.'/images/airlines/'.str_replace('alliance_','',$airline).'.png" alt="'.str_replace('_',' ',str_replace('alliance_','',$airline)).'" title="'.str_replace('_',' ',str_replace('alliance_','',$airline)).'" class="logo" />';
143
+					print '<img src="'.$globalURL.'/images/airlines/'.str_replace('alliance_', '', $airline).'.png" alt="'.str_replace('_', ' ', str_replace('alliance_', '', $airline)).'" title="'.str_replace('_', ' ', str_replace('alliance_', '', $airline)).'" class="logo" />';
144 144
 				}
145
-				print '<div><span class="label">'._("Name").'</span>'.str_replace('_',' ',str_replace('alliance_','',$airline)).'</div>';
145
+				print '<div><span class="label">'._("Name").'</span>'.str_replace('_', ' ', str_replace('alliance_', '', $airline)).'</div>';
146 146
 				print '</div>';
147 147
 			}
148 148
 		} else {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 			include('airline-sub-menu.php');
154 154
 			print '<div class="table column">';
155 155
 			if (isset($spotter_array[0]['airline_name']) && $alliance === false) {
156
-				print '<p>'.sprintf(_("The table below shows the detailed information of all flights from <strong>%s</strong>."),$spotter_array[0]['airline_name']).'</p>';
156
+				print '<p>'.sprintf(_("The table below shows the detailed information of all flights from <strong>%s</strong>."), $spotter_array[0]['airline_name']).'</p>';
157 157
 			}
158 158
 			include('table-output.php');  
159 159
 			print '<div class="pagination">';
Please login to merge, or discard this patch.
table-output.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 				}
366 366
 			}
367 367
 		}
368
-    		if ($type == 'aircraft') {
368
+			if ($type == 'aircraft') {
369 369
 			if ((isset($globalUsePilot) && $globalUsePilot) || (!isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalVAM) && $globalVAM) || (isset($globalphpVMS) && $globalphpVMS)))) {
370 370
 				print '<th class="pilot"><span class="nomobile">'._("Pilot name").'</span><span class="mobile">'._("Pilot").'</span></a></th>';
371 371
 			}
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 	} elseif(strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed"){
724 724
 		if ($type == 'aircraft') {
725 725
 			if (!isset($spotter_item['squawk']) || $spotter_item['squawk'] == 0) {
726
-			    $spotter_item['squawk'] = '-';
726
+				$spotter_item['squawk'] = '-';
727 727
 			}
728 728
 			if ($spotter_item['image_thumbnail'] != "")
729 729
 			{
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 				print '</td>'."\n";
763 763
 			} else {
764 764
 				print '<td class="aircraft_thumbnail">'."\n";
765
-	       //   	 	print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
765
+		   //   	 	print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
766 766
 		//}
767 767
 				if (!isset($spotter_item['airline_name']) && !isset($spotter_item['aircraft_name'])) {
768 768
 					print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '._("Not available").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n";
@@ -1034,11 +1034,11 @@  discard block
 block discarded – undo
1034 1034
 					if (!isset($Spotter)) $Spotter = new Spotter();
1035 1035
 					$arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']);
1036 1036
 					if (isset($arrival_airport_info[0])) {
1037
-                        print '<br /><span class="nomobile">' . _("Real:") . ' <a href="' . $globalURL . '/airport/' . $spotter_item['real_arrival_airport'] . '">' . $arrival_airport_info[0]['city'] . ',' . $arrival_airport_info[0]['country'] . ' (' . $spotter_item['real_arrival_airport'] . ')</a></span>' . "\n";
1038
-                    }
1039
-                    print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n";
1040
-                    if (isset($arrival_airport_info[0])) {
1041
-                        print '<span class="mobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n";
1037
+						print '<br /><span class="nomobile">' . _("Real:") . ' <a href="' . $globalURL . '/airport/' . $spotter_item['real_arrival_airport'] . '">' . $arrival_airport_info[0]['city'] . ',' . $arrival_airport_info[0]['country'] . ' (' . $spotter_item['real_arrival_airport'] . ')</a></span>' . "\n";
1038
+					}
1039
+					print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n";
1040
+					if (isset($arrival_airport_info[0])) {
1041
+						print '<span class="mobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n";
1042 1042
 					}
1043 1043
 				} elseif ($spotter_item['arrival_airport'] != 'NA') {
1044 1044
 					print '<span class="nomobile"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a></span>'."\n";
Please login to merge, or discard this patch.
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -4,15 +4,15 @@  discard block
 block discarded – undo
4 4
 
5 5
 require_once(dirname(__FILE__).'/require/class.Common.php');
6 6
 $Common = new Common();
7
-$showRouteStop = $Common->multiKeyExists($spotter_array,'route_stop');
7
+$showRouteStop = $Common->multiKeyExists($spotter_array, 'route_stop');
8 8
 if (isset($globalVM) && $globalVM && isset($type) && $type == 'marine') {
9
-	$showDuration = $Common->multiKeyExists($spotter_array,'race_time');
10
-	if ($showDuration === false) $showDuration = $Common->multiKeyExists($spotter_array,'duration');
9
+	$showDuration = $Common->multiKeyExists($spotter_array, 'race_time');
10
+	if ($showDuration === false) $showDuration = $Common->multiKeyExists($spotter_array, 'duration');
11 11
 } else {
12
-	$showDuration = $Common->multiKeyExists($spotter_array,'duration');
12
+	$showDuration = $Common->multiKeyExists($spotter_array, 'duration');
13 13
 }
14 14
 if (isset($globalVM) && $globalVM && isset($type) && $type == 'marine') {
15
-	$showDistance = $Common->multiKeyExists($spotter_array,'distance');
15
+	$showDistance = $Common->multiKeyExists($spotter_array, 'distance');
16 16
 }
17 17
 
18 18
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	}
179 179
 	print '<th class="more"></th>';
180 180
 	print '</thead>';
181
-} else if (strtolower($current_page) == "upcoming"){
181
+} else if (strtolower($current_page) == "upcoming") {
182 182
 	print '<thead>';
183 183
 	if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) {
184 184
 		if ($_GET['sort'] == "airline_name_asc")
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	}
233 233
 	*/
234 234
 	print '</thead>';
235
-} else if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive"){
235
+} else if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive") {
236 236
 	print '<thead>';
237 237
 	print '<th class="aircraft_thumbnail"></th>';
238 238
 	print '<th class="logo">'._("Airline").'</th>';
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	print '</thead>';
270 270
 } else {
271 271
 
272
-	if ($hide_th_links === true){
272
+	if ($hide_th_links === true) {
273 273
 		print '<thead>';
274 274
 		if ($type == 'marine' && isset($globalVM) && $globalVM) {
275 275
 			print '<th class="rank">'._("Rank").'</th>';
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 }
588 588
 
589 589
 print '<tbody>'."\n";
590
-foreach($spotter_array as $spotter_item)
590
+foreach ($spotter_array as $spotter_item)
591 591
 {
592 592
 	if (isset($globalTimezone))
593 593
 	{
@@ -622,13 +622,13 @@  discard block
 block discarded – undo
622 622
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
623 623
 					}
624 624
 					if (isset($spotter_item['airline_name'])) {
625
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
625
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
626 626
 					} else {
627
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
627
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
628 628
 					}
629 629
 				} else {
630 630
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
631
-						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
631
+						$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
632 632
 					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
633 633
 					if (isset($spotter_item['airline_name'])) {
634 634
 						print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 			{
655 655
 				print '<td class="aircraft_thumbnail">'."\n";
656 656
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
657
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
657
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
658 658
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
659 659
 				if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') {
660 660
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 			{
677 677
 				print '<td class="aircraft_thumbnail">'."\n";
678 678
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
679
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
679
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
680 680
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
681 681
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
682 682
 				print '</td>'."\n";
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
 				print '</td>'."\n";
721 721
 			}
722 722
 		}
723
-	} elseif(strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed"){
723
+	} elseif (strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed") {
724 724
 		if ($type == 'aircraft') {
725 725
 			if (!isset($spotter_item['squawk']) || $spotter_item['squawk'] == 0) {
726 726
 			    $spotter_item['squawk'] = '-';
@@ -737,17 +737,17 @@  discard block
 block discarded – undo
737 737
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
738 738
 					}
739 739
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
740
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
740
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
741 741
 					} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
742
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
742
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
743 743
 					} elseif (!isset($spotter_item['aircraft_name']) && !isset($spotter_item['airline_name'])) {
744
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
744
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
745 745
 					} else {
746
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
746
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
747 747
 					}
748 748
 				} else {
749 749
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
750
-						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
750
+						$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
751 751
 					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
752 752
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
753 753
 						print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 			{
788 788
 				print '<td class="aircraft_thumbnail">'."\n";
789 789
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
790
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
790
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
791 791
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
792 792
 				if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') {
793 793
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n";
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
 			{
812 812
 				print '<td class="aircraft_thumbnail">'."\n";
813 813
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
814
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
814
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
815 815
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
816 816
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
817 817
 				print '</td>'."\n";
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
 		print '</td>'."\n";
921 921
 	}
922 922
 	// Aircraft type
923
-	if(strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive"){
923
+	if (strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive") {
924 924
 		print '<td class="type">'."\n";
925 925
 		if ($type == 'aircraft') {
926 926
 			if (!isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_name'])) {
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 				//print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'._("Not available").'</a></span>'."\n";
930 930
 				print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n";
931 931
 			} else {
932
-				$aircraft_names = explode('/',$spotter_item['aircraft_name']);
932
+				$aircraft_names = explode('/', $spotter_item['aircraft_name']);
933 933
 				if (count($aircraft_names) == 1) print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n";
934 934
 				else print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n";
935 935
 			}
@@ -973,22 +973,22 @@  discard block
 block discarded – undo
973 973
 			}
974 974
 			if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) {
975 975
 				if ($spotter_item['departure_airport_time'] > 2460) {
976
-					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
977
-				} else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
976
+					$departure_airport_time = date('H:m', $spotter_item['departure_airport_time']);
977
+				} else $departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2);
978 978
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
979
-					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
979
+					$real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']);
980 980
 				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
981 981
 				print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n";
982 982
 			} elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') {
983 983
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
984
-					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
984
+					$real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']);
985 985
 				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
986 986
 				print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n";
987 987
 			} elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
988 988
 				if ($spotter_item['departure_airport_time'] > 2460) {
989
-					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
989
+					$departure_airport_time = date('H:m', $spotter_item['departure_airport_time']);
990 990
 				} else {
991
-					$departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
991
+					$departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2);
992 992
 				}
993 993
 				print '<br /><span class="airport_time">'.$departure_airport_time.'</span>'."\n";
994 994
 			}
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 						$latitude = $spotter_item['latitude'];
1004 1004
 						$longitude = $spotter_item['longitude'];
1005 1005
 					}
1006
-					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
1006
+					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'], $latitude, $longitude);
1007 1007
 				} else $distance = '';
1008 1008
 				if ($distance != '') {
1009 1009
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
 					if (!isset($Spotter)) $Spotter = new Spotter();
1035 1035
 					$arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']);
1036 1036
 					if (isset($arrival_airport_info[0])) {
1037
-                        print '<br /><span class="nomobile">' . _("Real:") . ' <a href="' . $globalURL . '/airport/' . $spotter_item['real_arrival_airport'] . '">' . $arrival_airport_info[0]['city'] . ',' . $arrival_airport_info[0]['country'] . ' (' . $spotter_item['real_arrival_airport'] . ')</a></span>' . "\n";
1037
+                        print '<br /><span class="nomobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n";
1038 1038
                     }
1039 1039
                     print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n";
1040 1040
                     if (isset($arrival_airport_info[0])) {
@@ -1050,20 +1050,20 @@  discard block
 block discarded – undo
1050 1050
 			}
1051 1051
 			if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) {
1052 1052
 				if ($spotter_item['arrival_airport_time'] > 2460) {
1053
-					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
1053
+					$arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']);
1054 1054
 				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
1055 1055
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
1056
-					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
1056
+					$real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']);
1057 1057
 				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1058 1058
 				print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n";
1059 1059
 			} elseif (isset($spotter_item['real_arrival_airport_time'])) {
1060 1060
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
1061
-					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
1061
+					$real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']);
1062 1062
 				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1063 1063
 				print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n";
1064 1064
 			} elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
1065 1065
 				if ($spotter_item['arrival_airport_time'] > 2460) {
1066
-					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
1066
+					$arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']);
1067 1067
 				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
1068 1068
 				print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n";
1069 1069
 			}
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
 						$latitude = $spotter_item['latitude'];
1077 1077
 						$longitude = $spotter_item['longitude'];
1078 1078
 					}
1079
-					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude);
1079
+					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'], $latitude, $longitude);
1080 1080
 				} else $distance = '';
1081 1081
 				if ($distance != '') {
1082 1082
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
@@ -1138,19 +1138,19 @@  discard block
 block discarded – undo
1138 1138
 				print '<span class="mobile">-</span>'."\n";
1139 1139
 			} else {
1140 1140
 				if ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
1141
-					print '<span class="nomobile">'.round($spotter_item['distance'],2).' km</span>'."\n";
1142
-					print '<span class="mobile">'.round($spotter_item['distance'],2).' km</span><br />'."\n";
1141
+					print '<span class="nomobile">'.round($spotter_item['distance'], 2).' km</span>'."\n";
1142
+					print '<span class="mobile">'.round($spotter_item['distance'], 2).' km</span><br />'."\n";
1143 1143
 				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
1144
-					print '<span class="nomobile">'.round($spotter_item['distance']*0.621371,2).' mi</span>'."\n";
1145
-					print '<span class="mobile">'.round($spotter_item['distance']*0.621371,2).' mi</span><br />'."\n";
1144
+					print '<span class="nomobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span>'."\n";
1145
+					print '<span class="mobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span><br />'."\n";
1146 1146
 				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1147
-					print '<span class="nomobile">'.round($spotter_item['distance']*0.539957,2).' nm</span>'."\n";
1148
-					print '<span class="mobile">'.round($spotter_item['distance']*0.539957,2).' nm</span><br />'."\n";
1147
+					print '<span class="nomobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span>'."\n";
1148
+					print '<span class="mobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span><br />'."\n";
1149 1149
 				}
1150 1150
 			}
1151 1151
 			print '</td>'."\n";
1152 1152
 		}
1153
-		if(strtolower($current_page) != "upcoming"){
1153
+		if (strtolower($current_page) != "upcoming") {
1154 1154
 			if ($type == 'aircraft') {
1155 1155
 				//if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
1156 1156
 				if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
@@ -1195,14 +1195,14 @@  discard block
 block discarded – undo
1195 1195
 						if (isset($spotter_item['distance'])) {
1196 1196
 							print '<td class="distance">';
1197 1197
 							if ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
1198
-								print '<span class="nomobile">'.round($spotter_item['distance'],2).' km</span>'."\n";
1199
-								print '<span class="mobile">'.round($spotter_item['distance'],2).' km</span><br />'."\n";
1198
+								print '<span class="nomobile">'.round($spotter_item['distance'], 2).' km</span>'."\n";
1199
+								print '<span class="mobile">'.round($spotter_item['distance'], 2).' km</span><br />'."\n";
1200 1200
 							} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
1201
-								print '<span class="nomobile">'.round($spotter_item['distance']*0.621371,2).' mi</span>'."\n";
1202
-								print '<span class="mobile">'.round($spotter_item['distance']*0.621371,2).' mi</span><br />'."\n";
1201
+								print '<span class="nomobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span>'."\n";
1202
+								print '<span class="mobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span><br />'."\n";
1203 1203
 							} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1204
-								print '<span class="nomobile">'.round($spotter_item['distance']*0.539957,2).' nm</span>'."\n";
1205
-								print '<span class="mobile">'.round($spotter_item['distance']*0.539957,2).' nm</span><br />'."\n";
1204
+								print '<span class="nomobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span>'."\n";
1205
+								print '<span class="mobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span><br />'."\n";
1206 1206
 							}
1207 1207
 							print '</td>'."\n";
1208 1208
 						} else {
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
 		
1234 1234
 		if ($showRouteStop) {
1235 1235
 		// Route stop
1236
-			if(strtolower($current_page) != "upcoming"){
1236
+			if (strtolower($current_page) != "upcoming") {
1237 1237
 				print '<td class="route_stop">'."\n";
1238 1238
 				if (!isset($spotter_item['route_stop']) || $spotter_item['route_stop'] == '' || $spotter_item['route_stop'] == 'NULL') {
1239 1239
 					print '<span class="nomobile">-</span>'."\n";
@@ -1256,19 +1256,19 @@  discard block
 block discarded – undo
1256 1256
 				print '<td class="duration">'."\n";
1257 1257
 				if (isset($spotter_item['race_time'])) {
1258 1258
 					if ($spotter_item['race_time'] > 86400) {
1259
-						print '<span class="nomobile">'.gmdate("z\d. H\h. i\m. s\s.",$spotter_item['race_time']).'</span>'."\n";
1260
-						print '<span class="mobile">'.gmdate("z\d. H\h. i\m. s\s.",$spotter_item['race_time']).'</span>'."\n";
1259
+						print '<span class="nomobile">'.gmdate("z\d. H\h. i\m. s\s.", $spotter_item['race_time']).'</span>'."\n";
1260
+						print '<span class="mobile">'.gmdate("z\d. H\h. i\m. s\s.", $spotter_item['race_time']).'</span>'."\n";
1261 1261
 					} else {
1262
-						print '<span class="nomobile">'.gmdate("H\h. i\m. s\s.",$spotter_item['race_time']).'</span>'."\n";
1263
-						print '<span class="mobile">'.gmdate("H\h. i\m. s\s.",$spotter_item['race_time']).'</span>'."\n";
1262
+						print '<span class="nomobile">'.gmdate("H\h. i\m. s\s.", $spotter_item['race_time']).'</span>'."\n";
1263
+						print '<span class="mobile">'.gmdate("H\h. i\m. s\s.", $spotter_item['race_time']).'</span>'."\n";
1264 1264
 					}
1265 1265
 				} elseif (isset($spotter_item['duration'])) {
1266 1266
 					if ($spotter_item['duration'] > 86400) {
1267
-						print '<span class="nomobile">'.gmdate('z\d. H\h. i\m. s\s.',$spotter_item['duration']).'</span>'."\n";
1268
-						print '<span class="mobile">'.gmdate('z\d. H\h. i\m. s\s.',$spotter_item['duration']).'</span>'."\n";
1267
+						print '<span class="nomobile">'.gmdate('z\d. H\h. i\m. s\s.', $spotter_item['duration']).'</span>'."\n";
1268
+						print '<span class="mobile">'.gmdate('z\d. H\h. i\m. s\s.', $spotter_item['duration']).'</span>'."\n";
1269 1269
 					} else {
1270
-						print '<span class="nomobile">'.gmdate('H\h. i\m. s\s.',$spotter_item['duration']).'</span>'."\n";
1271
-						print '<span class="mobile">'.gmdate('H\h. i\m. s\s.',$spotter_item['duration']).'</span>'."\n";
1270
+						print '<span class="nomobile">'.gmdate('H\h. i\m. s\s.', $spotter_item['duration']).'</span>'."\n";
1271
+						print '<span class="mobile">'.gmdate('H\h. i\m. s\s.', $spotter_item['duration']).'</span>'."\n";
1272 1272
 					}
1273 1273
 				} else {
1274 1274
 					print '<span class="nomobile">-</span>'."\n";
@@ -1276,11 +1276,11 @@  discard block
 block discarded – undo
1276 1276
 				}
1277 1277
 				print '</td>'."\n";
1278 1278
 			} else {
1279
-				if(strtolower($current_page) != "upcoming"){
1279
+				if (strtolower($current_page) != "upcoming") {
1280 1280
 					print '<td class="duration">'."\n";
1281 1281
 					if (isset($spotter_item['duration'])) {
1282
-						print '<span class="nomobile">'.gmdate('H:i:s',$spotter_item['duration']).'</span>'."\n";
1283
-						print '<span class="mobile">'.gmdate('H:i:s',$spotter_item['duration']).'</span>'."\n";
1282
+						print '<span class="nomobile">'.gmdate('H:i:s', $spotter_item['duration']).'</span>'."\n";
1283
+						print '<span class="mobile">'.gmdate('H:i:s', $spotter_item['duration']).'</span>'."\n";
1284 1284
 					} else {
1285 1285
 						print '<span class="nomobile">-</span>'."\n";
1286 1286
 						print '<span class="mobile">-</span>'."\n";
@@ -1294,7 +1294,7 @@  discard block
 block discarded – undo
1294 1294
 	if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive") {
1295 1295
 		if (isset($spotter_item['decode']) && $spotter_item['decode'] != '') {
1296 1296
 			print '<td class="message"><p>'."\n";
1297
-			print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1297
+			print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1298 1298
 			print '</p><p class="decode">';
1299 1299
 			$decode_array = json_decode($spotter_item['decode']);
1300 1300
 			foreach ($decode_array as $key => $value) {
@@ -1304,7 +1304,7 @@  discard block
 block discarded – undo
1304 1304
 			print '</td>'."\n";
1305 1305
 		} else {
1306 1306
 			print '<td class="message">'."\n";
1307
-			print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1307
+			print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1308 1308
 			print '</td>'."\n";
1309 1309
 		}
1310 1310
 	}
@@ -1329,7 +1329,7 @@  discard block
 block discarded – undo
1329 1329
 		}
1330 1330
 		print '</td>'."\n";
1331 1331
 		print '<td class="message">'."\n";
1332
-		print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1332
+		print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1333 1333
 		print '</td>'."\n";
1334 1334
 	}
1335 1335
 	if (strtolower($current_page) == "incident-latest" || strtolower($current_page) == "incident-detailed") {
@@ -1355,7 +1355,7 @@  discard block
 block discarded – undo
1355 1355
 		print '</td>'."\n";
1356 1356
 		*/
1357 1357
 		print '<td class="message">'."\n";
1358
-		print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1358
+		print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1359 1359
 		print '</td>'."\n";
1360 1360
 	}
1361 1361
 
Please login to merge, or discard this patch.
Braces   +78 added lines, -29 removed lines patch added patch discarded remove patch
@@ -7,8 +7,10 @@  discard block
 block discarded – undo
7 7
 $showRouteStop = $Common->multiKeyExists($spotter_array,'route_stop');
8 8
 if (isset($globalVM) && $globalVM && isset($type) && $type == 'marine') {
9 9
 	$showDuration = $Common->multiKeyExists($spotter_array,'race_time');
10
-	if ($showDuration === false) $showDuration = $Common->multiKeyExists($spotter_array,'duration');
11
-} else {
10
+	if ($showDuration === false) {
11
+		$showDuration = $Common->multiKeyExists($spotter_array,'duration');
12
+	}
13
+	} else {
12 14
 	$showDuration = $Common->multiKeyExists($spotter_array,'duration');
13 15
 }
14 16
 if (isset($globalVM) && $globalVM && isset($type) && $type == 'marine') {
@@ -16,7 +18,9 @@  discard block
 block discarded – undo
16 18
 }
17 19
 
18 20
 
19
-if (!isset($type)) $type = 'aircraft';
21
+if (!isset($type)) {
22
+	$type = 'aircraft';
23
+}
20 24
 
21 25
 if (!isset($_GET['sort'])) 
22 26
 {
@@ -592,7 +596,9 @@  discard block
 block discarded – undo
592 596
 	if (isset($globalTimezone))
593 597
 	{
594 598
 		date_default_timezone_set($globalTimezone);
595
-	} else date_default_timezone_set('UTC');
599
+	} else {
600
+		date_default_timezone_set('UTC');
601
+	}
596 602
 	if ($showSpecial === true)
597 603
 	{
598 604
 		print '<tr class="special">'."\n";
@@ -607,7 +613,9 @@  discard block
 block discarded – undo
607 613
 			print '<tr class="active">';
608 614
 		} elseif (isset($spotter_item['spotted_registration'])) {
609 615
 			print '<tr class="info">';
610
-		} else print '<tr>';
616
+		} else {
617
+			print '<tr>';
618
+		}
611 619
 	}
612 620
 	if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive" || strtolower($current_page) == "currently" || strtolower($current_page) == "accident-latest" || strtolower($current_page) == "incident-latest" || strtolower($current_page) == "accident-detailed" || strtolower($current_page) == "incident-detailed") {
613 621
 		if ($type == 'aircraft') {
@@ -615,8 +623,9 @@  discard block
 block discarded – undo
615 623
 			{
616 624
 				print '<td class="aircraft_thumbnail">'."\n";
617 625
 				if ($spotter_item['image_source'] == 'planespotters') {
618
-					if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
619
-					else {
626
+					if ($spotter_item['image_source_website'] != '') {
627
+						$image_src = $spotter_item['image_source_website'];
628
+					} else {
620 629
 						$planespotter_url_array = explode("_", $spotter_item['image']);
621 630
 						$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
622 631
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -629,7 +638,9 @@  discard block
 block discarded – undo
629 638
 				} else {
630 639
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
631 640
 						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
632
-					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
641
+					} else {
642
+						$image_thumbnail = $spotter_item['image_thumbnail'];
643
+					}
633 644
 					if (isset($spotter_item['airline_name'])) {
634 645
 						print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
635 646
 					} else {
@@ -655,7 +666,9 @@  discard block
 block discarded – undo
655 666
 				print '<td class="aircraft_thumbnail">'."\n";
656 667
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
657 668
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
658
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
669
+				} else {
670
+					$image_thumbnail = $spotter_item['image_thumbnail'];
671
+				}
659 672
 				if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') {
660 673
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
661 674
 				} else {
@@ -677,7 +690,9 @@  discard block
 block discarded – undo
677 690
 				print '<td class="aircraft_thumbnail">'."\n";
678 691
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
679 692
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
680
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
693
+				} else {
694
+					$image_thumbnail = $spotter_item['image_thumbnail'];
695
+				}
681 696
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
682 697
 				print '</td>'."\n";
683 698
 			} else {
@@ -730,8 +745,9 @@  discard block
 block discarded – undo
730 745
 				print '<td class="aircraft_thumbnail">'."\n";
731 746
 				//print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$spotter_item['image_thumbnail'].'" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
732 747
 				if ($spotter_item['image_source'] == 'planespotters') {
733
-					if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
734
-					else {
748
+					if ($spotter_item['image_source_website'] != '') {
749
+						$image_src = $spotter_item['image_source_website'];
750
+					} else {
735 751
 						$planespotter_url_array = explode("_", $spotter_array[0]['image']);
736 752
 						$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
737 753
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -748,7 +764,9 @@  discard block
 block discarded – undo
748 764
 				} else {
749 765
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
750 766
 						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
751
-					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
767
+					} else {
768
+						$image_thumbnail = $spotter_item['image_thumbnail'];
769
+					}
752 770
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
753 771
 						print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
754 772
 					} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
@@ -788,13 +806,19 @@  discard block
 block discarded – undo
788 806
 				print '<td class="aircraft_thumbnail">'."\n";
789 807
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
790 808
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
791
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
809
+				} else {
810
+					$image_thumbnail = $spotter_item['image_thumbnail'];
811
+				}
792 812
 				if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') {
793 813
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n";
794
-					if ($spotter_item['image_copyright'] != '') print '<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
814
+					if ($spotter_item['image_copyright'] != '') {
815
+						print '<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
816
+					}
795 817
 				} else {
796 818
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['ident'].'" data-content="'._("Ident:").' '.$spotter_item['ident'].'" data-html="true" width="100px" />'."\n";
797
-					if ($spotter_item['image_copyright'] != '') print '<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
819
+					if ($spotter_item['image_copyright'] != '') {
820
+						print '<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
821
+					}
798 822
 				}
799 823
 				print '</td>'."\n";
800 824
 			} else {
@@ -812,7 +836,9 @@  discard block
 block discarded – undo
812 836
 				print '<td class="aircraft_thumbnail">'."\n";
813 837
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
814 838
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
815
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
839
+				} else {
840
+					$image_thumbnail = $spotter_item['image_thumbnail'];
841
+				}
816 842
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
817 843
 				print '</td>'."\n";
818 844
 			} else {
@@ -930,8 +956,11 @@  discard block
 block discarded – undo
930 956
 				print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n";
931 957
 			} else {
932 958
 				$aircraft_names = explode('/',$spotter_item['aircraft_name']);
933
-				if (count($aircraft_names) == 1) print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n";
934
-				else print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n";
959
+				if (count($aircraft_names) == 1) {
960
+					print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n";
961
+				} else {
962
+					print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n";
963
+				}
935 964
 			}
936 965
 			print '<span class="mobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n";
937 966
 		} elseif ($type == 'marine') {
@@ -974,15 +1003,21 @@  discard block
 block discarded – undo
974 1003
 			if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) {
975 1004
 				if ($spotter_item['departure_airport_time'] > 2460) {
976 1005
 					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
977
-				} else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
1006
+				} else {
1007
+					$departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
1008
+				}
978 1009
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
979 1010
 					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
980
-				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
1011
+				} else {
1012
+					$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
1013
+				}
981 1014
 				print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n";
982 1015
 			} elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') {
983 1016
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
984 1017
 					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
985
-				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
1018
+				} else {
1019
+					$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
1020
+				}
986 1021
 				print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n";
987 1022
 			} elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
988 1023
 				if ($spotter_item['departure_airport_time'] > 2460) {
@@ -1004,7 +1039,9 @@  discard block
 block discarded – undo
1004 1039
 						$longitude = $spotter_item['longitude'];
1005 1040
 					}
1006 1041
 					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
1007
-				} else $distance = '';
1042
+				} else {
1043
+					$distance = '';
1044
+				}
1008 1045
 				if ($distance != '') {
1009 1046
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1010 1047
 						echo '<br/><i>'.round($distance*0.539957).' nm</i>';
@@ -1031,7 +1068,9 @@  discard block
 block discarded – undo
1031 1068
 			} else {
1032 1069
 				if (isset($spotter_item['real_arrival_airport']) && $spotter_item['real_arrival_airport'] != $spotter_item['arrival_airport']) {
1033 1070
 					print '<span class="nomobile">Scheduled : <a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a></span>'."\n";
1034
-					if (!isset($Spotter)) $Spotter = new Spotter();
1071
+					if (!isset($Spotter)) {
1072
+						$Spotter = new Spotter();
1073
+					}
1035 1074
 					$arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']);
1036 1075
 					if (isset($arrival_airport_info[0])) {
1037 1076
                         print '<br /><span class="nomobile">' . _("Real:") . ' <a href="' . $globalURL . '/airport/' . $spotter_item['real_arrival_airport'] . '">' . $arrival_airport_info[0]['city'] . ',' . $arrival_airport_info[0]['country'] . ' (' . $spotter_item['real_arrival_airport'] . ')</a></span>' . "\n";
@@ -1051,20 +1090,28 @@  discard block
 block discarded – undo
1051 1090
 			if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) {
1052 1091
 				if ($spotter_item['arrival_airport_time'] > 2460) {
1053 1092
 					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
1054
-				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
1093
+				} else {
1094
+					$arrival_airport_time = $spotter_item['arrival_airport_time'];
1095
+				}
1055 1096
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
1056 1097
 					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
1057
-				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1098
+				} else {
1099
+					$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1100
+				}
1058 1101
 				print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n";
1059 1102
 			} elseif (isset($spotter_item['real_arrival_airport_time'])) {
1060 1103
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
1061 1104
 					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
1062
-				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1105
+				} else {
1106
+					$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1107
+				}
1063 1108
 				print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n";
1064 1109
 			} elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
1065 1110
 				if ($spotter_item['arrival_airport_time'] > 2460) {
1066 1111
 					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
1067
-				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
1112
+				} else {
1113
+					$arrival_airport_time = $spotter_item['arrival_airport_time'];
1114
+				}
1068 1115
 				print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n";
1069 1116
 			}
1070 1117
 			if (!isset($spotter_item['real_arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
@@ -1077,7 +1124,9 @@  discard block
 block discarded – undo
1077 1124
 						$longitude = $spotter_item['longitude'];
1078 1125
 					}
1079 1126
 					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude);
1080
-				} else $distance = '';
1127
+				} else {
1128
+					$distance = '';
1129
+				}
1081 1130
 				if ($distance != '') {
1082 1131
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1083 1132
 						echo '<br/><i>'.round($distance*0.539957).' nm</i>';
Please login to merge, or discard this patch.
require/class.MarineLive.php 3 patches
Indentation   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 	}
21 21
 
22 22
 
23
-    /**
24
-     * Get SQL query part for filter used
25
-     * @param array $filter the filter
26
-     * @param bool $where
27
-     * @param bool $and
28
-     * @return string the SQL part
29
-     */
23
+	/**
24
+	 * Get SQL query part for filter used
25
+	 * @param array $filter the filter
26
+	 * @param bool $where
27
+	 * @param bool $and
28
+	 * @return string the SQL part
29
+	 */
30 30
 	public function getFilter($filter = array(),$where = false,$and = false) {
31 31
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
32 32
 		$filters = array();
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
 		return $filter_query;
106 106
 	}
107 107
 
108
-    /**
109
-     * Gets all the spotter information based on the latest data entry
110
-     *
111
-     * @param string $limit
112
-     * @param string $sort
113
-     * @param array $filter
114
-     * @return array the spotter information
115
-     */
108
+	/**
109
+	 * Gets all the spotter information based on the latest data entry
110
+	 *
111
+	 * @param string $limit
112
+	 * @param string $sort
113
+	 * @param array $filter
114
+	 * @return array the spotter information
115
+	 */
116 116
 	public function getLiveMarineData($limit = '', $sort = '', $filter = array())
117 117
 	{
118 118
 		global $globalDBdriver, $globalLiveInterval;
@@ -154,12 +154,12 @@  discard block
 block discarded – undo
154 154
 		return $spotter_array;
155 155
 	}
156 156
 
157
-    /**
158
-     * Gets Minimal Live Spotter data
159
-     *
160
-     * @param array $filter
161
-     * @return array the spotter information
162
-     */
157
+	/**
158
+	 * Gets Minimal Live Spotter data
159
+	 *
160
+	 * @param array $filter
161
+	 * @return array the spotter information
162
+	 */
163 163
 	public function getMinLiveMarineData($filter = array())
164 164
 	{
165 165
 		global $globalDBdriver, $globalLiveInterval;
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
 		return $spotter_array;
189 189
 	}
190 190
 
191
-    /**
192
-     * Gets Minimal Live Spotter data since xx seconds
193
-     *
194
-     * @param array $coord
195
-     * @param array $filter
196
-     * @param bool $limit
197
-     * @param string $id
198
-     * @return array the spotter information
199
-     */
191
+	/**
192
+	 * Gets Minimal Live Spotter data since xx seconds
193
+	 *
194
+	 * @param array $coord
195
+	 * @param array $filter
196
+	 * @param bool $limit
197
+	 * @param string $id
198
+	 * @return array the spotter information
199
+	 */
200 200
 	public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false, $id = '')
201 201
 	{
202 202
 		global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive;
@@ -275,14 +275,14 @@  discard block
 block discarded – undo
275 275
 		return $spotter_array;
276 276
 	}
277 277
 
278
-    /**
279
-     * Gets Minimal Live Spotter data since xx seconds
280
-     *
281
-     * @param string $id
282
-     * @param array $filter
283
-     * @param bool $limit
284
-     * @return array the spotter information
285
-     */
278
+	/**
279
+	 * Gets Minimal Live Spotter data since xx seconds
280
+	 *
281
+	 * @param string $id
282
+	 * @param array $filter
283
+	 * @param bool $limit
284
+	 * @return array the spotter information
285
+	 */
286 286
 	public function getMinLastLiveMarineDataByID($id = '',$filter = array(), $limit = false)
287 287
 	{
288 288
 		global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive;
@@ -341,12 +341,12 @@  discard block
 block discarded – undo
341 341
 		return $spotter_array;
342 342
 	}
343 343
 
344
-    /**
345
-     * Gets number of latest data entry
346
-     *
347
-     * @param array $filter
348
-     * @return String number of entry
349
-     */
344
+	/**
345
+	 * Gets number of latest data entry
346
+	 *
347
+	 * @param array $filter
348
+	 * @return String number of entry
349
+	 */
350 350
 	public function getLiveMarineCount($filter = array())
351 351
 	{
352 352
 		global $globalDBdriver, $globalLiveInterval;
@@ -370,13 +370,13 @@  discard block
 block discarded – undo
370 370
 		return $result['nb'];
371 371
 	}
372 372
 
373
-    /**
374
-     * Gets all the spotter information based on the latest data entry and coord
375
-     *
376
-     * @param $coord
377
-     * @param array $filter
378
-     * @return array the spotter information
379
-     */
373
+	/**
374
+	 * Gets all the spotter information based on the latest data entry and coord
375
+	 *
376
+	 * @param $coord
377
+	 * @param array $filter
378
+	 * @return array the spotter information
379
+	 */
380 380
 	public function getLiveMarineDatabyCoord($coord, $filter = array())
381 381
 	{
382 382
 		global $globalDBdriver, $globalLiveInterval;
@@ -399,13 +399,13 @@  discard block
 block discarded – undo
399 399
 		return $spotter_array;
400 400
 	}
401 401
 
402
-    /**
403
-     * Gets all the spotter information based on the latest data entry and coord
404
-     *
405
-     * @param $coord
406
-     * @param array $filter
407
-     * @return array the spotter information
408
-     */
402
+	/**
403
+	 * Gets all the spotter information based on the latest data entry and coord
404
+	 *
405
+	 * @param $coord
406
+	 * @param array $filter
407
+	 * @return array the spotter information
408
+	 */
409 409
 	public function getMinLiveMarineDatabyCoord($coord, $filter = array())
410 410
 	{
411 411
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -473,15 +473,15 @@  discard block
 block discarded – undo
473 473
 		return $spotter_array;
474 474
 	}
475 475
 
476
-    /**
477
-     * Gets all the spotter information based on a user's latitude and longitude
478
-     *
479
-     * @param $lat
480
-     * @param $lng
481
-     * @param $radius
482
-     * @param $interval
483
-     * @return array the spotter information
484
-     */
476
+	/**
477
+	 * Gets all the spotter information based on a user's latitude and longitude
478
+	 *
479
+	 * @param $lat
480
+	 * @param $lng
481
+	 * @param $radius
482
+	 * @param $interval
483
+	 * @return array the spotter information
484
+	 */
485 485
 	public function getLatestMarineForLayar($lat, $lng, $radius, $interval)
486 486
 	{
487 487
 		$Marine = new Marine($this->db);
@@ -538,32 +538,32 @@  discard block
 block discarded – undo
538 538
 	}
539 539
 
540 540
 
541
-    /**
542
-     * Gets all the spotter information based on a particular callsign
543
-     *
544
-     * @param $ident
545
-     * @return array the spotter information
546
-     */
541
+	/**
542
+	 * Gets all the spotter information based on a particular callsign
543
+	 *
544
+	 * @param $ident
545
+	 * @return array the spotter information
546
+	 */
547 547
 	public function getLastLiveMarineDataByIdent($ident)
548 548
 	{
549 549
 		$Marine = new Marine($this->db);
550 550
 		date_default_timezone_set('UTC');
551 551
 
552 552
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
553
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
553
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
554 554
 
555 555
 		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
556 556
 
557 557
 		return $spotter_array;
558 558
 	}
559 559
 
560
-    /**
561
-     * Gets all the spotter information based on a particular callsign
562
-     *
563
-     * @param $ident
564
-     * @param $date
565
-     * @return array the spotter information
566
-     */
560
+	/**
561
+	 * Gets all the spotter information based on a particular callsign
562
+	 *
563
+	 * @param $ident
564
+	 * @param $date
565
+	 * @return array the spotter information
566
+	 */
567 567
 	public function getDateLiveMarineDataByIdent($ident,$date)
568 568
 	{
569 569
 		$Marine = new Marine($this->db);
@@ -575,13 +575,13 @@  discard block
 block discarded – undo
575 575
 		return $spotter_array;
576 576
 	}
577 577
 
578
-    /**
579
-     * Gets all the spotter information based on a particular MMSI
580
-     *
581
-     * @param $mmsi
582
-     * @param $date
583
-     * @return array the spotter information
584
-     */
578
+	/**
579
+	 * Gets all the spotter information based on a particular MMSI
580
+	 *
581
+	 * @param $mmsi
582
+	 * @param $date
583
+	 * @return array the spotter information
584
+	 */
585 585
 	public function getDateLiveMarineDataByMMSI($mmsi,$date)
586 586
 	{
587 587
 		$Marine = new Marine($this->db);
@@ -593,53 +593,53 @@  discard block
 block discarded – undo
593 593
 		return $spotter_array;
594 594
 	}
595 595
 
596
-    /**
597
-     * Gets last spotter information based on a particular callsign
598
-     *
599
-     * @param $id
600
-     * @return array the spotter information
601
-     */
596
+	/**
597
+	 * Gets last spotter information based on a particular callsign
598
+	 *
599
+	 * @param $id
600
+	 * @return array the spotter information
601
+	 */
602 602
 	public function getLastLiveMarineDataById($id)
603 603
 	{
604 604
 		$Marine = new Marine($this->db);
605 605
 		date_default_timezone_set('UTC');
606 606
 
607 607
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
608
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
608
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
609 609
 
610 610
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
611 611
 
612 612
 		return $spotter_array;
613 613
 	}
614 614
 
615
-    /**
616
-     * Gets last spotter information based on a particular callsign
617
-     *
618
-     * @param $id
619
-     * @param $date
620
-     * @return array the spotter information
621
-     */
615
+	/**
616
+	 * Gets last spotter information based on a particular callsign
617
+	 *
618
+	 * @param $id
619
+	 * @param $date
620
+	 * @return array the spotter information
621
+	 */
622 622
 	public function getDateLiveMarineDataById($id,$date)
623 623
 	{
624 624
 		$Marine = new Marine($this->db);
625 625
 		date_default_timezone_set('UTC');
626 626
 
627 627
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
628
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
629
-                $date = date('c',$date);
628
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
629
+				$date = date('c',$date);
630 630
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
631 631
 
632 632
 		return $spotter_array;
633 633
 	}
634 634
 
635 635
 
636
-    /**
637
-     * Gets all the spotter information based on a particular id
638
-     *
639
-     * @param $id
640
-     * @param bool $liveinterval
641
-     * @return array the spotter information
642
-     */
636
+	/**
637
+	 * Gets all the spotter information based on a particular id
638
+	 *
639
+	 * @param $id
640
+	 * @param bool $liveinterval
641
+	 * @return array the spotter information
642
+	 */
643 643
 	public function getAllLiveMarineDataById($id,$liveinterval = false)
644 644
 	{
645 645
 		global $globalDBdriver, $globalLiveInterval;
@@ -667,18 +667,18 @@  discard block
 block discarded – undo
667 667
 		return $spotter_array;
668 668
 	}
669 669
 
670
-    /**
671
-     * Gets all the spotter information based on a particular ident
672
-     *
673
-     * @param $ident
674
-     * @return array the spotter information
675
-     */
670
+	/**
671
+	 * Gets all the spotter information based on a particular ident
672
+	 *
673
+	 * @param $ident
674
+	 * @return array the spotter information
675
+	 */
676 676
 	public function getAllLiveMarineDataByIdent($ident)
677 677
 	{
678 678
 		date_default_timezone_set('UTC');
679 679
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
680 680
 		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
681
-    		try {
681
+			try {
682 682
 			
683 683
 			$sth = $this->db->prepare($query);
684 684
 			$sth->execute(array(':ident' => $ident));
@@ -692,23 +692,23 @@  discard block
 block discarded – undo
692 692
 
693 693
 
694 694
 	/**
695
-	* Deletes all info in the table
696
-	*
697
-	* @return String success or false
698
-	*
699
-	*/
695
+	 * Deletes all info in the table
696
+	 *
697
+	 * @return String success or false
698
+	 *
699
+	 */
700 700
 	public function deleteLiveMarineData()
701 701
 	{
702 702
 		global $globalDBdriver;
703 703
 		if ($globalDBdriver == 'mysql') {
704 704
 			//$query  = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date";
705 705
 			$query  = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 HOUR) >= marine_live.date';
706
-            		//$query  = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";
706
+					//$query  = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";
707 707
 		} else {
708 708
 			$query  = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '12 HOURS' >= marine_live.date";
709 709
 		}
710 710
         
711
-    		try {
711
+			try {
712 712
 			
713 713
 			$sth = $this->db->prepare($query);
714 714
 			$sth->execute();
@@ -720,18 +720,18 @@  discard block
 block discarded – undo
720 720
 	}
721 721
 
722 722
 	/**
723
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
724
-	*
725
-	* @return String success or false
726
-	*
727
-	*/
723
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
724
+	 *
725
+	 * @return String success or false
726
+	 *
727
+	 */
728 728
 	public function deleteLiveMarineDataNotUpdated()
729 729
 	{
730 730
 		global $globalDBdriver, $globalDebug;
731 731
 		if ($globalDBdriver == 'mysql') {
732 732
 			//$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0';
733
-    			$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
734
-    			try {
733
+				$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
734
+				try {
735 735
 				
736 736
 				$sth = $this->db->prepare($query);
737 737
 				$sth->execute();
@@ -739,8 +739,8 @@  discard block
 block discarded – undo
739 739
 				return "error";
740 740
 			}
741 741
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
742
-                        $i = 0;
743
-                        $j =0;
742
+						$i = 0;
743
+						$j =0;
744 744
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
745 745
 			foreach($all as $row)
746 746
 			{
@@ -748,20 +748,20 @@  discard block
 block discarded – undo
748 748
 				$j++;
749 749
 				if ($j == 30) {
750 750
 					if ($globalDebug) echo ".";
751
-				    	try {
751
+						try {
752 752
 						
753 753
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
754 754
 						$sth->execute();
755 755
 					} catch(PDOException $e) {
756 756
 						return "error";
757 757
 					}
758
-                                	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
759
-                                	$j = 0;
758
+									$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
759
+									$j = 0;
760 760
 				}
761 761
 				$query_delete .= "'".$row['fammarine_id']."',";
762 762
 			}
763 763
 			if ($i > 0) {
764
-    				try {
764
+					try {
765 765
 					
766 766
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
767 767
 					$sth->execute();
@@ -772,9 +772,9 @@  discard block
 block discarded – undo
772 772
 			return "success";
773 773
 		} elseif ($globalDBdriver == 'pgsql') {
774 774
 			//$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0";
775
-    			//$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
776
-    			$query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
777
-    			try {
775
+				//$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
776
+				$query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
777
+				try {
778 778
 				
779 779
 				$sth = $this->db->prepare($query);
780 780
 				$sth->execute();
@@ -818,18 +818,18 @@  discard block
 block discarded – undo
818 818
 		return 'error';
819 819
 	}
820 820
 
821
-    /**
822
-     * Deletes all info in the table for an ident
823
-     *
824
-     * @param $ident
825
-     * @return String success or false
826
-     */
821
+	/**
822
+	 * Deletes all info in the table for an ident
823
+	 *
824
+	 * @param $ident
825
+	 * @return String success or false
826
+	 */
827 827
 	public function deleteLiveMarineDataByIdent($ident)
828 828
 	{
829 829
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
830 830
 		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
831 831
         
832
-    		try {
832
+			try {
833 833
 			
834 834
 			$sth = $this->db->prepare($query);
835 835
 			$sth->execute(array(':ident' => $ident));
@@ -840,18 +840,18 @@  discard block
 block discarded – undo
840 840
 		return "success";
841 841
 	}
842 842
 
843
-    /**
844
-     * Deletes all info in the table for an id
845
-     *
846
-     * @param $id
847
-     * @return String success or false
848
-     */
843
+	/**
844
+	 * Deletes all info in the table for an id
845
+	 *
846
+	 * @param $id
847
+	 * @return String success or false
848
+	 */
849 849
 	public function deleteLiveMarineDataById($id)
850 850
 	{
851 851
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
852 852
 		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
853 853
         
854
-    		try {
854
+			try {
855 855
 			
856 856
 			$sth = $this->db->prepare($query);
857 857
 			$sth->execute(array(':id' => $id));
@@ -864,11 +864,11 @@  discard block
 block discarded – undo
864 864
 
865 865
 
866 866
 	/**
867
-	* Gets the marine races
868
-	*
869
-	* @return array all races
870
-	*
871
-	*/
867
+	 * Gets the marine races
868
+	 *
869
+	 * @return array all races
870
+	 *
871
+	 */
872 872
 	public function getAllRaces()
873 873
 	{
874 874
 		$query  = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name';
@@ -877,12 +877,12 @@  discard block
 block discarded – undo
877 877
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
878 878
 	}
879 879
 
880
-    /**
881
-     * Gets the aircraft ident within the last hour
882
-     *
883
-     * @param $ident
884
-     * @return String the ident
885
-     */
880
+	/**
881
+	 * Gets the aircraft ident within the last hour
882
+	 *
883
+	 * @param $ident
884
+	 * @return String the ident
885
+	 */
886 886
 	public function getIdentFromLastHour($ident)
887 887
 	{
888 888
 		global $globalDBdriver;
@@ -908,14 +908,14 @@  discard block
 block discarded – undo
908 908
 			$ident_result = $row['ident'];
909 909
 		}
910 910
 		return $ident_result;
911
-        }
912
-
913
-    /**
914
-     * Check recent aircraft
915
-     *
916
-     * @param $ident
917
-     * @return String the ident
918
-     */
911
+		}
912
+
913
+	/**
914
+	 * Check recent aircraft
915
+	 *
916
+	 * @param $ident
917
+	 * @return String the ident
918
+	 */
919 919
 	public function checkIdentRecent($ident)
920 920
 	{
921 921
 		global $globalDBdriver;
@@ -941,14 +941,14 @@  discard block
 block discarded – undo
941 941
 			$ident_result = $row['fammarine_id'];
942 942
 		}
943 943
 		return $ident_result;
944
-        }
945
-
946
-    /**
947
-     * Check recent aircraft by id
948
-     *
949
-     * @param $id
950
-     * @return String the ident
951
-     */
944
+		}
945
+
946
+	/**
947
+	 * Check recent aircraft by id
948
+	 *
949
+	 * @param $id
950
+	 * @return String the ident
951
+	 */
952 952
 	public function checkIdRecent($id)
953 953
 	{
954 954
 		global $globalDBdriver;
@@ -974,14 +974,14 @@  discard block
 block discarded – undo
974 974
 			$ident_result = $row['fammarine_id'];
975 975
 		}
976 976
 		return $ident_result;
977
-        }
978
-
979
-    /**
980
-     * Check recent aircraft by mmsi
981
-     *
982
-     * @param $mmsi
983
-     * @return String the ident
984
-     */
977
+		}
978
+
979
+	/**
980
+	 * Check recent aircraft by mmsi
981
+	 *
982
+	 * @param $mmsi
983
+	 * @return String the ident
984
+	 */
985 985
 	public function checkMMSIRecent($mmsi)
986 986
 	{
987 987
 		global $globalDBdriver;
@@ -1007,41 +1007,41 @@  discard block
 block discarded – undo
1007 1007
 			$ident_result = $row['fammarine_id'];
1008 1008
 		}
1009 1009
 		return $ident_result;
1010
-        }
1011
-
1012
-    /**
1013
-     * Adds a new spotter data
1014
-     *
1015
-     * @param String $fammarine_id the ID from flightaware
1016
-     * @param String $ident the flight ident
1017
-     * @param string $latitude
1018
-     * @param string $longitude
1019
-     * @param string $heading
1020
-     * @param string $groundspeed
1021
-     * @param string $date
1022
-     * @param bool $putinarchive
1023
-     * @param string $mmsi
1024
-     * @param string $type
1025
-     * @param string $typeid
1026
-     * @param string $imo
1027
-     * @param string $callsign
1028
-     * @param string $arrival_code
1029
-     * @param string $arrival_date
1030
-     * @param string $status
1031
-     * @param string $statusid
1032
-     * @param bool $noarchive
1033
-     * @param string $format_source
1034
-     * @param string $source_name
1035
-     * @param string $over_country
1036
-     * @param string $captain_id
1037
-     * @param string $captain_name
1038
-     * @param string $race_id
1039
-     * @param string $race_name
1040
-     * @param string $distance
1041
-     * @param string $race_rank
1042
-     * @param string $race_time
1043
-     * @return String success or false
1044
-     */
1010
+		}
1011
+
1012
+	/**
1013
+	 * Adds a new spotter data
1014
+	 *
1015
+	 * @param String $fammarine_id the ID from flightaware
1016
+	 * @param String $ident the flight ident
1017
+	 * @param string $latitude
1018
+	 * @param string $longitude
1019
+	 * @param string $heading
1020
+	 * @param string $groundspeed
1021
+	 * @param string $date
1022
+	 * @param bool $putinarchive
1023
+	 * @param string $mmsi
1024
+	 * @param string $type
1025
+	 * @param string $typeid
1026
+	 * @param string $imo
1027
+	 * @param string $callsign
1028
+	 * @param string $arrival_code
1029
+	 * @param string $arrival_date
1030
+	 * @param string $status
1031
+	 * @param string $statusid
1032
+	 * @param bool $noarchive
1033
+	 * @param string $format_source
1034
+	 * @param string $source_name
1035
+	 * @param string $over_country
1036
+	 * @param string $captain_id
1037
+	 * @param string $captain_name
1038
+	 * @param string $race_id
1039
+	 * @param string $race_name
1040
+	 * @param string $distance
1041
+	 * @param string $race_rank
1042
+	 * @param string $race_time
1043
+	 * @return String success or false
1044
+	 */
1045 1045
 	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '')
1046 1046
 	{
1047 1047
 		global $globalArchive, $globalDebug;
@@ -1123,10 +1123,10 @@  discard block
 block discarded – undo
1123 1123
 		if ($statusid == '') $statusid = NULL;
1124 1124
 		if ($distance == '') $distance = NULL;
1125 1125
 
1126
-            	//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1127
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1128
-            	if ($arrival_date == '') $arrival_date = NULL;
1129
-            	$query = '';
1126
+				//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1127
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1128
+				if ($arrival_date == '') $arrival_date = NULL;
1129
+				$query = '';
1130 1130
 		if ($globalArchive) {
1131 1131
 			if ($globalDebug) echo '-- Delete previous data -- ';
1132 1132
 			$query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';
Please login to merge, or discard this patch.
Spacing   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -27,33 +27,33 @@  discard block
 block discarded – undo
27 27
      * @param bool $and
28 28
      * @return string the SQL part
29 29
      */
30
-	public function getFilter($filter = array(),$where = false,$and = false) {
30
+	public function getFilter($filter = array(), $where = false, $and = false) {
31 31
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
32 32
 		$filters = array();
33 33
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
34 34
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
35 35
 				$filters = $globalStatsFilters[$globalFilterName];
36 36
 			} else {
37
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
37
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
38 38
 			}
39 39
 		}
40 40
 		if (isset($filter[0]['source'])) {
41
-			$filters = array_merge($filters,$filter);
41
+			$filters = array_merge($filters, $filter);
42 42
 		}
43
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
43
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
44 44
 		$filter_query_join = '';
45 45
 		$filter_query_where = '';
46
-		foreach($filters as $flt) {
46
+		foreach ($filters as $flt) {
47 47
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
48 48
 				if (isset($flt['source'])) {
49
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
49
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
50 50
 				} else {
51
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
51
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
52 52
 				}
53 53
 			}
54 54
 		}
55 55
 		if (isset($filter['source']) && !empty($filter['source'])) {
56
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
56
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
57 57
 		}
58 58
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
59 59
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
 					$filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
92 92
 				}
93 93
 			}
94
-			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
94
+			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
95 95
 		}
96 96
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
97
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
97
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
98 98
 		}
99 99
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
100 100
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
101 101
 		if ($filter_query_where != '') {
102
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
102
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
103 103
 		}
104 104
 		$filter_query = $filter_query_join.$filter_query_where;
105 105
 		return $filter_query;
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
 		if ($limit != '')
125 125
 		{
126 126
 			$limit_array = explode(',', $limit);
127
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
128
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
127
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
128
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
129 129
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
130 130
 			{
131 131
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
141 141
 			}
142 142
 		}
143
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
143
+		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
144 144
 
145 145
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
146 146
 		if ($globalDBdriver == 'mysql') {
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		} else {
150 150
 			$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query;
151 151
 		}
152
-		$spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true);
152
+		$spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true);
153 153
 
154 154
 		return $spotter_array;
155 155
 	}
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 		global $globalDBdriver, $globalLiveInterval;
166 166
 		date_default_timezone_set('UTC');
167 167
 
168
-		$filter_query = $this->getFilter($filter,true,true);
168
+		$filter_query = $this->getFilter($filter, true, true);
169 169
 
170 170
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
171 171
 		if ($globalDBdriver == 'mysql') {
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 		try {
180 180
 			$sth = $this->db->prepare($query);
181 181
 			$sth->execute();
182
-		} catch(PDOException $e) {
182
+		} catch (PDOException $e) {
183 183
 			echo $e->getMessage();
184 184
 			die;
185 185
 		}
@@ -197,26 +197,26 @@  discard block
 block discarded – undo
197 197
      * @param string $id
198 198
      * @return array the spotter information
199 199
      */
200
-	public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false, $id = '')
200
+	public function getMinLastLiveMarineData($coord = array(), $filter = array(), $limit = false, $id = '')
201 201
 	{
202 202
 		global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive;
203 203
 		date_default_timezone_set('UTC');
204 204
 		$usecoord = false;
205 205
 		if (is_array($coord) && !empty($coord)) {
206
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
207
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
208
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
209
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
206
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
207
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
208
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
209
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
210 210
 			$usecoord = true;
211 211
 		}
212
-		$id = filter_var($id,FILTER_SANITIZE_STRING);
213
-		$filter_query = $this->getFilter($filter,true,true);
212
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
213
+		$filter_query = $this->getFilter($filter, true, true);
214 214
 
215 215
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
216 216
 		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
217 217
 		if ($globalDBdriver == 'mysql') {
218 218
 			if (isset($globalArchive) && $globalArchive === TRUE) {
219
-				$query  = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name 
219
+				$query = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name 
220 220
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
221 221
 				if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
222 222
 				if ($id != '') $query .= "OR marine_archive.fammarine_id = :id ";
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 				    ORDER BY fammarine_id, date";
231 231
 				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
232 232
 			} else {
233
-				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
233
+				$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
234 234
 				    FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date ";
235 235
 				if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
236 236
 				if ($id != '') $query .= "OR marine_live.fammarine_id = :id ";
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 			}
241 241
 		} else {
242 242
 			if (isset($globalArchive) && $globalArchive === TRUE) {
243
-				$query  = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name 
243
+				$query = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name 
244 244
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
245 245
 				if ($usecoord) $query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
246 246
 				if ($id != '') $query .= "OR marine_archive.fammarine_id = :id ";
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 		try {
268 268
 			$sth = $this->db->prepare($query);
269 269
 			$sth->execute($query_values);
270
-		} catch(PDOException $e) {
270
+		} catch (PDOException $e) {
271 271
 			echo $e->getMessage();
272 272
 			die;
273 273
 		}
@@ -283,12 +283,12 @@  discard block
 block discarded – undo
283 283
      * @param bool $limit
284 284
      * @return array the spotter information
285 285
      */
286
-	public function getMinLastLiveMarineDataByID($id = '',$filter = array(), $limit = false)
286
+	public function getMinLastLiveMarineDataByID($id = '', $filter = array(), $limit = false)
287 287
 	{
288 288
 		global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive;
289 289
 		date_default_timezone_set('UTC');
290
-		$id = filter_var($id,FILTER_SANITIZE_STRING);
291
-		$filter_query = $this->getFilter($filter,true,true);
290
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
291
+		$filter_query = $this->getFilter($filter, true, true);
292 292
 
293 293
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
294 294
 		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 		try {
334 334
 			$sth = $this->db->prepare($query);
335 335
 			$sth->execute($query_values);
336
-		} catch(PDOException $e) {
336
+		} catch (PDOException $e) {
337 337
 			echo $e->getMessage();
338 338
 			die;
339 339
 		}
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 	public function getLiveMarineCount($filter = array())
351 351
 	{
352 352
 		global $globalDBdriver, $globalLiveInterval;
353
-		$filter_query = $this->getFilter($filter,true,true);
353
+		$filter_query = $this->getFilter($filter, true, true);
354 354
 
355 355
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
356 356
 		if ($globalDBdriver == 'mysql') {
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 		try {
362 362
 			$sth = $this->db->prepare($query);
363 363
 			$sth->execute();
364
-		} catch(PDOException $e) {
364
+		} catch (PDOException $e) {
365 365
 			echo $e->getMessage();
366 366
 			die;
367 367
 		}
@@ -385,10 +385,10 @@  discard block
 block discarded – undo
385 385
 		$filter_query = $this->getFilter($filter);
386 386
 
387 387
 		if (is_array($coord)) {
388
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
389
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
390
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
391
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
388
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
389
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
390
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
391
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
392 392
 		} else return array();
393 393
 		if ($globalDBdriver == 'mysql') {
394 394
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id ORDER BY date DESC'.$filter_query;
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
412 412
 		$Marine = new Marine($this->db);
413 413
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
414
-		$filter_query = $this->getFilter($filter,true,true);
414
+		$filter_query = $this->getFilter($filter, true, true);
415 415
 
416 416
 		if (is_array($coord)) {
417
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
418
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
419
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
420
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
417
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
418
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
419
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
420
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
421 421
 		} else return array();
422 422
 		/*
423 423
 		if ($globalDBdriver == 'mysql') {
@@ -432,13 +432,13 @@  discard block
 block discarded – undo
432 432
 		*/
433 433
 		if ($globalDBdriver == 'mysql') {
434 434
 			if (isset($globalArchive) && $globalArchive === TRUE) {
435
-				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
435
+				$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
436 436
 				    FROM marine_live 
437 437
 				    '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= marine_live.date 
438 438
 				    AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
439 439
 				    AND marine_live.latitude <> 0 AND marine_live.longitude <> 0 ORDER BY race_rank,date DESC';
440 440
 			} else {
441
-				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
441
+				$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
442 442
 				    FROM marine_live 
443 443
 				    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate 
444 444
 				    FROM marine_live l 
@@ -450,14 +450,14 @@  discard block
 block discarded – undo
450 450
 			}
451 451
 		} else {
452 452
 			if (isset($globalArchive) && $globalArchive === TRUE) {
453
-				$query  = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
453
+				$query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
454 454
 				    FROM marine_live 
455 455
 				    ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date 
456 456
 				    AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
457 457
 				    AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
458 458
 				    AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' ORDER BY race_rank, date DESC";
459 459
 			} else {
460
-				$query  = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
460
+				$query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
461 461
 				    FROM marine_live 
462 462
 				    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate 
463 463
 				    FROM marine_live l 
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 				if ($interval == '1m')
518 518
 				{
519 519
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
520
-				} else if ($interval == '15m'){
520
+				} else if ($interval == '15m') {
521 521
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
522 522
 				}
523 523
 			}
@@ -525,14 +525,14 @@  discard block
 block discarded – undo
525 525
 			$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
526 526
 		}
527 527
 
528
-		$query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
528
+		$query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
529 529
                    WHERE marine_live.latitude <> '' 
530 530
                                    AND marine_live.longitude <> '' 
531 531
                    ".$additional_query."
532 532
                    HAVING distance < :radius  
533 533
                                    ORDER BY distance";
534 534
 
535
-		$spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
535
+		$spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
536 536
 
537 537
 		return $spotter_array;
538 538
 	}
@@ -550,9 +550,9 @@  discard block
 block discarded – undo
550 550
 		date_default_timezone_set('UTC');
551 551
 
552 552
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
553
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
553
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
554 554
 
555
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
555
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true);
556 556
 
557 557
 		return $spotter_array;
558 558
 	}
@@ -564,14 +564,14 @@  discard block
 block discarded – undo
564 564
      * @param $date
565 565
      * @return array the spotter information
566 566
      */
567
-	public function getDateLiveMarineDataByIdent($ident,$date)
567
+	public function getDateLiveMarineDataByIdent($ident, $date)
568 568
 	{
569 569
 		$Marine = new Marine($this->db);
570 570
 		date_default_timezone_set('UTC');
571 571
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
572 572
 		$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
573
-		$date = date('c',$date);
574
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
573
+		$date = date('c', $date);
574
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
575 575
 		return $spotter_array;
576 576
 	}
577 577
 
@@ -582,14 +582,14 @@  discard block
 block discarded – undo
582 582
      * @param $date
583 583
      * @return array the spotter information
584 584
      */
585
-	public function getDateLiveMarineDataByMMSI($mmsi,$date)
585
+	public function getDateLiveMarineDataByMMSI($mmsi, $date)
586 586
 	{
587 587
 		$Marine = new Marine($this->db);
588 588
 		date_default_timezone_set('UTC');
589 589
 		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
590 590
 		$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.mmsi = :mmsi AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
591
-		$date = date('c',$date);
592
-		$spotter_array = $Marine->getDataFromDB($query,array(':mmsi' => $mmsi,':date' => $date));
591
+		$date = date('c', $date);
592
+		$spotter_array = $Marine->getDataFromDB($query, array(':mmsi' => $mmsi, ':date' => $date));
593 593
 		return $spotter_array;
594 594
 	}
595 595
 
@@ -605,9 +605,9 @@  discard block
 block discarded – undo
605 605
 		date_default_timezone_set('UTC');
606 606
 
607 607
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
608
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
608
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
609 609
 
610
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
610
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true);
611 611
 
612 612
 		return $spotter_array;
613 613
 	}
@@ -619,15 +619,15 @@  discard block
 block discarded – undo
619 619
      * @param $date
620 620
      * @return array the spotter information
621 621
      */
622
-	public function getDateLiveMarineDataById($id,$date)
622
+	public function getDateLiveMarineDataById($id, $date)
623 623
 	{
624 624
 		$Marine = new Marine($this->db);
625 625
 		date_default_timezone_set('UTC');
626 626
 
627 627
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
628
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
629
-                $date = date('c',$date);
630
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
628
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
629
+                $date = date('c', $date);
630
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
631 631
 
632 632
 		return $spotter_array;
633 633
 	}
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
      * @param bool $liveinterval
641 641
      * @return array the spotter information
642 642
      */
643
-	public function getAllLiveMarineDataById($id,$liveinterval = false)
643
+	public function getAllLiveMarineDataById($id, $liveinterval = false)
644 644
 	{
645 645
 		global $globalDBdriver, $globalLiveInterval;
646 646
 		date_default_timezone_set('UTC');
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 		try {
660 660
 			$sth = $this->db->prepare($query);
661 661
 			$sth->execute(array(':id' => $id));
662
-		} catch(PDOException $e) {
662
+		} catch (PDOException $e) {
663 663
 			echo $e->getMessage();
664 664
 			die;
665 665
 		}
@@ -677,12 +677,12 @@  discard block
 block discarded – undo
677 677
 	{
678 678
 		date_default_timezone_set('UTC');
679 679
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
680
-		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
680
+		$query = self::$global_query.' WHERE marine_live.ident = :ident';
681 681
     		try {
682 682
 			
683 683
 			$sth = $this->db->prepare($query);
684 684
 			$sth->execute(array(':ident' => $ident));
685
-		} catch(PDOException $e) {
685
+		} catch (PDOException $e) {
686 686
 			echo $e->getMessage();
687 687
 			die;
688 688
 		}
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 			
713 713
 			$sth = $this->db->prepare($query);
714 714
 			$sth->execute();
715
-		} catch(PDOException $e) {
715
+		} catch (PDOException $e) {
716 716
 			return "error";
717 717
 		}
718 718
 
@@ -735,14 +735,14 @@  discard block
 block discarded – undo
735 735
 				
736 736
 				$sth = $this->db->prepare($query);
737 737
 				$sth->execute();
738
-			} catch(PDOException $e) {
738
+			} catch (PDOException $e) {
739 739
 				return "error";
740 740
 			}
741 741
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
742 742
                         $i = 0;
743
-                        $j =0;
743
+                        $j = 0;
744 744
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
745
-			foreach($all as $row)
745
+			foreach ($all as $row)
746 746
 			{
747 747
 				$i++;
748 748
 				$j++;
@@ -750,9 +750,9 @@  discard block
 block discarded – undo
750 750
 					if ($globalDebug) echo ".";
751 751
 				    	try {
752 752
 						
753
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
753
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
754 754
 						$sth->execute();
755
-					} catch(PDOException $e) {
755
+					} catch (PDOException $e) {
756 756
 						return "error";
757 757
 					}
758 758
                                 	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
@@ -763,9 +763,9 @@  discard block
 block discarded – undo
763 763
 			if ($i > 0) {
764 764
     				try {
765 765
 					
766
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
766
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
767 767
 					$sth->execute();
768
-				} catch(PDOException $e) {
768
+				} catch (PDOException $e) {
769 769
 					return "error";
770 770
 				}
771 771
 			}
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 				
779 779
 				$sth = $this->db->prepare($query);
780 780
 				$sth->execute();
781
-			} catch(PDOException $e) {
781
+			} catch (PDOException $e) {
782 782
 				return "error";
783 783
 			}
784 784
 /*			$query_delete = "DELETE FROM marine_live WHERE fammarine_id IN (";
@@ -827,13 +827,13 @@  discard block
 block discarded – undo
827 827
 	public function deleteLiveMarineDataByIdent($ident)
828 828
 	{
829 829
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
830
-		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
830
+		$query = 'DELETE FROM marine_live WHERE ident = :ident';
831 831
         
832 832
     		try {
833 833
 			
834 834
 			$sth = $this->db->prepare($query);
835 835
 			$sth->execute(array(':ident' => $ident));
836
-		} catch(PDOException $e) {
836
+		} catch (PDOException $e) {
837 837
 			return "error";
838 838
 		}
839 839
 
@@ -849,13 +849,13 @@  discard block
 block discarded – undo
849 849
 	public function deleteLiveMarineDataById($id)
850 850
 	{
851 851
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
852
-		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
852
+		$query = 'DELETE FROM marine_live WHERE fammarine_id = :id';
853 853
         
854 854
     		try {
855 855
 			
856 856
 			$sth = $this->db->prepare($query);
857 857
 			$sth->execute(array(':id' => $id));
858
-		} catch(PDOException $e) {
858
+		} catch (PDOException $e) {
859 859
 			return "error";
860 860
 		}
861 861
 
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 	*/
872 872
 	public function getAllRaces()
873 873
 	{
874
-		$query  = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name';
874
+		$query = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name';
875 875
 		$sth = $this->db->prepare($query);
876 876
 		$sth->execute();
877 877
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -887,13 +887,13 @@  discard block
 block discarded – undo
887 887
 	{
888 888
 		global $globalDBdriver;
889 889
 		if ($globalDBdriver == 'mysql') {
890
-			$query  = 'SELECT marine_live.ident FROM marine_live 
890
+			$query = 'SELECT marine_live.ident FROM marine_live 
891 891
 				WHERE marine_live.ident = :ident 
892 892
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
893 893
 				AND marine_live.date < UTC_TIMESTAMP()';
894 894
 			$query_data = array(':ident' => $ident);
895 895
 		} else {
896
-			$query  = "SELECT marine_live.ident FROM marine_live 
896
+			$query = "SELECT marine_live.ident FROM marine_live 
897 897
 				WHERE marine_live.ident = :ident 
898 898
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
899 899
 				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -902,8 +902,8 @@  discard block
 block discarded – undo
902 902
 		
903 903
 		$sth = $this->db->prepare($query);
904 904
 		$sth->execute($query_data);
905
-		$ident_result='';
906
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
905
+		$ident_result = '';
906
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
907 907
 		{
908 908
 			$ident_result = $row['ident'];
909 909
 		}
@@ -920,13 +920,13 @@  discard block
 block discarded – undo
920 920
 	{
921 921
 		global $globalDBdriver;
922 922
 		if ($globalDBdriver == 'mysql') {
923
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
923
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
924 924
 				WHERE marine_live.ident = :ident 
925 925
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
926 926
 //				AND marine_live.date < UTC_TIMESTAMP()";
927 927
 			$query_data = array(':ident' => $ident);
928 928
 		} else {
929
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
929
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
930 930
 				WHERE marine_live.ident = :ident 
931 931
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
932 932
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -935,8 +935,8 @@  discard block
 block discarded – undo
935 935
 		
936 936
 		$sth = $this->db->prepare($query);
937 937
 		$sth->execute($query_data);
938
-		$ident_result='';
939
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
938
+		$ident_result = '';
939
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
940 940
 		{
941 941
 			$ident_result = $row['fammarine_id'];
942 942
 		}
@@ -953,13 +953,13 @@  discard block
 block discarded – undo
953 953
 	{
954 954
 		global $globalDBdriver;
955 955
 		if ($globalDBdriver == 'mysql') {
956
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
956
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
957 957
 				WHERE marine_live.fammarine_id = :id 
958 958
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
959 959
 //				AND marine_live.date < UTC_TIMESTAMP()";
960 960
 			$query_data = array(':id' => $id);
961 961
 		} else {
962
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
962
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
963 963
 				WHERE marine_live.fammarine_id = :id 
964 964
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
965 965
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -968,8 +968,8 @@  discard block
 block discarded – undo
968 968
 		
969 969
 		$sth = $this->db->prepare($query);
970 970
 		$sth->execute($query_data);
971
-		$ident_result='';
972
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
971
+		$ident_result = '';
972
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
973 973
 		{
974 974
 			$ident_result = $row['fammarine_id'];
975 975
 		}
@@ -986,13 +986,13 @@  discard block
 block discarded – undo
986 986
 	{
987 987
 		global $globalDBdriver;
988 988
 		if ($globalDBdriver == 'mysql') {
989
-			$query  = 'SELECT marine_live.fammarine_id FROM marine_live 
989
+			$query = 'SELECT marine_live.fammarine_id FROM marine_live 
990 990
 				WHERE marine_live.mmsi = :mmsi 
991 991
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
992 992
 //				AND marine_live.date < UTC_TIMESTAMP()";
993 993
 			$query_data = array(':mmsi' => $mmsi);
994 994
 		} else {
995
-			$query  = "SELECT marine_live.fammarine_id FROM marine_live 
995
+			$query = "SELECT marine_live.fammarine_id FROM marine_live 
996 996
 				WHERE marine_live.mmsi = :mmsi 
997 997
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
998 998
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -1001,8 +1001,8 @@  discard block
 block discarded – undo
1001 1001
 		
1002 1002
 		$sth = $this->db->prepare($query);
1003 1003
 		$sth->execute($query_data);
1004
-		$ident_result='';
1005
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1004
+		$ident_result = '';
1005
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1006 1006
 		{
1007 1007
 			$ident_result = $row['fammarine_id'];
1008 1008
 		}
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
      * @param string $race_time
1043 1043
      * @return String success or false
1044 1044
      */
1045
-	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '')
1045
+	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '')
1046 1046
 	{
1047 1047
 		global $globalArchive, $globalDebug;
1048 1048
 		$Common = new Common();
@@ -1094,39 +1094,39 @@  discard block
 block discarded – undo
1094 1094
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
1095 1095
 
1096 1096
         
1097
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1098
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1099
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1100
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1101
-		$distance = filter_var($distance,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1102
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1103
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1104
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1105
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
1106
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
1107
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
1108
-		$typeid = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT);
1109
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
1110
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
1111
-		$statusid = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT);
1112
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
1113
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
1114
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
1115
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
1116
-		$captain_id = filter_var($captain_id,FILTER_SANITIZE_STRING);
1117
-		$captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING);
1118
-		$race_id = filter_var($race_id,FILTER_SANITIZE_STRING);
1119
-		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
1120
-		$race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT);
1097
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1098
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1099
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1100
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1101
+		$distance = filter_var($distance, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1102
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1103
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1104
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1105
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
1106
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
1107
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
1108
+		$typeid = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT);
1109
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
1110
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
1111
+		$statusid = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT);
1112
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
1113
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
1114
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
1115
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
1116
+		$captain_id = filter_var($captain_id, FILTER_SANITIZE_STRING);
1117
+		$captain_name = filter_var($captain_name, FILTER_SANITIZE_STRING);
1118
+		$race_id = filter_var($race_id, FILTER_SANITIZE_STRING);
1119
+		$race_name = filter_var($race_name, FILTER_SANITIZE_STRING);
1120
+		$race_rank = filter_var($race_rank, FILTER_SANITIZE_NUMBER_INT);
1121 1121
 		if ($race_rank == '') $race_rank = NULL;
1122
-		$race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1122
+		$race_time = filter_var($race_time, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1123 1123
 		if ($race_time == '') $race_time = NULL;
1124 1124
 		if ($typeid == '') $typeid = NULL;
1125 1125
 		if ($statusid == '') $statusid = NULL;
1126 1126
 		if ($distance == '') $distance = NULL;
1127 1127
 
1128 1128
             	//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1129
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1129
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1130 1130
             	if ($arrival_date == '') $arrival_date = NULL;
1131 1131
             	$query = '';
1132 1132
 		if ($globalArchive) {
@@ -1135,19 +1135,19 @@  discard block
 block discarded – undo
1135 1135
 		}
1136 1136
 		$query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) 
1137 1137
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:typeid,:status,:statusid,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name,:distance,:race_rank,:race_time)';
1138
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':typeid' => $typeid,':status' => $status,':statusid' => $statusid,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_time' => $race_time,':race_rank' => $race_rank);
1138
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':typeid' => $typeid, ':status' => $status, ':statusid' => $statusid, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_time' => $race_time, ':race_rank' => $race_rank);
1139 1139
 		try {
1140 1140
 			$sth = $this->db->prepare($query);
1141 1141
 			$sth->execute($query_values);
1142 1142
 			$sth->closeCursor();
1143
-		} catch(PDOException $e) {
1143
+		} catch (PDOException $e) {
1144 1144
 			return "error : ".$e->getMessage();
1145 1145
 		}
1146 1146
 		
1147 1147
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1148 1148
 			if ($globalDebug) echo '(Add to Marine archive : ';
1149 1149
 			$MarineArchive = new MarineArchive($this->db);
1150
-			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source, $source_name, $over_country,$captain_id,$captain_name,$race_id,$race_name,$distance,$race_rank,$race_time);
1150
+			$result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country, $captain_id, $captain_name, $race_id, $race_name, $distance, $race_rank, $race_time);
1151 1151
 			if ($globalDebug) echo $result.')';
1152 1152
 		}
1153 1153
 		return "success";
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 
1156 1156
 	public function getOrderBy()
1157 1157
 	{
1158
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
1158
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
1159 1159
 		return $orderby;
1160 1160
 	}
1161 1161
 
Please login to merge, or discard this patch.
Braces   +164 added lines, -55 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 	public function __construct($dbc = null) {
17 17
 		$Connection = new Connection($dbc);
18 18
 		$this->db = $Connection->db();
19
-		if ($this->db === null) die('Error: No DB connection. (MarineLive)');
19
+		if ($this->db === null) {
20
+			die('Error: No DB connection. (MarineLive)');
21
+		}
20 22
 	}
21 23
 
22 24
 
@@ -40,7 +42,9 @@  discard block
 block discarded – undo
40 42
 		if (isset($filter[0]['source'])) {
41 43
 			$filters = array_merge($filters,$filter);
42 44
 		}
43
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
45
+		if (is_array($globalFilter)) {
46
+			$filter = array_merge($filter,$globalFilter);
47
+		}
44 48
 		$filter_query_join = '';
45 49
 		$filter_query_where = '';
46 50
 		foreach($filters as $flt) {
@@ -96,8 +100,11 @@  discard block
 block discarded – undo
96 100
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
97 101
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
98 102
 		}
99
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
100
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
103
+		if ($filter_query_where == '' && $where) {
104
+			$filter_query_where = ' WHERE';
105
+		} elseif ($filter_query_where != '' && $and) {
106
+			$filter_query_where .= ' AND';
107
+		}
101 108
 		if ($filter_query_where != '') {
102 109
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
103 110
 		}
@@ -140,9 +147,13 @@  discard block
 block discarded – undo
140 147
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
141 148
 			}
142 149
 		}
143
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
150
+		if ($orderby_query == '') {
151
+			$orderby_query= ' ORDER BY date DESC';
152
+		}
144 153
 
145
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
154
+		if (!isset($globalLiveInterval)) {
155
+			$globalLiveInterval = '200';
156
+		}
146 157
 		if ($globalDBdriver == 'mysql') {
147 158
 			//$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate";
148 159
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -167,7 +178,9 @@  discard block
 block discarded – undo
167 178
 
168 179
 		$filter_query = $this->getFilter($filter,true,true);
169 180
 
170
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
181
+		if (!isset($globalLiveInterval)) {
182
+			$globalLiveInterval = '200';
183
+		}
171 184
 		if ($globalDBdriver == 'mysql') {
172 185
 			$query  = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
173 186
 			FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0 ORDER BY marine_live.race_rank";
@@ -212,58 +225,96 @@  discard block
 block discarded – undo
212 225
 		$id = filter_var($id,FILTER_SANITIZE_STRING);
213 226
 		$filter_query = $this->getFilter($filter,true,true);
214 227
 
215
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
216
-		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
228
+		if (!isset($globalLiveInterval)) {
229
+			$globalLiveInterval = '200';
230
+		}
231
+		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') {
232
+			$globalMap3DMarinesLimit = '300';
233
+		}
217 234
 		if ($globalDBdriver == 'mysql') {
218 235
 			if (isset($globalArchive) && $globalArchive === TRUE) {
219 236
 				$query  = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name 
220 237
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
221
-				if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
222
-				if ($id != '') $query .= "OR marine_archive.fammarine_id = :id ";
238
+				if ($usecoord) {
239
+					$query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
240
+				}
241
+				if ($id != '') {
242
+					$query .= "OR marine_archive.fammarine_id = :id ";
243
+				}
223 244
 				$query .= "UNION
224 245
 				    SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
225 246
 				    FROM marine_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date";
226
-				if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
227
-				if ($id != '') $query .= "OR marine_live.fammarine_id = :id ";
247
+				if ($usecoord) {
248
+					$query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
249
+				}
250
+				if ($id != '') {
251
+					$query .= "OR marine_live.fammarine_id = :id ";
252
+				}
228 253
 				$query .= ") AS marine 
229 254
 				    WHERE latitude <> '0' AND longitude <> '0' 
230 255
 				    ORDER BY fammarine_id, date";
231
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
256
+				if ($limit) {
257
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
258
+				}
232 259
 			} else {
233 260
 				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
234 261
 				    FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date ";
235
-				if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
236
-				if ($id != '') $query .= "OR marine_live.fammarine_id = :id ";
262
+				if ($usecoord) {
263
+					$query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
264
+				}
265
+				if ($id != '') {
266
+					$query .= "OR marine_live.fammarine_id = :id ";
267
+				}
237 268
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
238 269
 				ORDER BY marine_live.fammarine_id, marine_live.date";
239
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
270
+				if ($limit) {
271
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
272
+				}
240 273
 			}
241 274
 		} else {
242 275
 			if (isset($globalArchive) && $globalArchive === TRUE) {
243 276
 				$query  = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name 
244 277
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
245
-				if ($usecoord) $query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
246
-				if ($id != '') $query .= "OR marine_archive.fammarine_id = :id ";
278
+				if ($usecoord) {
279
+					$query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
280
+				}
281
+				if ($id != '') {
282
+					$query .= "OR marine_archive.fammarine_id = :id ";
283
+				}
247 284
 				$query .= "UNION
248 285
 				    SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
249 286
 				    FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date";
250
-				if ($usecoord) $query .= " AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
251
-				if ($id != '') $query .= " OR marine_live.fammarine_id = :id";
287
+				if ($usecoord) {
288
+					$query .= " AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
289
+				}
290
+				if ($id != '') {
291
+					$query .= " OR marine_live.fammarine_id = :id";
292
+				}
252 293
 				$query .= ") AS marine WHERE latitude <> '0' AND longitude <> '0' ";
253 294
 				$query .= "ORDER BY fammarine_id, date";
254
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
295
+				if ($limit) {
296
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
297
+				}
255 298
 			} else {
256 299
 				$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
257 300
 				    FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date ";
258
-				if ($usecoord) $query .= "AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
259
-				if ($id != '') $query .= "OR marine_live.fammarine_id = :id ";
301
+				if ($usecoord) {
302
+					$query .= "AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
303
+				}
304
+				if ($id != '') {
305
+					$query .= "OR marine_live.fammarine_id = :id ";
306
+				}
260 307
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
261 308
 				ORDER BY marine_live.fammarine_id, marine_live.date";
262
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
309
+				if ($limit) {
310
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
311
+				}
263 312
 			}
264 313
 		}
265 314
 		$query_values = array();
266
-		if ($id != '') $query_values = array(':id' => $id);
315
+		if ($id != '') {
316
+			$query_values = array(':id' => $id);
317
+		}
267 318
 		try {
268 319
 			$sth = $this->db->prepare($query);
269 320
 			$sth->execute($query_values);
@@ -290,8 +341,12 @@  discard block
 block discarded – undo
290 341
 		$id = filter_var($id,FILTER_SANITIZE_STRING);
291 342
 		$filter_query = $this->getFilter($filter,true,true);
292 343
 
293
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
294
-		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
344
+		if (!isset($globalLiveInterval)) {
345
+			$globalLiveInterval = '200';
346
+		}
347
+		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') {
348
+			$globalMap3DMarinesLimit = '300';
349
+		}
295 350
 		if ($globalDBdriver == 'mysql') {
296 351
 			if (isset($globalArchive) && $globalArchive === TRUE) {
297 352
 				$query  = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name, marine_archive.race_id, marine_archive.race_rank, marine_archive.race_name 
@@ -302,13 +357,17 @@  discard block
 block discarded – undo
302 357
 				$query .= ") AS marine 
303 358
 				    WHERE latitude <> '0' AND longitude <> '0' 
304 359
 				    ORDER BY fammarine_id, date";
305
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
360
+				if ($limit) {
361
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
362
+				}
306 363
 			} else {
307 364
 				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
308 365
 				    FROM marine_live'.$filter_query.' marine_live.fammarine_id = :id ';
309 366
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
310 367
 				ORDER BY marine_live.fammarine_id, marine_live.date";
311
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
368
+				if ($limit) {
369
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
370
+				}
312 371
 			}
313 372
 		} else {
314 373
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -320,13 +379,17 @@  discard block
 block discarded – undo
320 379
 				$query .= ") AS marine 
321 380
 				    WHERE latitude <> '0' AND longitude <> '0' 
322 381
 				    ORDER BY fammarine_id, date";
323
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
382
+				if ($limit) {
383
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
384
+				}
324 385
 			} else {
325 386
 				$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name, marine_live.race_id, marine_live.race_rank, marine_live.race_name 
326 387
 				    FROM marine_live".$filter_query." marine_live.fammarine_id = :id ";
327 388
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
328 389
 				ORDER BY marine_live.fammarine_id, marine_live.date";
329
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
390
+				if ($limit) {
391
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
392
+				}
330 393
 			}
331 394
 		}
332 395
 		$query_values = array(':id' => $id);
@@ -352,7 +415,9 @@  discard block
 block discarded – undo
352 415
 		global $globalDBdriver, $globalLiveInterval;
353 416
 		$filter_query = $this->getFilter($filter,true,true);
354 417
 
355
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
418
+		if (!isset($globalLiveInterval)) {
419
+			$globalLiveInterval = '200';
420
+		}
356 421
 		if ($globalDBdriver == 'mysql') {
357 422
 			$query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
358 423
 		} else {
@@ -381,7 +446,9 @@  discard block
 block discarded – undo
381 446
 	{
382 447
 		global $globalDBdriver, $globalLiveInterval;
383 448
 		$Marine = new Marine($this->db);
384
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
449
+		if (!isset($globalLiveInterval)) {
450
+			$globalLiveInterval = '200';
451
+		}
385 452
 		$filter_query = $this->getFilter($filter);
386 453
 
387 454
 		if (is_array($coord)) {
@@ -389,7 +456,9 @@  discard block
 block discarded – undo
389 456
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
390 457
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
391 458
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
392
-		} else return array();
459
+		} else {
460
+			return array();
461
+		}
393 462
 		if ($globalDBdriver == 'mysql') {
394 463
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id ORDER BY date DESC'.$filter_query;
395 464
 		} else {
@@ -410,7 +479,9 @@  discard block
 block discarded – undo
410 479
 	{
411 480
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
412 481
 		$Marine = new Marine($this->db);
413
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
482
+		if (!isset($globalLiveInterval)) {
483
+			$globalLiveInterval = '200';
484
+		}
414 485
 		$filter_query = $this->getFilter($filter,true,true);
415 486
 
416 487
 		if (is_array($coord)) {
@@ -418,7 +489,9 @@  discard block
 block discarded – undo
418 489
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
419 490
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
420 491
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
421
-		} else return array();
492
+		} else {
493
+			return array();
494
+		}
422 495
 		/*
423 496
 		if ($globalDBdriver == 'mysql') {
424 497
 			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
@@ -648,11 +721,15 @@  discard block
 block discarded – undo
648 721
 		//$query  = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date';
649 722
 		if ($globalDBdriver == 'mysql') {
650 723
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
651
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
724
+			if ($liveinterval) {
725
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
726
+			}
652 727
 			$query .= ' ORDER BY date';
653 728
 		} else {
654 729
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
655
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
730
+			if ($liveinterval) {
731
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
732
+			}
656 733
 			$query .= ' ORDER BY date';
657 734
 		}
658 735
 
@@ -747,7 +824,9 @@  discard block
 block discarded – undo
747 824
 				$i++;
748 825
 				$j++;
749 826
 				if ($j == 30) {
750
-					if ($globalDebug) echo ".";
827
+					if ($globalDebug) {
828
+						echo ".";
829
+					}
751 830
 				    	try {
752 831
 						
753 832
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -1064,7 +1143,9 @@  discard block
 block discarded – undo
1064 1143
 			{
1065 1144
 				return false;
1066 1145
 			}
1067
-		} else return '';
1146
+		} else {
1147
+			return '';
1148
+		}
1068 1149
 
1069 1150
 		if ($longitude != '')
1070 1151
 		{
@@ -1072,7 +1153,9 @@  discard block
 block discarded – undo
1072 1153
 			{
1073 1154
 				return false;
1074 1155
 			}
1075
-		} else return '';
1156
+		} else {
1157
+			return '';
1158
+		}
1076 1159
 
1077 1160
 
1078 1161
 		if ($heading != '')
@@ -1081,7 +1164,9 @@  discard block
 block discarded – undo
1081 1164
 			{
1082 1165
 				return false;
1083 1166
 			}
1084
-		} else $heading = 0;
1167
+		} else {
1168
+			$heading = 0;
1169
+		}
1085 1170
 
1086 1171
 		if ($groundspeed != '')
1087 1172
 		{
@@ -1089,9 +1174,13 @@  discard block
 block discarded – undo
1089 1174
 			{
1090 1175
 				return false;
1091 1176
 			}
1092
-		} else $groundspeed = 0;
1177
+		} else {
1178
+			$groundspeed = 0;
1179
+		}
1093 1180
 		date_default_timezone_set('UTC');
1094
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1181
+		if ($date == '') {
1182
+			$date = date("Y-m-d H:i:s", time());
1183
+		}
1095 1184
 
1096 1185
         
1097 1186
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -1118,19 +1207,35 @@  discard block
 block discarded – undo
1118 1207
 		$race_id = filter_var($race_id,FILTER_SANITIZE_STRING);
1119 1208
 		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
1120 1209
 		$race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT);
1121
-		if ($race_rank == '') $race_rank = NULL;
1210
+		if ($race_rank == '') {
1211
+			$race_rank = NULL;
1212
+		}
1122 1213
 		$race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1123
-		if ($race_time == '') $race_time = NULL;
1124
-		if ($typeid == '') $typeid = NULL;
1125
-		if ($statusid == '') $statusid = NULL;
1126
-		if ($distance == '') $distance = NULL;
1214
+		if ($race_time == '') {
1215
+			$race_time = NULL;
1216
+		}
1217
+		if ($typeid == '') {
1218
+			$typeid = NULL;
1219
+		}
1220
+		if ($statusid == '') {
1221
+			$statusid = NULL;
1222
+		}
1223
+		if ($distance == '') {
1224
+			$distance = NULL;
1225
+		}
1127 1226
 
1128 1227
             	//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1129
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1130
-            	if ($arrival_date == '') $arrival_date = NULL;
1228
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1229
+            		$heading = 0;
1230
+            	}
1231
+            	if ($arrival_date == '') {
1232
+            		$arrival_date = NULL;
1233
+            	}
1131 1234
             	$query = '';
1132 1235
 		if ($globalArchive) {
1133
-			if ($globalDebug) echo '-- Delete previous data -- ';
1236
+			if ($globalDebug) {
1237
+				echo '-- Delete previous data -- ';
1238
+			}
1134 1239
 			$query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';
1135 1240
 		}
1136 1241
 		$query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) 
@@ -1145,10 +1250,14 @@  discard block
 block discarded – undo
1145 1250
 		}
1146 1251
 		
1147 1252
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1148
-			if ($globalDebug) echo '(Add to Marine archive : ';
1253
+			if ($globalDebug) {
1254
+				echo '(Add to Marine archive : ';
1255
+			}
1149 1256
 			$MarineArchive = new MarineArchive($this->db);
1150 1257
 			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source, $source_name, $over_country,$captain_id,$captain_name,$race_id,$race_name,$distance,$race_rank,$race_time);
1151
-			if ($globalDebug) echo $result.')';
1258
+			if ($globalDebug) {
1259
+				echo $result.')';
1260
+			}
1152 1261
 		}
1153 1262
 		return "success";
1154 1263
 	}
Please login to merge, or discard this patch.
require/class.MarineImport.php 3 patches
Indentation   +266 added lines, -266 removed lines patch added patch discarded remove patch
@@ -16,25 +16,25 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/class.Stats.php');
17 17
 require_once(dirname(__FILE__).'/class.Source.php');
18 18
 if (isset($globalServerAPRS) && $globalServerAPRS) {
19
-    require_once(dirname(__FILE__).'/class.APRS.php');
19
+	require_once(dirname(__FILE__).'/class.APRS.php');
20 20
 }
21 21
 
22 22
 class MarineImport {
23
-    private $all_tracked = array();
24
-    private $last_delete_hourly = 0;
25
-    private $last_delete = 0;
26
-    private $stats = array();
27
-    private $tmd = 0;
28
-    private $source_location = array();
29
-    public $db = null;
30
-    public $nb = 0;
23
+	private $all_tracked = array();
24
+	private $last_delete_hourly = 0;
25
+	private $last_delete = 0;
26
+	private $stats = array();
27
+	private $tmd = 0;
28
+	private $source_location = array();
29
+	public $db = null;
30
+	public $nb = 0;
31 31
 
32
-    public function __construct($dbc = null) {
32
+	public function __construct($dbc = null) {
33 33
 	global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB;
34 34
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
35
-	    $Connection = new Connection($dbc);
36
-	    $this->db = $Connection->db();
37
-	    date_default_timezone_set('UTC');
35
+		$Connection = new Connection($dbc);
36
+		$this->db = $Connection->db();
37
+		date_default_timezone_set('UTC');
38 38
 	}
39 39
 	// Get previous source stats
40 40
 	/*
@@ -53,79 +53,79 @@  discard block
 block discarded – undo
53 53
 	}
54 54
 	*/
55 55
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
56
-	    $APRSMarine = new APRSMarine();
57
-	    //$APRSSpotter->connect();
56
+		$APRSMarine = new APRSMarine();
57
+		//$APRSSpotter->connect();
58
+	}
58 59
 	}
59
-    }
60 60
 
61
-    public function checkAll() {
61
+	public function checkAll() {
62 62
 	global $globalDebug, $globalNoDB, $globalVM;
63 63
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
64
-	    if ($globalDebug) echo "Update last seen tracked data...\n";
65
-	    foreach ($this->all_tracked as $key => $flight) {
64
+		if ($globalDebug) echo "Update last seen tracked data...\n";
65
+		foreach ($this->all_tracked as $key => $flight) {
66 66
 		if (isset($this->all_tracked[$key]['id'])) {
67
-		    //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
68
-    		    $Marine = new Marine($this->db);
69
-    		    if (isset($globalVM) && $globalVM) {
67
+			//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
68
+				$Marine = new Marine($this->db);
69
+				if (isset($globalVM) && $globalVM) {
70 70
 			if ($this->all_tracked[$key]['status'] == 'Racing') {
71
-    			    $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'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
72
-    			} else {
73
-    			    $timerace = (strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']);
74
-    			    if ($timerace > time()) $finaldatetime = NULL;
75
-    			    else $finaldatetime = date('Y-m-d H:i:s',$timerace);
76
-    			    $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'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
77
-    			}
78
-    		    } else {
71
+					$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'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
72
+				} else {
73
+					$timerace = (strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']);
74
+					if ($timerace > time()) $finaldatetime = NULL;
75
+					else $finaldatetime = date('Y-m-d H:i:s',$timerace);
76
+					$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'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
77
+				}
78
+				} else {
79 79
 			$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'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
80
-		    }
80
+			}
81
+		}
81 82
 		}
82
-	    }
83 83
 	}
84
-    }
84
+	}
85 85
 
86
-    public function del() {
86
+	public function del() {
87 87
 	global $globalDebug, $globalNoDB, $globalNoImport;
88 88
 	// Delete old infos
89 89
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
90 90
 	foreach ($this->all_tracked as $key => $flight) {
91
-    	    if (isset($flight['lastupdate'])) {
92
-        	if ($flight['lastupdate'] < (time()-3000)) {
93
-            	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
94
-            		if (isset($this->all_tracked[$key]['id'])) {
95
-            		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
96
-			    /*
91
+			if (isset($flight['lastupdate'])) {
92
+			if ($flight['lastupdate'] < (time()-3000)) {
93
+					if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
94
+					if (isset($this->all_tracked[$key]['id'])) {
95
+						if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
96
+				/*
97 97
 			    $MarineLive = new MarineLive();
98 98
             		    $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
99 99
 			    $MarineLive->db = null;
100 100
 			    */
101
-            		    //$real_arrival = $this->arrival($key);
102
-            		    $Marine = new Marine($this->db);
103
-            		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
101
+						//$real_arrival = $this->arrival($key);
102
+						$Marine = new Marine($this->db);
103
+						if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
104 104
 				if (isset($globalVM) && $globalVM) {
105
-				    if ($this->all_tracked[$key]['status'] == 'Racing') {
105
+					if ($this->all_tracked[$key]['status'] == 'Racing') {
106 106
 					$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'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
107
-				    } else {
107
+					} else {
108 108
 					$timerace = strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time'];
109
-	        			if ($timerace > time()) $finaldatetime = NULL;
109
+						if ($timerace > time()) $finaldatetime = NULL;
110 110
 					else $finaldatetime = date('Y-m-d H:i:s',$timerace);
111 111
 					$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'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
112
-				    }
112
+					}
113 113
 				} else {
114 114
 					$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'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
115 115
 				}
116 116
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
117
-			    }
118
-			    // Put in archive
117
+				}
118
+				// Put in archive
119 119
 //				$Marine->db = null;
120 120
 			}
121
-            	    }
122
-            	    unset($this->all_tracked[$key]);
123
-    	        }
124
-	    }
125
-        }
126
-    }
121
+					}
122
+					unset($this->all_tracked[$key]);
123
+				}
124
+		}
125
+		}
126
+	}
127 127
 
128
-    public function add($line) {
128
+	public function add($line) {
129 129
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM, $globalOnlyID;
130 130
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
131 131
 	date_default_timezone_set('UTC');
@@ -134,106 +134,106 @@  discard block
 block discarded – undo
134 134
 	
135 135
 	// SBS format is CSV format
136 136
 	if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) {
137
-	    //print_r($line);
138
-  	    if (isset($line['mmsi']) || isset($line['id'])) {
137
+		//print_r($line);
138
+  		if (isset($line['mmsi']) || isset($line['id'])) {
139 139
 
140 140
 		
141 141
 		// Increment message number
142 142
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
143
-		    $current_date = date('Y-m-d');
144
-		    if (isset($line['source_name'])) $source = $line['source_name'];
145
-		    else $source = '';
146
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
147
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
148
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
149
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
150
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
143
+			$current_date = date('Y-m-d');
144
+			if (isset($line['source_name'])) $source = $line['source_name'];
145
+			else $source = '';
146
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
147
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
148
+				$this->stats[$current_date][$source]['msg']['date'] = time();
149
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
150
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
151 151
 		}
152 152
 		
153 153
 		
154 154
 		$Common = new Common();
155 155
 		$AIS = new AIS();
156
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
157
-	        else $id = trim($line['id']);
156
+			if (!isset($line['id'])) $id = trim($line['mmsi']);
157
+			else $id = trim($line['id']);
158 158
 		
159 159
 		if (!isset($this->all_tracked[$id])) {
160
-		    $this->all_tracked[$id] = array();
161
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
162
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => ''));
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
164
-		    if (!isset($line['id'])) {
160
+			$this->all_tracked[$id] = array();
161
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
162
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => ''));
163
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
164
+			if (!isset($line['id'])) {
165 165
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
166 166
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
167
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
168
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
167
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
168
+			if ($globalAllTracked !== FALSE) $dataFound = true;
169 169
 		}
170 170
 		
171 171
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
172
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
173
-		    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
172
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
173
+			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
174 174
 			$Marine = new Marine($this->db);
175 175
 			$identity = $Marine->getIdentity($line['mmsi']);
176 176
 			if (!empty($identity)) {
177
-			    $this->all_tracked[$id]['ident'] = $identity['ship_name'];
178
-			    $this->all_tracked[$id]['type'] = $identity['type'];
179
-			    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type'])));
177
+				$this->all_tracked[$id]['ident'] = $identity['ship_name'];
178
+				$this->all_tracked[$id]['type'] = $identity['type'];
179
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type'])));
180 180
 			}
181 181
 			//print_r($identity);
182 182
 			unset($Marine);
183 183
 			//$dataFound = true;
184
-		    }
184
+			}
185 185
 		}
186 186
 		if (isset($line['type_id'])) {
187
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
188
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
187
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
188
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
189 189
 		}
190 190
 		if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') {
191
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
192
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
191
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
192
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
193 193
 		} elseif (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] != '') {
194
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
194
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
195 195
 		}
196 196
 		if (isset($line['status']) && $line['status'] != '') {
197
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
197
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
198 198
 		}
199 199
 		if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) {
200
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
201
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
200
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
201
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
202 202
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
203
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
203
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
204 204
 				$Marine = new Marine($this->db);
205 205
 				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']);
206 206
 				unset($Marine);
207
-			    }
207
+				}
208
+			}
208 209
 			}
209
-		    }
210 210
 		}
211 211
 
212 212
 
213 213
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
214
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
214
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
215 215
 		}
216 216
 		if (isset($line['imo']) && $line['imo'] != '') {
217
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
217
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
218 218
 		}
219 219
 		if (isset($line['callsign']) && $line['callsign'] != '') {
220
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
220
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
221 221
 		}
222 222
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
223
-		    if (!isset($this->all_tracked[$id]['arrival_code'])) {
223
+			if (!isset($this->all_tracked[$id]['arrival_code'])) {
224 224
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
225 225
 			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
226 226
 			if ($this->all_tracked[$id]['addedMarine'] != 0) {
227
-			    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
227
+				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
228 228
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
229
-				    $Marine = new Marine($this->db);
230
-				    $fromsource = NULL;
231
-				    $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource);
232
-				    $Marine->db = null;
229
+					$Marine = new Marine($this->db);
230
+					$fromsource = NULL;
231
+					$Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource);
232
+					$Marine->db = null;
233
+				}
233 234
 				}
234
-			    }
235 235
 			}
236
-		    } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
236
+			} elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
237 237
 			$this->all_tracked[$id]['arrival_code'] = $line['arrival_code'];
238 238
 			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
239 239
 			if (!isset($line['id'])) {
@@ -241,50 +241,50 @@  discard block
 block discarded – undo
241 241
 				$this->all_tracked[$id]['forcenew'] = 1;
242 242
 				$this->all_tracked[$id]['addedMarine'] = 0;
243 243
 			}
244
-		    }
244
+			}
245 245
 		}
246 246
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
247
-		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
247
+			if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
248 248
 		}
249 249
 		if (isset($line['captain_id']) && $line['captain_id'] != '') {
250
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id']));
250
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id']));
251 251
 		}
252 252
 		if (isset($line['captain_name']) && $line['captain_name'] != '') {
253
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name']));
253
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name']));
254 254
 		}
255 255
 		if (isset($line['race_id']) && $line['race_id'] != '') {
256
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id']));
256
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id']));
257 257
 		}
258 258
 		if (isset($line['race_name']) && $line['race_name'] != '') {
259
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name']));
259
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name']));
260 260
 		}
261 261
 		if (isset($line['race_rank']) && $line['race_rank'] != '') {
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank']));
262
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank']));
263 263
 		}
264 264
 		if (isset($line['race_time']) && $line['race_time'] != '') {
265
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time']));
265
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time']));
266 266
 		}
267 267
 		if (isset($line['race_begin']) && $line['race_begin'] != '') {
268
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_begin' => $line['race_begin']));
268
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_begin' => $line['race_begin']));
269 269
 		}
270 270
 		if (isset($line['distance']) && $line['distance'] != '') {
271
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance']));
271
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance']));
272 272
 		}
273 273
 
274 274
 		//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'])) {
275 275
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
276
-		    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
276
+			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
277 277
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
278
-			    $timeelapsed = microtime(true);
279
-			    $Marine = new Marine($this->db);
280
-			    $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']);
281
-			    $Marine->db = null;
278
+				$timeelapsed = microtime(true);
279
+				$Marine = new Marine($this->db);
280
+				$Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']);
281
+				$Marine->db = null;
282
+			}
282 283
 			}
283
-		    }
284
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
285
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
284
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
285
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
286 286
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
287
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
287
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
288 288
 				$timeelapsed = microtime(true);
289 289
 				$Marine = new Marine($this->db);
290 290
 				$fromsource = NULL;
@@ -292,20 +292,20 @@  discard block
 block discarded – undo
292 292
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
293 293
 				$Marine->db = null;
294 294
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
295
-			    }
295
+				}
296
+			}
296 297
 			}
297
-		    }
298
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
298
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
299 299
 		}
300 300
 
301 301
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
302
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
302
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
303 303
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
304
-		    } else {
304
+			} else {
305 305
 				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";
306 306
 				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";
307 307
 				return '';
308
-		    }
308
+			}
309 309
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
310 310
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
311 311
 			return '';
@@ -322,33 +322,33 @@  discard block
 block discarded – undo
322 322
 
323 323
 
324 324
 		if (isset($line['speed'])) {
325
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2)));
326
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
325
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2)));
326
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
327 327
 		} 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'])) {
328
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
329
-		    if ($distance > 1000 && $distance < 10000) {
328
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
329
+			if ($distance > 1000 && $distance < 10000) {
330 330
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
331 331
 			$speed = $speed*3.6;
332 332
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2)));
333 333
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['id']." : ".$speed." - distance : ".$distance."\n";
334
-		    }
334
+			}
335 335
 		}
336 336
 
337
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
338
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
339
-	    	    else unset($timediff);
340
-	    	    if ($this->tmd > 5 ||
341
-	    		!isset($timediff) ||
342
-	    		$timediff > $globalLiveInterval ||
343
-	    		(
344
-	    		    $timediff > 30 && 
345
-	    		    isset($this->all_tracked[$id]['latitude']) &&
346
-	    		    isset($this->all_tracked[$id]['longitude']) &&
347
-	    		    $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'))
348
-	    		)
349
-	    		) {
337
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
338
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
339
+				else unset($timediff);
340
+				if ($this->tmd > 5 ||
341
+				!isset($timediff) ||
342
+				$timediff > $globalLiveInterval ||
343
+				(
344
+					$timediff > 30 && 
345
+					isset($this->all_tracked[$id]['latitude']) &&
346
+					isset($this->all_tracked[$id]['longitude']) &&
347
+					$Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'))
348
+				)
349
+				) {
350 350
 			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'])) {
351
-			    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'])) {
351
+				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'])) {
352 352
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
353 353
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
354 354
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -356,217 +356,217 @@  discard block
 block discarded – undo
356 356
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
357 357
 				$timeelapsed = microtime(true);
358 358
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
359
-				    $Marine = new Marine($this->db);
360
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
361
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
362
-				    $Marine->db = null;
363
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
359
+					$Marine = new Marine($this->db);
360
+					$all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
361
+					if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
362
+					$Marine->db = null;
363
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
364 364
 				}
365 365
 				$this->tmd = 0;
366 366
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
367
-			    }
367
+				}
368 368
 			}
369 369
 
370 370
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
371 371
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
372 372
 				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') {
373
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
374
-				    $dataFound = true;
375
-				    $this->all_tracked[$id]['time_last_coord'] = time();
373
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
374
+					$dataFound = true;
375
+					$this->all_tracked[$id]['time_last_coord'] = time();
376 376
 				}
377 377
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
378 378
 			}
379 379
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
380
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
380
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
381 381
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
382 382
 				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') {
383
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
384
-				    $dataFound = true;
385
-				    $this->all_tracked[$id]['time_last_coord'] = time();
383
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
384
+					$dataFound = true;
385
+					$this->all_tracked[$id]['time_last_coord'] = time();
386 386
 				}
387 387
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
388 388
 			}
389 389
 
390
-		    } else if ($globalDebug && $timediff > 20) {
390
+			} else if ($globalDebug && $timediff > 20) {
391 391
 			$this->tmd = $this->tmd + 1;
392 392
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
393 393
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
394 394
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
395 395
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
396
-		    }
396
+			}
397 397
 		}
398 398
 		if (isset($line['last_update']) && $line['last_update'] != '') {
399
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
400
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
399
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
400
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
401 401
 		}
402 402
 		if (isset($line['format_source']) && $line['format_source'] != '') {
403
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
403
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
404 404
 		}
405 405
 		if (isset($line['source_name']) && $line['source_name'] != '') {
406
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
406
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
407 407
 		}
408 408
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
409
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
409
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
410 410
 		}
411 411
 		
412 412
 		if (isset($line['heading']) && $line['heading'] != '') {
413
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
414
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
415
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
416
-		    //$dataFound = true;
413
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
414
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
415
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
416
+			//$dataFound = true;
417 417
   		} 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']) {
418
-  		    $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']);
419
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
420
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
421
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
418
+  			$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']);
419
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
420
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
421
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
422 422
   		}
423 423
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
424 424
 
425 425
 
426 426
 
427 427
 		if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) {
428
-		    $this->all_tracked[$id]['lastupdate'] = time();
429
-		    if ($this->all_tracked[$id]['addedMarine'] == 0 || (isset($globalVM) && $globalVM)) {
430
-		        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'])) && (!isset($globalOnlyID) || in_array($id,$globalOnlyID))) {
431
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
428
+			$this->all_tracked[$id]['lastupdate'] = time();
429
+			if ($this->all_tracked[$id]['addedMarine'] == 0 || (isset($globalVM) && $globalVM)) {
430
+				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'])) && (!isset($globalOnlyID) || in_array($id,$globalOnlyID))) {
431
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
432 432
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
433
-				    if ($globalDebug) echo "Check if vessel is already in DB...";
434
-				    $timeelapsed = microtime(true);
435
-				    $MarineLive = new MarineLive($this->db);
436
-				    if (isset($line['id']) && isset($globalVM) && $globalVM) {
433
+					if ($globalDebug) echo "Check if vessel is already in DB...";
434
+					$timeelapsed = microtime(true);
435
+					$MarineLive = new MarineLive($this->db);
436
+					if (isset($line['id']) && isset($globalVM) && $globalVM) {
437 437
 					$Marine = new Marine($this->db);
438 438
 					$recent_ident = $Marine->checkId($line['id']);
439 439
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
440 440
 					$Marine->db=null;
441
-				    } elseif (isset($line['id'])) {
441
+					} elseif (isset($line['id'])) {
442 442
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
443 443
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
444
-				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
444
+					} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
445 445
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
446 446
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
447
-				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
447
+					} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
448 448
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
449 449
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
450
-				    } else $recent_ident = '';
451
-				    $MarineLive->db=null;
452
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
453
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
450
+					} else $recent_ident = '';
451
+					$MarineLive->db=null;
452
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
453
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
454 454
 				} else $recent_ident = '';
455
-			    } else {
455
+				} else {
456 456
 				$recent_ident = '';
457 457
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
458
-			    }
459
-			    //if there was no vessel with the same callsign within the last hour and go post it into the archive
460
-			    if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM)))
461
-			    {
458
+				}
459
+				//if there was no vessel with the same callsign within the last hour and go post it into the archive
460
+				if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM)))
461
+				{
462 462
 				if ($globalDebug) {
463 463
 					if ($this->all_tracked[$id]['mmsi'] != '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
464 464
 					else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
465 465
 				}
466 466
 				//adds the spotter data for the archive
467
-				    $highlight = '';
468
-				    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')));
469
-				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
467
+					$highlight = '';
468
+					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')));
469
+					if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
470 470
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
471
-					    $timeelapsed = microtime(true);
472
-					    $Marine = new Marine($this->db);
473
-					    if (isset($globalVM) && $globalVM && ($this->all_tracked[$id]['race_begin'] != '' || $this->all_tracked[$id]['format_source'] == 'sailaway')) {
471
+						$timeelapsed = microtime(true);
472
+						$Marine = new Marine($this->db);
473
+						if (isset($globalVM) && $globalVM && ($this->all_tracked[$id]['race_begin'] != '' || $this->all_tracked[$id]['format_source'] == 'sailaway')) {
474 474
 						$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]['race_begin'], $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]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
475
-					    } else {
475
+						} else {
476 476
 						$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]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
477
-					    }
478
-					    $Marine->db = null;
479
-					    if ($globalDebug && isset($result)) echo $result."\n";
480
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
477
+						}
478
+						$Marine->db = null;
479
+						if ($globalDebug && isset($result)) echo $result."\n";
480
+						if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
481 481
 					}
482
-				    }
483
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
482
+					}
483
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
484 484
 					// Add source stat in DB
485 485
 					$Stats = new Stats($this->db);
486 486
 					if (!empty($this->stats)) {
487
-					    if ($globalDebug) echo 'Add source stats : ';
488
-				    	    foreach($this->stats as $date => $data) {
487
+						if ($globalDebug) echo 'Add source stats : ';
488
+							foreach($this->stats as $date => $data) {
489 489
 						foreach($data as $source => $sourced) {
490
-					    	    //print_r($sourced);
491
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
492
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
493
-				    		    if (isset($sourced['msg'])) {
494
-				    			if (time() - $sourced['msg']['date'] > 10) {
495
-				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
496
-				    		    	    echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
497
-			    			    	    unset($this->stats[$date][$source]['msg']);
498
-			    				}
499
-			    			    }
500
-			    			}
501
-			    			if ($date != date('Y-m-d')) {
502
-			    			    unset($this->stats[$date]);
503
-			    			}
504
-				    	    }
505
-				    	    if ($globalDebug) echo 'Done'."\n";
490
+								//print_r($sourced);
491
+									if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
492
+									if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
493
+								if (isset($sourced['msg'])) {
494
+								if (time() - $sourced['msg']['date'] > 10) {
495
+										$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
496
+										echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
497
+										unset($this->stats[$date][$source]['msg']);
498
+								}
499
+								}
500
+							}
501
+							if ($date != date('Y-m-d')) {
502
+								unset($this->stats[$date]);
503
+							}
504
+							}
505
+							if ($globalDebug) echo 'Done'."\n";
506 506
 					}
507 507
 					$Stats->db = null;
508
-				    }
508
+					}
509 509
 				    
510
-				    $this->del();
510
+					$this->del();
511 511
 				//$ignoreImport = false;
512 512
 				$this->all_tracked[$id]['addedMarine'] = 1;
513 513
 				//print_r($this->all_tracked[$id]);
514 514
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
515
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 12 hours...";
516
-				    //MarineLive->deleteLiveMarineDataNotUpdated();
517
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
515
+					if ($globalDebug) echo "---- Deleting Live Marine data older than 12 hours...";
516
+					//MarineLive->deleteLiveMarineDataNotUpdated();
517
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
518 518
 					$MarineLive = new MarineLive($this->db);
519 519
 					$MarineLive->deleteLiveMarineData();
520 520
 					$MarineLive->db=null;
521 521
 					if ($globalDebug) echo " Done\n";
522
-				    }
523
-				    $this->last_delete = time();
522
+					}
523
+					$this->last_delete = time();
524 524
 				}
525
-			    } elseif ($recent_ident != '') {
525
+				} elseif ($recent_ident != '') {
526 526
 				$this->all_tracked[$id]['id'] = $recent_ident;
527 527
 				$this->all_tracked[$id]['addedMarine'] = 1;
528 528
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
529
-				    if ((isset($globalDaemon) && !$globalDaemon) || (isset($globalVM) && $globalVM)) {
529
+					if ((isset($globalDaemon) && !$globalDaemon) || (isset($globalVM) && $globalVM)) {
530 530
 					$Marine = new Marine($this->db);
531 531
 					if (isset($globalVM) && $globalVM) {
532
-					    if ($this->all_tracked[$id]['status'] == 'Racing') {
532
+						if ($this->all_tracked[$id]['status'] == 'Racing') {
533 533
 						$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'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
534
-					    } else {
534
+						} else {
535 535
 						//$finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
536 536
 						$timerace = (strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
537 537
 						if ($timerace > time()) $finaldatetime = NULL;
538 538
 						else $finaldatetime = date('Y-m-d H:i:s',$timerace);
539 539
 
540 540
 						$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'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
541
-					    }
541
+						}
542 542
 					} else {
543
-					    $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'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
543
+						$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'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
544 544
 					}
545 545
 					$Marine->db = null;
546
-				    }
546
+					}
547 547
 				}
548 548
 				
549
-			    }
549
+				}
550 550
 			}
551
-		    }
552
-		    //adds the spotter LIVE data
553
-		    if ($globalDebug) {
551
+			}
552
+			//adds the spotter LIVE data
553
+			if ($globalDebug) {
554 554
 			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";
555
-		    }
556
-		    $ignoreImport = false;
557
-		    if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] == 'sailawayfull' && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true;
558
-		    if (!$ignoreImport) {
555
+			}
556
+			$ignoreImport = false;
557
+			if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] == 'sailawayfull' && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true;
558
+			if (!$ignoreImport) {
559 559
 			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'])) && (!isset($globalOnlyID) || in_array($id,$globalOnlyID))) {
560 560
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
561 561
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
562
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
562
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
563 563
 					$timeelapsed = microtime(true);
564 564
 					$MarineLive = new MarineLive($this->db);
565 565
 					$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]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
566 566
 					$MarineLive->db = null;
567 567
 					if ($globalDebug) echo $result."\n";
568 568
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
569
-				    }
569
+					}
570 570
 				}
571 571
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
572 572
 					$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]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 					if ($stats_heading == 16) $stats_heading = 0;
602 602
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
603 603
 						for ($i=0;$i<=15;$i++) {
604
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
604
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
605 605
 						}
606 606
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
607 607
 					} else {
@@ -614,11 +614,11 @@  discard block
 block discarded – undo
614 614
 					//var_dump($this->stats);
615 615
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
616 616
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
617
-						    end($this->stats[$current_date][$source]['hist']);
618
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
617
+							end($this->stats[$current_date][$source]['hist']);
618
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
619 619
 						} else $mini = 0;
620 620
 						for ($i=$mini;$i<=$distance;$i+=10) {
621
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
621
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
622 622
 						}
623 623
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
624 624
 					} else {
@@ -634,30 +634,30 @@  discard block
 block discarded – undo
634 634
 			
635 635
 			
636 636
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
637
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
637
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
638 638
 				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
639 639
 				$MarineLive = new MarineLive($this->db);
640 640
 				$MarineLive->deleteLiveMarineDataNotUpdated();
641 641
 				$MarineLive->db = null;
642 642
 				//MarineLive->deleteLiveMarineData();
643 643
 				if ($globalDebug) echo " Done\n";
644
-			    }
645
-			    $this->last_delete_hourly = time();
644
+				}
645
+				$this->last_delete_hourly = time();
646 646
 			}
647 647
 			
648
-		    }
649
-		    //$ignoreImport = false;
648
+			}
649
+			//$ignoreImport = false;
650 650
 		}
651 651
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
652 652
 		if ($send) return $this->all_tracked[$id];
653
-	    }
653
+		}
654
+	}
654 655
 	}
655
-    }
656 656
     
657
-    public function race_add($data) {
658
-        $Marine = new Marine();
659
-        $Marine->addRace($data['id'],$data['name'],$data['creator'],$data['desc'],$data['startdate'],$data['markers']);
660
-        $Marine->db = null;
661
-    }
657
+	public function race_add($data) {
658
+		$Marine = new Marine();
659
+		$Marine->addRace($data['id'],$data['name'],$data['creator'],$data['desc'],$data['startdate'],$data['markers']);
660
+		$Marine->db = null;
661
+	}
662 662
 }
663 663
 ?>
Please login to merge, or discard this patch.
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -68,15 +68,15 @@  discard block
 block discarded – undo
68 68
     		    $Marine = new Marine($this->db);
69 69
     		    if (isset($globalVM) && $globalVM) {
70 70
 			if ($this->all_tracked[$key]['status'] == 'Racing') {
71
-    			    $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'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
71
+    			    $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'], $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']);
72 72
     			} else {
73
-    			    $timerace = (strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']);
73
+    			    $timerace = (strtotime($this->all_tracked[$key]['race_begin']) + $this->all_tracked[$key]['race_time']);
74 74
     			    if ($timerace > time()) $finaldatetime = NULL;
75
-    			    else $finaldatetime = date('Y-m-d H:i:s',$timerace);
76
-    			    $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'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
75
+    			    else $finaldatetime = date('Y-m-d H:i:s', $timerace);
76
+    			    $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'], $finaldatetime, $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']);
77 77
     			}
78 78
     		    } else {
79
-			$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'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
79
+			$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'], $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']);
80 80
 		    }
81 81
 		}
82 82
 	    }
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
90 90
 	foreach ($this->all_tracked as $key => $flight) {
91 91
     	    if (isset($flight['lastupdate'])) {
92
-        	if ($flight['lastupdate'] < (time()-3000)) {
92
+        	if ($flight['lastupdate'] < (time() - 3000)) {
93 93
             	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
94 94
             		if (isset($this->all_tracked[$key]['id'])) {
95 95
             		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
@@ -103,15 +103,15 @@  discard block
 block discarded – undo
103 103
             		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
104 104
 				if (isset($globalVM) && $globalVM) {
105 105
 				    if ($this->all_tracked[$key]['status'] == 'Racing') {
106
-					$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'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
106
+					$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'], $this->all_tracked[$key]['datetime'], $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']);
107 107
 				    } else {
108
-					$timerace = strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time'];
108
+					$timerace = strtotime($this->all_tracked[$key]['race_begin']) + $this->all_tracked[$key]['race_time'];
109 109
 	        			if ($timerace > time()) $finaldatetime = NULL;
110
-					else $finaldatetime = date('Y-m-d H:i:s',$timerace);
111
-					$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'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
110
+					else $finaldatetime = date('Y-m-d H:i:s', $timerace);
111
+					$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'], $finaldatetime, $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']);
112 112
 				    }
113 113
 				} else {
114
-					$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'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
114
+					$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'], $this->all_tracked[$key]['datetime'], $this->all_tracked[$key]['distance'], $this->all_tracked[$key]['race_rank'], $this->all_tracked[$key]['race_time'], $this->all_tracked[$key]['status'], $this->all_tracked[$key]['race_begin']);
115 115
 				}
116 116
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
117 117
 			    }
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
     }
127 127
 
128 128
     public function add($line) {
129
-	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM, $globalOnlyID;
129
+	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine, $globalLiveInterval, $globalVM, $globalOnlyID;
130 130
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
131 131
 	date_default_timezone_set('UTC');
132 132
 	$dataFound = false;
133 133
 	$send = false;
134 134
 	
135 135
 	// SBS format is CSV format
136
-	if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) {
136
+	if (is_array($line) && (isset($line['mmsi']) || isset($line['id']))) {
137 137
 	    //print_r($line);
138 138
   	    if (isset($line['mmsi']) || isset($line['id'])) {
139 139
 
@@ -158,25 +158,25 @@  discard block
 block discarded – undo
158 158
 		
159 159
 		if (!isset($this->all_tracked[$id])) {
160 160
 		    $this->all_tracked[$id] = array();
161
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
162
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => ''));
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
161
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0));
162
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'status_id' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '', 'mmsi_type' => '', 'captain_id' => '', 'captain_name' => '', 'race_id' => '', 'race_name' => '', 'distance' => NULL, 'race_rank' => NULL, 'race_time' => NULL, 'race_begin' => ''));
163
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
164 164
 		    if (!isset($line['id'])) {
165 165
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
166
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
167
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
166
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
167
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
168 168
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
169 169
 		}
170 170
 		
171 171
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
172
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
172
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi']));
173 173
 		    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
174 174
 			$Marine = new Marine($this->db);
175 175
 			$identity = $Marine->getIdentity($line['mmsi']);
176 176
 			if (!empty($identity)) {
177 177
 			    $this->all_tracked[$id]['ident'] = $identity['ship_name'];
178 178
 			    $this->all_tracked[$id]['type'] = $identity['type'];
179
-			    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type'])));
179
+			    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $AIS->getShipTypeID($identity['type'])));
180 180
 			}
181 181
 			//print_r($identity);
182 182
 			unset($Marine);
@@ -184,25 +184,25 @@  discard block
 block discarded – undo
184 184
 		    }
185 185
 		}
186 186
 		if (isset($line['type_id'])) {
187
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
188
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
187
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id'])));
188
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $line['type_id']));
189 189
 		}
190 190
 		if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') {
191
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
192
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
191
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
192
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $AIS->getShipTypeID($line['type'])));
193 193
 		} elseif (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] != '') {
194
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
194
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
195 195
 		}
196 196
 		if (isset($line['status']) && $line['status'] != '') {
197
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
197
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status']));
198 198
 		}
199 199
 		if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) {
200
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
200
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id']));
201 201
 		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
202 202
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
203 203
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
204 204
 				$Marine = new Marine($this->db);
205
-				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']);
205
+				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']);
206 206
 				unset($Marine);
207 207
 			    }
208 208
 			}
@@ -211,24 +211,24 @@  discard block
 block discarded – undo
211 211
 
212 212
 
213 213
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
214
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
214
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type']));
215 215
 		}
216 216
 		if (isset($line['imo']) && $line['imo'] != '') {
217
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
217
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo']));
218 218
 		}
219 219
 		if (isset($line['callsign']) && $line['callsign'] != '') {
220
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
220
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign']));
221 221
 		}
222 222
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
223 223
 		    if (!isset($this->all_tracked[$id]['arrival_code'])) {
224
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
224
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code']));
225 225
 			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
226 226
 			if ($this->all_tracked[$id]['addedMarine'] != 0) {
227 227
 			    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
228 228
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
229 229
 				    $Marine = new Marine($this->db);
230 230
 				    $fromsource = NULL;
231
-				    $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource);
231
+				    $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['arrival_code'], $fromsource);
232 232
 				    $Marine->db = null;
233 233
 				}
234 234
 			    }
@@ -244,31 +244,31 @@  discard block
 block discarded – undo
244 244
 		    }
245 245
 		}
246 246
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
247
-		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
247
+		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date']));
248 248
 		}
249 249
 		if (isset($line['captain_id']) && $line['captain_id'] != '') {
250
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id']));
250
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('captain_id' => $line['captain_id']));
251 251
 		}
252 252
 		if (isset($line['captain_name']) && $line['captain_name'] != '') {
253
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name']));
253
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('captain_name' => $line['captain_name']));
254 254
 		}
255 255
 		if (isset($line['race_id']) && $line['race_id'] != '') {
256
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id']));
256
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_id' => $line['race_id']));
257 257
 		}
258 258
 		if (isset($line['race_name']) && $line['race_name'] != '') {
259
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name']));
259
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_name' => $line['race_name']));
260 260
 		}
261 261
 		if (isset($line['race_rank']) && $line['race_rank'] != '') {
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_rank' => $line['race_rank']));
262
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_rank' => $line['race_rank']));
263 263
 		}
264 264
 		if (isset($line['race_time']) && $line['race_time'] != '') {
265
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_time' => $line['race_time']));
265
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_time' => $line['race_time']));
266 266
 		}
267 267
 		if (isset($line['race_begin']) && $line['race_begin'] != '') {
268
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_begin' => $line['race_begin']));
268
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('race_begin' => $line['race_begin']));
269 269
 		}
270 270
 		if (isset($line['distance']) && $line['distance'] != '') {
271
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('distance' => $line['distance']));
271
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('distance' => $line['distance']));
272 272
 		}
273 273
 
274 274
 		//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'])) {
@@ -277,44 +277,44 @@  discard block
 block discarded – undo
277 277
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
278 278
 			    $timeelapsed = microtime(true);
279 279
 			    $Marine = new Marine($this->db);
280
-			    $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']);
280
+			    $Marine->addIdentity($this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['type']);
281 281
 			    $Marine->db = null;
282 282
 			}
283 283
 		    }
284
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
284
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
285 285
 		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
286 286
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
287 287
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
288 288
 				$timeelapsed = microtime(true);
289 289
 				$Marine = new Marine($this->db);
290 290
 				$fromsource = NULL;
291
-				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
291
+				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
292 292
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
293 293
 				$Marine->db = null;
294
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
294
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
295 295
 			    }
296 296
 			}
297 297
 		    }
298
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
298
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
299 299
 		}
300 300
 
301
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
301
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 30*60 && strtotime($line['datetime']) < time() + 20*60) {
302 302
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
303
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
303
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
304 304
 		    } else {
305 305
 				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";
306 306
 				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";
307 307
 				return '';
308 308
 		    }
309
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
309
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time() - 30*60) {
310 310
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
311 311
 			return '';
312
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) {
312
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time() + 20*60) {
313 313
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
314 314
 			return '';
315 315
 		} elseif (!isset($line['datetime'])) {
316 316
 			date_default_timezone_set('UTC');
317
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
317
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
318 318
 		} else {
319 319
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n";
320 320
 			return '';
@@ -322,20 +322,20 @@  discard block
 block discarded – undo
322 322
 
323 323
 
324 324
 		if (isset($line['speed'])) {
325
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'],2)));
326
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
325
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'], 2)));
326
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
327 327
 		} 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'])) {
328
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
328
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
329 329
 		    if ($distance > 1000 && $distance < 10000) {
330 330
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
331 331
 			$speed = $speed*3.6;
332
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2)));
332
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed, 2)));
333 333
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['id']." : ".$speed." - distance : ".$distance."\n";
334 334
 		    }
335 335
 		}
336 336
 
337 337
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
338
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
338
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
339 339
 	    	    else unset($timediff);
340 340
 	    	    if ($this->tmd > 5 ||
341 341
 	    		!isset($timediff) ||
@@ -344,11 +344,11 @@  discard block
 block discarded – undo
344 344
 	    		    $timediff > 30 && 
345 345
 	    		    isset($this->all_tracked[$id]['latitude']) &&
346 346
 	    		    isset($this->all_tracked[$id]['longitude']) &&
347
-	    		    $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'))
347
+	    		    $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm'))
348 348
 	    		)
349 349
 	    		) {
350 350
 			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'])) {
351
-			    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'])) {
351
+			    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'])) {
352 352
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
353 353
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
354 354
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -357,10 +357,10 @@  discard block
 block discarded – undo
357 357
 				$timeelapsed = microtime(true);
358 358
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
359 359
 				    $Marine = new Marine($this->db);
360
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
360
+				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
361 361
 				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
362 362
 				    $Marine->db = null;
363
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
363
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
364 364
 				}
365 365
 				$this->tmd = 0;
366 366
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
@@ -369,55 +369,55 @@  discard block
 block discarded – undo
369 369
 
370 370
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
371 371
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
372
-				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') {
372
+				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') {
373 373
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
374 374
 				    $dataFound = true;
375 375
 				    $this->all_tracked[$id]['time_last_coord'] = time();
376 376
 				}
377
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
377
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
378 378
 			}
379 379
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
380 380
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
381 381
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
382
-				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') {
382
+				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') {
383 383
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
384 384
 				    $dataFound = true;
385 385
 				    $this->all_tracked[$id]['time_last_coord'] = time();
386 386
 				}
387
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
387
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
388 388
 			}
389 389
 
390 390
 		    } else if ($globalDebug && $timediff > 20) {
391 391
 			$this->tmd = $this->tmd + 1;
392 392
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
393
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
394
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
393
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
394
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
395 395
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
396 396
 		    }
397 397
 		}
398 398
 		if (isset($line['last_update']) && $line['last_update'] != '') {
399 399
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
400
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
400
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
401 401
 		}
402 402
 		if (isset($line['format_source']) && $line['format_source'] != '') {
403
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
403
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
404 404
 		}
405 405
 		if (isset($line['source_name']) && $line['source_name'] != '') {
406
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
406
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
407 407
 		}
408 408
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
409
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
409
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
410 410
 		}
411 411
 		
412 412
 		if (isset($line['heading']) && $line['heading'] != '') {
413
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
414
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
415
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
413
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
414
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
415
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
416 416
 		    //$dataFound = true;
417 417
   		} 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']) {
418
-  		    $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']);
419
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
420
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
418
+  		    $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']);
419
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
420
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
421 421
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
422 422
   		}
423 423
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 		if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) {
428 428
 		    $this->all_tracked[$id]['lastupdate'] = time();
429 429
 		    if ($this->all_tracked[$id]['addedMarine'] == 0 || (isset($globalVM) && $globalVM)) {
430
-		        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'])) && (!isset($globalOnlyID) || in_array($id,$globalOnlyID))) {
430
+		        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'])) && (!isset($globalOnlyID) || in_array($id, $globalOnlyID))) {
431 431
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
432 432
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
433 433
 				    if ($globalDebug) echo "Check if vessel is already in DB...";
@@ -436,28 +436,28 @@  discard block
 block discarded – undo
436 436
 				    if (isset($line['id']) && isset($globalVM) && $globalVM) {
437 437
 					$Marine = new Marine($this->db);
438 438
 					$recent_ident = $Marine->checkId($line['id']);
439
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
440
-					$Marine->db=null;
439
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
440
+					$Marine->db = null;
441 441
 				    } elseif (isset($line['id'])) {
442 442
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
443
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
443
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
444 444
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
445 445
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
446
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
446
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
447 447
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
448 448
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
449
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
449
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
450 450
 				    } else $recent_ident = '';
451
-				    $MarineLive->db=null;
451
+				    $MarineLive->db = null;
452 452
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
453 453
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
454 454
 				} else $recent_ident = '';
455 455
 			    } else {
456 456
 				$recent_ident = '';
457
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
457
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
458 458
 			    }
459 459
 			    //if there was no vessel with the same callsign within the last hour and go post it into the archive
460
-			    if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM)))
460
+			    if ($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM)))
461 461
 			    {
462 462
 				if ($globalDebug) {
463 463
 					if ($this->all_tracked[$id]['mmsi'] != '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
@@ -465,19 +465,19 @@  discard block
 block discarded – undo
465 465
 				}
466 466
 				//adds the spotter data for the archive
467 467
 				    $highlight = '';
468
-				    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')));
468
+				    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')));
469 469
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
470 470
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
471 471
 					    $timeelapsed = microtime(true);
472 472
 					    $Marine = new Marine($this->db);
473 473
 					    if (isset($globalVM) && $globalVM && ($this->all_tracked[$id]['race_begin'] != '' || $this->all_tracked[$id]['format_source'] == 'sailaway')) {
474
-						$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]['race_begin'], $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]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
474
+						$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]['race_begin'], $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]['status_id'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['captain_id'], $this->all_tracked[$id]['captain_name'], $this->all_tracked[$id]['race_id'], $this->all_tracked[$id]['race_name'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time']);
475 475
 					    } else {
476
-						$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]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
476
+						$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]['status_id'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['captain_id'], $this->all_tracked[$id]['captain_name'], $this->all_tracked[$id]['race_id'], $this->all_tracked[$id]['race_name'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time']);
477 477
 					    }
478 478
 					    $Marine->db = null;
479 479
 					    if ($globalDebug && isset($result)) echo $result."\n";
480
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
480
+					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
481 481
 					}
482 482
 				    }
483 483
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
@@ -485,15 +485,15 @@  discard block
 block discarded – undo
485 485
 					$Stats = new Stats($this->db);
486 486
 					if (!empty($this->stats)) {
487 487
 					    if ($globalDebug) echo 'Add source stats : ';
488
-				    	    foreach($this->stats as $date => $data) {
489
-						foreach($data as $source => $sourced) {
488
+				    	    foreach ($this->stats as $date => $data) {
489
+						foreach ($data as $source => $sourced) {
490 490
 					    	    //print_r($sourced);
491
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
492
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
491
+				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date);
492
+				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date);
493 493
 				    		    if (isset($sourced['msg'])) {
494 494
 				    			if (time() - $sourced['msg']['date'] > 10) {
495 495
 				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
496
-				    		    	    echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
496
+				    		    	    echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date);
497 497
 			    			    	    unset($this->stats[$date][$source]['msg']);
498 498
 			    				}
499 499
 			    			    }
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
518 518
 					$MarineLive = new MarineLive($this->db);
519 519
 					$MarineLive->deleteLiveMarineData();
520
-					$MarineLive->db=null;
520
+					$MarineLive->db = null;
521 521
 					if ($globalDebug) echo " Done\n";
522 522
 				    }
523 523
 				    $this->last_delete = time();
@@ -530,17 +530,17 @@  discard block
 block discarded – undo
530 530
 					$Marine = new Marine($this->db);
531 531
 					if (isset($globalVM) && $globalVM) {
532 532
 					    if ($this->all_tracked[$id]['status'] == 'Racing') {
533
-						$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'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
533
+						$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'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['race_begin']);
534 534
 					    } else {
535 535
 						//$finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
536
-						$timerace = (strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
536
+						$timerace = (strtotime($this->all_tracked[$id]['race_begin']) + $this->all_tracked[$id]['race_time']);
537 537
 						if ($timerace > time()) $finaldatetime = NULL;
538
-						else $finaldatetime = date('Y-m-d H:i:s',$timerace);
538
+						else $finaldatetime = date('Y-m-d H:i:s', $timerace);
539 539
 
540
-						$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'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
540
+						$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'], $finaldatetime, $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['race_begin']);
541 541
 					    }
542 542
 					} else {
543
-					    $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'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
543
+					    $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'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['race_begin']);
544 544
 					}
545 545
 					$Marine->db = null;
546 546
 				    }
@@ -556,20 +556,20 @@  discard block
 block discarded – undo
556 556
 		    $ignoreImport = false;
557 557
 		    if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] == 'sailawayfull' && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true;
558 558
 		    if (!$ignoreImport) {
559
-			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'])) && (!isset($globalOnlyID) || in_array($id,$globalOnlyID))) {
559
+			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'])) && (!isset($globalOnlyID) || in_array($id, $globalOnlyID))) {
560 560
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
561 561
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
562 562
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
563 563
 					$timeelapsed = microtime(true);
564 564
 					$MarineLive = new MarineLive($this->db);
565
-					$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]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
565
+					$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]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country'], $this->all_tracked[$id]['captain_id'], $this->all_tracked[$id]['captain_name'], $this->all_tracked[$id]['race_id'], $this->all_tracked[$id]['race_name'], $this->all_tracked[$id]['distance'], $this->all_tracked[$id]['race_rank'], $this->all_tracked[$id]['race_time']);
566 566
 					$MarineLive->db = null;
567 567
 					if ($globalDebug) echo $result."\n";
568
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
568
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
569 569
 				    }
570 570
 				}
571 571
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
572
-					$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]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
572
+					$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]['status_id'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
573 573
 				}
574 574
 				$this->all_tracked[$id]['putinarchive'] = false;
575 575
 
@@ -588,19 +588,19 @@  discard block
 block discarded – undo
588 588
 							$latitude = $globalCenterLatitude;
589 589
 							$longitude = $globalCenterLongitude;
590 590
 						}
591
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
591
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
592 592
 					} else {
593 593
 						$latitude = $this->source_location[$source]['latitude'];
594 594
 						$longitude = $this->source_location[$source]['longitude'];
595 595
 					}
596
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
596
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
597 597
 					//$stats_heading = $stats_heading%22.5;
598 598
 					$stats_heading = round($stats_heading/22.5);
599
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
599
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
600 600
 					$current_date = date('Y-m-d');
601 601
 					if ($stats_heading == 16) $stats_heading = 0;
602 602
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
603
-						for ($i=0;$i<=15;$i++) {
603
+						for ($i = 0; $i <= 15; $i++) {
604 604
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
605 605
 						}
606 606
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -615,9 +615,9 @@  discard block
 block discarded – undo
615 615
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
616 616
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
617 617
 						    end($this->stats[$current_date][$source]['hist']);
618
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
618
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
619 619
 						} else $mini = 0;
620
-						for ($i=$mini;$i<=$distance;$i+=10) {
620
+						for ($i = $mini; $i <= $distance; $i += 10) {
621 621
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
622 622
 						}
623 623
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 
630 630
 				$this->all_tracked[$id]['lastupdate'] = time();
631 631
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
632
-			} 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";
632
+			} 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";
633 633
 			//$this->del();
634 634
 			
635 635
 			
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
     
657 657
     public function race_add($data) {
658 658
         $Marine = new Marine();
659
-        $Marine->addRace($data['id'],$data['name'],$data['creator'],$data['desc'],$data['startdate'],$data['markers']);
659
+        $Marine->addRace($data['id'], $data['name'], $data['creator'], $data['desc'], $data['startdate'], $data['markers']);
660 660
         $Marine->db = null;
661 661
     }
662 662
 }
Please login to merge, or discard this patch.
Braces   +225 added lines, -78 removed lines patch added patch discarded remove patch
@@ -61,7 +61,9 @@  discard block
 block discarded – undo
61 61
     public function checkAll() {
62 62
 	global $globalDebug, $globalNoDB, $globalVM;
63 63
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
64
-	    if ($globalDebug) echo "Update last seen tracked data...\n";
64
+	    if ($globalDebug) {
65
+	    	echo "Update last seen tracked data...\n";
66
+	    }
65 67
 	    foreach ($this->all_tracked as $key => $flight) {
66 68
 		if (isset($this->all_tracked[$key]['id'])) {
67 69
 		    //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -71,8 +73,11 @@  discard block
 block discarded – undo
71 73
     			    $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'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
72 74
     			} else {
73 75
     			    $timerace = (strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time']);
74
-    			    if ($timerace > time()) $finaldatetime = NULL;
75
-    			    else $finaldatetime = date('Y-m-d H:i:s',$timerace);
76
+    			    if ($timerace > time()) {
77
+    			    	$finaldatetime = NULL;
78
+    			    } else {
79
+    			    	$finaldatetime = date('Y-m-d H:i:s',$timerace);
80
+    			    }
76 81
     			    $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'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
77 82
     			}
78 83
     		    } else {
@@ -86,13 +91,17 @@  discard block
 block discarded – undo
86 91
     public function del() {
87 92
 	global $globalDebug, $globalNoDB, $globalNoImport;
88 93
 	// Delete old infos
89
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
94
+	if ($globalDebug) {
95
+		echo 'Delete old values and update latest data...'."\n";
96
+	}
90 97
 	foreach ($this->all_tracked as $key => $flight) {
91 98
     	    if (isset($flight['lastupdate'])) {
92 99
         	if ($flight['lastupdate'] < (time()-3000)) {
93 100
             	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
94 101
             		if (isset($this->all_tracked[$key]['id'])) {
95
-            		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
102
+            		    if ($globalDebug) {
103
+            		    	echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
104
+            		    }
96 105
 			    /*
97 106
 			    $MarineLive = new MarineLive();
98 107
             		    $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
@@ -106,14 +115,19 @@  discard block
 block discarded – undo
106 115
 					$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'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
107 116
 				    } else {
108 117
 					$timerace = strtotime($this->all_tracked[$key]['race_begin'])+$this->all_tracked[$key]['race_time'];
109
-	        			if ($timerace > time()) $finaldatetime = NULL;
110
-					else $finaldatetime = date('Y-m-d H:i:s',$timerace);
118
+	        			if ($timerace > time()) {
119
+	        				$finaldatetime = NULL;
120
+	        			} else {
121
+						$finaldatetime = date('Y-m-d H:i:s',$timerace);
122
+					}
111 123
 					$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'],$finaldatetime,$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
112 124
 				    }
113 125
 				} else {
114 126
 					$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'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$key]['distance'],$this->all_tracked[$key]['race_rank'],$this->all_tracked[$key]['race_time'],$this->all_tracked[$key]['status'],$this->all_tracked[$key]['race_begin']);
115 127
 				}
116
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
128
+				if ($globalDebug && $result != 'success') {
129
+					echo '!!! ERROR : '.$result."\n";
130
+				}
117 131
 			    }
118 132
 			    // Put in archive
119 133
 //				$Marine->db = null;
@@ -127,7 +141,9 @@  discard block
 block discarded – undo
127 141
 
128 142
     public function add($line) {
129 143
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval, $globalVM, $globalOnlyID;
130
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
144
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
145
+		$globalCoordMinChange = '0.02';
146
+	}
131 147
 	date_default_timezone_set('UTC');
132 148
 	$dataFound = false;
133 149
 	$send = false;
@@ -141,20 +157,30 @@  discard block
 block discarded – undo
141 157
 		// Increment message number
142 158
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
143 159
 		    $current_date = date('Y-m-d');
144
-		    if (isset($line['source_name'])) $source = $line['source_name'];
145
-		    else $source = '';
146
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
160
+		    if (isset($line['source_name'])) {
161
+		    	$source = $line['source_name'];
162
+		    } else {
163
+		    	$source = '';
164
+		    }
165
+		    if ($source == '' || $line['format_source'] == 'aprs') {
166
+		    	$source = $line['format_source'];
167
+		    }
147 168
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
148 169
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
149 170
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
150
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
171
+		    } else {
172
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
173
+		    }
151 174
 		}
152 175
 		
153 176
 		
154 177
 		$Common = new Common();
155 178
 		$AIS = new AIS();
156
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
157
-	        else $id = trim($line['id']);
179
+	        if (!isset($line['id'])) {
180
+	        	$id = trim($line['mmsi']);
181
+	        } else {
182
+	        	$id = trim($line['id']);
183
+	        }
158 184
 		
159 185
 		if (!isset($this->all_tracked[$id])) {
160 186
 		    $this->all_tracked[$id] = array();
@@ -162,10 +188,16 @@  discard block
 block discarded – undo
162 188
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL,'race_rank' => NULL,'race_time' => NULL,'race_begin' => ''));
163 189
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
164 190
 		    if (!isset($line['id'])) {
165
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
191
+			if (!isset($globalDaemon)) {
192
+				$globalDaemon = TRUE;
193
+			}
166 194
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
167
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
168
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
195
+		     } else {
196
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
197
+		     }
198
+		    if ($globalAllTracked !== FALSE) {
199
+		    	$dataFound = true;
200
+		    }
169 201
 		}
170 202
 		
171 203
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
@@ -222,7 +254,9 @@  discard block
 block discarded – undo
222 254
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
223 255
 		    if (!isset($this->all_tracked[$id]['arrival_code'])) {
224 256
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
225
-			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
257
+			if ($globalDebug) {
258
+				echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
259
+			}
226 260
 			if ($this->all_tracked[$id]['addedMarine'] != 0) {
227 261
 			    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
228 262
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -235,7 +269,9 @@  discard block
 block discarded – undo
235 269
 			}
236 270
 		    } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
237 271
 			$this->all_tracked[$id]['arrival_code'] = $line['arrival_code'];
238
-			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
272
+			if ($globalDebug) {
273
+				echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
274
+			}
239 275
 			if (!isset($line['id'])) {
240 276
 				$this->all_tracked[$id]['id'] = $id.'-'.date('YmdHi');
241 277
 				$this->all_tracked[$id]['forcenew'] = 1;
@@ -244,7 +280,9 @@  discard block
 block discarded – undo
244 280
 		    }
245 281
 		}
246 282
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
247
-		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
283
+		    if (strtotime($line['arrival_date']) > time()) {
284
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
285
+		    }
248 286
 		}
249 287
 		if (isset($line['captain_id']) && $line['captain_id'] != '') {
250 288
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id']));
@@ -289,34 +327,49 @@  discard block
 block discarded – undo
289 327
 				$Marine = new Marine($this->db);
290 328
 				$fromsource = NULL;
291 329
 				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
292
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
330
+				if ($globalDebug && $result != 'success') {
331
+					echo '!!! ERROR : '.$result."\n";
332
+				}
293 333
 				$Marine->db = null;
294
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
334
+				if ($globalDebugTimeElapsed) {
335
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
336
+				}
295 337
 			    }
296 338
 			}
297 339
 		    }
298
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
340
+		    if (!isset($this->all_tracked[$id]['id'])) {
341
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
342
+		    }
299 343
 		}
300 344
 
301 345
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
302 346
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
303 347
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
304 348
 		    } else {
305
-				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";
306
-				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";
349
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
350
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
351
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
352
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
353
+				}
307 354
 				return '';
308 355
 		    }
309 356
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
310
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
357
+			if ($globalDebug) {
358
+				echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
359
+			}
311 360
 			return '';
312 361
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) {
313
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
362
+			if ($globalDebug) {
363
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
364
+			}
314 365
 			return '';
315 366
 		} elseif (!isset($line['datetime'])) {
316 367
 			date_default_timezone_set('UTC');
317 368
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
318 369
 		} else {
319
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n";
370
+			if ($globalDebug) {
371
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n";
372
+			}
320 373
 			return '';
321 374
 		}
322 375
 
@@ -329,14 +382,21 @@  discard block
 block discarded – undo
329 382
 		    if ($distance > 1000 && $distance < 10000) {
330 383
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
331 384
 			$speed = $speed*3.6;
332
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2)));
333
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['id']." : ".$speed." - distance : ".$distance."\n";
385
+			if ($speed < 1000) {
386
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2)));
387
+			}
388
+  			if ($globalDebug) {
389
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['id']." : ".$speed." - distance : ".$distance."\n";
390
+  			}
334 391
 		    }
335 392
 		}
336 393
 
337 394
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
338
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
339
-	    	    else unset($timediff);
395
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
396
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
397
+	    	    } else {
398
+	    	    	unset($timediff);
399
+	    	    }
340 400
 	    	    if ($this->tmd > 5 ||
341 401
 	    		!isset($timediff) ||
342 402
 	    		$timediff > $globalLiveInterval ||
@@ -353,22 +413,32 @@  discard block
 block discarded – undo
353 413
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
354 414
 				$this->all_tracked[$id]['putinarchive'] = true;
355 415
 				
356
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
416
+				if ($globalDebug) {
417
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
418
+				}
357 419
 				$timeelapsed = microtime(true);
358 420
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
359 421
 				    $Marine = new Marine($this->db);
360 422
 				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
361
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
423
+				    if (!empty($all_country)) {
424
+				    	$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
425
+				    }
362 426
 				    $Marine->db = null;
363
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
427
+				    if ($globalDebugTimeElapsed) {
428
+				    	echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
429
+				    }
364 430
 				}
365 431
 				$this->tmd = 0;
366
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
432
+				if ($globalDebug) {
433
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
434
+				}
367 435
 			    }
368 436
 			}
369 437
 
370 438
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
371
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
439
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
440
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
441
+				}
372 442
 				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') {
373 443
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
374 444
 				    $dataFound = true;
@@ -377,8 +447,12 @@  discard block
 block discarded – undo
377 447
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
378 448
 			}
379 449
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
380
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
381
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
450
+			    if ($line['longitude'] > 180) {
451
+			    	$line['longitude'] = $line['longitude'] - 360;
452
+			    }
453
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
454
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
455
+				}
382 456
 				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') {
383 457
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
384 458
 				    $dataFound = true;
@@ -396,7 +470,9 @@  discard block
 block discarded – undo
396 470
 		    }
397 471
 		}
398 472
 		if (isset($line['last_update']) && $line['last_update'] != '') {
399
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
473
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
474
+		    	$dataFound = true;
475
+		    }
400 476
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
401 477
 		}
402 478
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -410,15 +486,21 @@  discard block
 block discarded – undo
410 486
 		}
411 487
 		
412 488
 		if (isset($line['heading']) && $line['heading'] != '') {
413
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
489
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
490
+		    	$this->all_tracked[$id]['putinarchive'] = true;
491
+		    }
414 492
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
415 493
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
416 494
 		    //$dataFound = true;
417 495
   		} 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']) {
418 496
   		    $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']);
419 497
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
420
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
421
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
498
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
499
+		    	$this->all_tracked[$id]['putinarchive'] = true;
500
+		    }
501
+  		    if ($globalDebug) {
502
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
503
+  		    }
422 504
   		}
423 505
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
424 506
 
@@ -430,28 +512,45 @@  discard block
 block discarded – undo
430 512
 		        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'])) && (!isset($globalOnlyID) || in_array($id,$globalOnlyID))) {
431 513
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
432 514
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
433
-				    if ($globalDebug) echo "Check if vessel is already in DB...";
515
+				    if ($globalDebug) {
516
+				    	echo "Check if vessel is already in DB...";
517
+				    }
434 518
 				    $timeelapsed = microtime(true);
435 519
 				    $MarineLive = new MarineLive($this->db);
436 520
 				    if (isset($line['id']) && isset($globalVM) && $globalVM) {
437 521
 					$Marine = new Marine($this->db);
438 522
 					$recent_ident = $Marine->checkId($line['id']);
439
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
523
+					if ($globalDebugTimeElapsed) {
524
+						echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
525
+					}
440 526
 					$Marine->db=null;
441 527
 				    } elseif (isset($line['id'])) {
442 528
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
443
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
529
+					if ($globalDebugTimeElapsed) {
530
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
531
+					}
444 532
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
445 533
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
446
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
534
+					if ($globalDebugTimeElapsed) {
535
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
536
+					}
447 537
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
448 538
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
449
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
450
-				    } else $recent_ident = '';
539
+					if ($globalDebugTimeElapsed) {
540
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
541
+					}
542
+				    } else {
543
+				    	$recent_ident = '';
544
+				    }
451 545
 				    $MarineLive->db=null;
452
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
453
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
454
-				} else $recent_ident = '';
546
+				    if ($globalDebug && $recent_ident == '') {
547
+				    	echo " Not in DB.\n";
548
+				    } elseif ($globalDebug && $recent_ident != '') {
549
+				    	echo " Already in DB.\n";
550
+				    }
551
+				} else {
552
+					$recent_ident = '';
553
+				}
455 554
 			    } else {
456 555
 				$recent_ident = '';
457 556
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -460,12 +559,17 @@  discard block
 block discarded – undo
460 559
 			    if($recent_ident == "" && (($this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') || (isset($globalVM) && $globalVM)))
461 560
 			    {
462 561
 				if ($globalDebug) {
463
-					if ($this->all_tracked[$id]['mmsi'] != '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
464
-					else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
562
+					if ($this->all_tracked[$id]['mmsi'] != '') {
563
+						echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
564
+					} else {
565
+						echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
566
+					}
465 567
 				}
466 568
 				//adds the spotter data for the archive
467 569
 				    $highlight = '';
468
-				    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')));
570
+				    if (!isset($this->all_tracked[$id]['id'])) {
571
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
572
+				    }
469 573
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
470 574
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
471 575
 					    $timeelapsed = microtime(true);
@@ -476,20 +580,30 @@  discard block
 block discarded – undo
476 580
 						$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]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
477 581
 					    }
478 582
 					    $Marine->db = null;
479
-					    if ($globalDebug && isset($result)) echo $result."\n";
480
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
583
+					    if ($globalDebug && isset($result)) {
584
+					    	echo $result."\n";
585
+					    }
586
+					    if ($globalDebugTimeElapsed) {
587
+					    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
588
+					    }
481 589
 					}
482 590
 				    }
483 591
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
484 592
 					// Add source stat in DB
485 593
 					$Stats = new Stats($this->db);
486 594
 					if (!empty($this->stats)) {
487
-					    if ($globalDebug) echo 'Add source stats : ';
595
+					    if ($globalDebug) {
596
+					    	echo 'Add source stats : ';
597
+					    }
488 598
 				    	    foreach($this->stats as $date => $data) {
489 599
 						foreach($data as $source => $sourced) {
490 600
 					    	    //print_r($sourced);
491
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
492
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
601
+				    	    	    if (isset($sourced['polar'])) {
602
+				    	    	    	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
603
+				    	    	    }
604
+				    	    	    if (isset($sourced['hist'])) {
605
+				    	    	    	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
606
+				    	    	    }
493 607
 				    		    if (isset($sourced['msg'])) {
494 608
 				    			if (time() - $sourced['msg']['date'] > 10) {
495 609
 				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -502,7 +616,9 @@  discard block
 block discarded – undo
502 616
 			    			    unset($this->stats[$date]);
503 617
 			    			}
504 618
 				    	    }
505
-				    	    if ($globalDebug) echo 'Done'."\n";
619
+				    	    if ($globalDebug) {
620
+				    	    	echo 'Done'."\n";
621
+				    	    }
506 622
 					}
507 623
 					$Stats->db = null;
508 624
 				    }
@@ -512,13 +628,17 @@  discard block
 block discarded – undo
512 628
 				$this->all_tracked[$id]['addedMarine'] = 1;
513 629
 				//print_r($this->all_tracked[$id]);
514 630
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
515
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 12 hours...";
631
+				    if ($globalDebug) {
632
+				    	echo "---- Deleting Live Marine data older than 12 hours...";
633
+				    }
516 634
 				    //MarineLive->deleteLiveMarineDataNotUpdated();
517 635
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
518 636
 					$MarineLive = new MarineLive($this->db);
519 637
 					$MarineLive->deleteLiveMarineData();
520 638
 					$MarineLive->db=null;
521
-					if ($globalDebug) echo " Done\n";
639
+					if ($globalDebug) {
640
+						echo " Done\n";
641
+					}
522 642
 				    }
523 643
 				    $this->last_delete = time();
524 644
 				}
@@ -534,8 +654,11 @@  discard block
 block discarded – undo
534 654
 					    } else {
535 655
 						//$finaldatetime = date('Y-m-d H:i:s',strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
536 656
 						$timerace = (strtotime($this->all_tracked[$id]['race_begin'])+$this->all_tracked[$id]['race_time']);
537
-						if ($timerace > time()) $finaldatetime = NULL;
538
-						else $finaldatetime = date('Y-m-d H:i:s',$timerace);
657
+						if ($timerace > time()) {
658
+							$finaldatetime = NULL;
659
+						} else {
660
+							$finaldatetime = date('Y-m-d H:i:s',$timerace);
661
+						}
539 662
 
540 663
 						$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'],$finaldatetime,$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['race_begin']);
541 664
 					    }
@@ -554,18 +677,26 @@  discard block
 block discarded – undo
554 677
 			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";
555 678
 		    }
556 679
 		    $ignoreImport = false;
557
-		    if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] == 'sailawayfull' && $this->all_tracked[$id]['status'] != 'Racing') $ignoreImport = true;
680
+		    if ((isset($globalVM) && $globalVM) && $this->all_tracked[$id]['status'] == 'sailawayfull' && $this->all_tracked[$id]['status'] != 'Racing') {
681
+		    	$ignoreImport = true;
682
+		    }
558 683
 		    if (!$ignoreImport) {
559 684
 			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'])) && (!isset($globalOnlyID) || in_array($id,$globalOnlyID))) {
560
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
685
+				if ($globalDebug) {
686
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
687
+				}
561 688
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
562 689
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
563 690
 					$timeelapsed = microtime(true);
564 691
 					$MarineLive = new MarineLive($this->db);
565 692
 					$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]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
566 693
 					$MarineLive->db = null;
567
-					if ($globalDebug) echo $result."\n";
568
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
694
+					if ($globalDebug) {
695
+						echo $result."\n";
696
+					}
697
+					if ($globalDebugTimeElapsed) {
698
+						echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
699
+					}
569 700
 				    }
570 701
 				}
571 702
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
@@ -577,7 +708,9 @@  discard block
 block discarded – undo
577 708
 				
578 709
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
579 710
 					$source = $this->all_tracked[$id]['source_name'];
580
-					if ($source == '') $source = $this->all_tracked[$id]['format_source'];
711
+					if ($source == '') {
712
+						$source = $this->all_tracked[$id]['format_source'];
713
+					}
581 714
 					if (!isset($this->source_location[$source])) {
582 715
 						$Location = new Source($this->db);
583 716
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -598,7 +731,9 @@  discard block
 block discarded – undo
598 731
 					$stats_heading = round($stats_heading/22.5);
599 732
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
600 733
 					$current_date = date('Y-m-d');
601
-					if ($stats_heading == 16) $stats_heading = 0;
734
+					if ($stats_heading == 16) {
735
+						$stats_heading = 0;
736
+					}
602 737
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
603 738
 						for ($i=0;$i<=15;$i++) {
604 739
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -616,7 +751,9 @@  discard block
 block discarded – undo
616 751
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
617 752
 						    end($this->stats[$current_date][$source]['hist']);
618 753
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
619
-						} else $mini = 0;
754
+						} else {
755
+							$mini = 0;
756
+						}
620 757
 						for ($i=$mini;$i<=$distance;$i+=10) {
621 758
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
622 759
 						}
@@ -628,19 +765,27 @@  discard block
 block discarded – undo
628 765
 				
629 766
 
630 767
 				$this->all_tracked[$id]['lastupdate'] = time();
631
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
632
-			} 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";
768
+				if ($this->all_tracked[$id]['putinarchive']) {
769
+					$send = true;
770
+				}
771
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
772
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
773
+			}
633 774
 			//$this->del();
634 775
 			
635 776
 			
636 777
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
637 778
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
638
-				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
779
+				if ($globalDebug) {
780
+					echo "---- Deleting Live Marine data Not updated since 2 hour...";
781
+				}
639 782
 				$MarineLive = new MarineLive($this->db);
640 783
 				$MarineLive->deleteLiveMarineDataNotUpdated();
641 784
 				$MarineLive->db = null;
642 785
 				//MarineLive->deleteLiveMarineData();
643
-				if ($globalDebug) echo " Done\n";
786
+				if ($globalDebug) {
787
+					echo " Done\n";
788
+				}
644 789
 			    }
645 790
 			    $this->last_delete_hourly = time();
646 791
 			}
@@ -649,7 +794,9 @@  discard block
 block discarded – undo
649 794
 		    //$ignoreImport = false;
650 795
 		}
651 796
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
652
-		if ($send) return $this->all_tracked[$id];
797
+		if ($send) {
798
+			return $this->all_tracked[$id];
799
+		}
653 800
 	    }
654 801
 	}
655 802
     }
Please login to merge, or discard this patch.
search-gpx.php 2 patches
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -6,53 +6,53 @@  discard block
 block discarded – undo
6 6
 $Spotter = new Spotter();
7 7
 if (isset($_GET['start_date'])) {
8 8
 	//for the date manipulation into the query
9
-	if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
10
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
11
-		$end_date = date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
9
+	if ($_GET['start_date'] != "" && $_GET['end_date'] != "") {
10
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
11
+		$end_date = date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
12 12
 		$sql_date = $start_date.",".$end_date;
13
-	} else if($_GET['start_date'] != ""){
14
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
13
+	} else if ($_GET['start_date'] != "") {
14
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
15 15
 		$sql_date = $start_date;
16
-	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
17
-		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
16
+	} else if ($_GET['start_date'] == "" && $_GET['end_date'] != "") {
17
+		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
18 18
 		$sql_date = $end_date;
19 19
 	} else $sql_date = '';
20 20
 } else $sql_date = '';
21 21
 
22 22
 if (isset($_GET['highest_altitude'])) {
23 23
 	//for altitude manipulation
24
-	if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
25
-		$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
26
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT);
24
+	if ($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != "") {
25
+		$end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
26
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT);
27 27
 		$sql_altitude = $start_altitude.",".$end_altitude;
28
-	} else if($_GET['highest_altitude'] != ""){
29
-		$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
28
+	} else if ($_GET['highest_altitude'] != "") {
29
+		$end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
30 30
 		$sql_altitude = $end_altitude;
31
-	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
32
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
31
+	} else if ($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != "") {
32
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT).",60000";
33 33
 		$sql_altitude = $start_altitude;
34 34
 	} else $sql_altitude = '';
35 35
 } else $sql_altitude = '';
36 36
 
37 37
 //calculuation for the pagination
38
-if(!isset($_GET['limit']))
38
+if (!isset($_GET['limit']))
39 39
 {
40 40
 	if (!isset($_GET['number_results'])) {
41 41
 		$limit_start = 0;
42 42
 		$limit_end = 25;
43 43
 		$absolute_difference = 25;
44 44
 	} else {
45
-		if ($_GET['number_results'] > 1000){
45
+		if ($_GET['number_results'] > 1000) {
46 46
 			$_GET['number_results'] = 1000;
47 47
 		}
48 48
 		$limit_start = 0;
49
-		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
50
-		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
49
+		$limit_end = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
50
+		$absolute_difference = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
51 51
 	}
52
-}  else {
52
+} else {
53 53
 	$limit_explode = explode(",", $_GET['limit']);
54
-	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
55
-	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
54
+	$limit_start = filter_var($limit_explode[0], FILTER_SANITIZE_NUMBER_INT);
55
+	$limit_end = filter_var($limit_explode[1], FILTER_SANITIZE_NUMBER_INT);
56 56
 }
57 57
 
58 58
 $absolute_difference = abs($limit_start - $limit_end);
@@ -69,34 +69,34 @@  discard block
 block discarded – undo
69 69
 
70 70
 if (isset($_GET['sort'])) $sort = $_GET['sort'];
71 71
 else $sort = '';
72
-$q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
73
-$id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_NUMBER_INT);
74
-$registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
75
-$aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING);
76
-$manufacturer = filter_input(INPUT_GET,'manufacturer',FILTER_SANITIZE_STRING);
77
-$highlights = filter_input(INPUT_GET,'highlights',FILTER_SANITIZE_STRING);
78
-$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
79
-$airline_country = filter_input(INPUT_GET,'airline_country',FILTER_SANITIZE_STRING);
80
-$airline_type = filter_input(INPUT_GET,'airline_type',FILTER_SANITIZE_STRING);
81
-$airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING);
82
-$airport_country = filter_input(INPUT_GET,'airport_country',FILTER_SANITIZE_STRING);
83
-$callsign = filter_input(INPUT_GET,'callsign',FILTER_SANITIZE_STRING);
84
-$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING);
85
-$pilot_id = filter_input(INPUT_GET,'pilot_id',FILTER_SANITIZE_STRING);
86
-$pilot_name = filter_input(INPUT_GET,'pilot_name',FILTER_SANITIZE_STRING);
87
-$departure_airport_route = filter_input(INPUT_GET,'departure_airport_route',FILTER_SANITIZE_STRING);
88
-$arrival_airport_route = filter_input(INPUT_GET,'arrival_airport_route',FILTER_SANITIZE_STRING);
72
+$q = filter_input(INPUT_GET, 'q', FILTER_SANITIZE_STRING);
73
+$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
74
+$registration = filter_input(INPUT_GET, 'registratrion', FILTER_SANITIZE_STRING);
75
+$aircraft = filter_input(INPUT_GET, 'aircraft', FILTER_SANITIZE_STRING);
76
+$manufacturer = filter_input(INPUT_GET, 'manufacturer', FILTER_SANITIZE_STRING);
77
+$highlights = filter_input(INPUT_GET, 'highlights', FILTER_SANITIZE_STRING);
78
+$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
79
+$airline_country = filter_input(INPUT_GET, 'airline_country', FILTER_SANITIZE_STRING);
80
+$airline_type = filter_input(INPUT_GET, 'airline_type', FILTER_SANITIZE_STRING);
81
+$airport = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING);
82
+$airport_country = filter_input(INPUT_GET, 'airport_country', FILTER_SANITIZE_STRING);
83
+$callsign = filter_input(INPUT_GET, 'callsign', FILTER_SANITIZE_STRING);
84
+$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING);
85
+$pilot_id = filter_input(INPUT_GET, 'pilot_id', FILTER_SANITIZE_STRING);
86
+$pilot_name = filter_input(INPUT_GET, 'pilot_name', FILTER_SANITIZE_STRING);
87
+$departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route', FILTER_SANITIZE_STRING);
88
+$arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route', FILTER_SANITIZE_STRING);
89 89
 if ($id != '') {
90 90
 	$spotter_array = $Spotter->getSpotterDataByID($id);
91 91
 } else {
92
-	$spotter_array = $Spotter->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'');
92
+	$spotter_array = $Spotter->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, '');
93 93
 }
94 94
 $output = '<?xml version="1.0" encoding="UTF-8"?>';
95 95
 $output .= '<gpx version="1.0">';
96 96
 $output .= '<name>FlightAirMap GPX Feed</name>';
97 97
 if (!empty($spotter_array))
98 98
 {
99
-	foreach($spotter_array as $spotter_item)
99
+	foreach ($spotter_array as $spotter_item)
100 100
 	{
101 101
 		$altitude = $spotter_item['altitude'].'00';
102 102
 		//waypoint plotting
Please login to merge, or discard this patch.
Braces   +18 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,8 +16,12 @@  discard block
 block discarded – undo
16 16
 	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
17 17
 		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
18 18
 		$sql_date = $end_date;
19
-	} else $sql_date = '';
20
-} else $sql_date = '';
19
+	} else {
20
+		$sql_date = '';
21
+	}
22
+	} else {
23
+	$sql_date = '';
24
+}
21 25
 
22 26
 if (isset($_GET['highest_altitude'])) {
23 27
 	//for altitude manipulation
@@ -31,8 +35,12 @@  discard block
 block discarded – undo
31 35
 	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
32 36
 		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
33 37
 		$sql_altitude = $start_altitude;
34
-	} else $sql_altitude = '';
35
-} else $sql_altitude = '';
38
+	} else {
39
+		$sql_altitude = '';
40
+	}
41
+	} else {
42
+	$sql_altitude = '';
43
+}
36 44
 
37 45
 //calculuation for the pagination
38 46
 if(!isset($_GET['limit']))
@@ -49,7 +57,7 @@  discard block
 block discarded – undo
49 57
 		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
50 58
 		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
51 59
 	}
52
-}  else {
60
+} else {
53 61
 	$limit_explode = explode(",", $_GET['limit']);
54 62
 	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
55 63
 	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -67,8 +75,11 @@  discard block
 block discarded – undo
67 75
 
68 76
 header('Content-Type: text/xml');
69 77
 
70
-if (isset($_GET['sort'])) $sort = $_GET['sort'];
71
-else $sort = '';
78
+if (isset($_GET['sort'])) {
79
+	$sort = $_GET['sort'];
80
+} else {
81
+	$sort = '';
82
+}
72 83
 $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
73 84
 $id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_NUMBER_INT);
74 85
 $registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
Please login to merge, or discard this patch.
search-geojson.php 2 patches
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -3,39 +3,39 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Language.php');
4 4
 require_once('require/class.Spotter.php');
5 5
 require_once('require/class.SpotterArchive.php');
6
-$Spotter=new Spotter();
6
+$Spotter = new Spotter();
7 7
 if (isset($_GET['start_date'])) {
8 8
 	//for the date manipulation into the query
9
-	if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
9
+	if ($_GET['start_date'] != "" && $_GET['end_date'] != "") {
10 10
 		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
11
-		$end_date = date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
11
+		$end_date = date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
12 12
 		$sql_date = $start_date.",".$end_date;
13
-	} else if($_GET['start_date'] != ""){
14
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
13
+	} else if ($_GET['start_date'] != "") {
14
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
15 15
 		$sql_date = $start_date;
16
-	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
17
-		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
16
+	} else if ($_GET['start_date'] == "" && $_GET['end_date'] != "") {
17
+		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
18 18
 		$sql_date = $end_date;
19 19
 	} else $sql_date = '';
20 20
 } else $sql_date = '';
21 21
 
22 22
 if (isset($_GET['highest_altitude'])) {
23 23
 	//for altitude manipulation
24
-	if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
25
-		$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
26
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT);
24
+	if ($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != "") {
25
+		$end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
26
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT);
27 27
 		$sql_altitude = $start_altitude.",".$end_altitude;
28
-	} else if($_GET['highest_altitude'] != ""){
29
-		$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
28
+	} else if ($_GET['highest_altitude'] != "") {
29
+		$end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
30 30
 		$sql_altitude = $end_altitude;
31
-	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
32
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
31
+	} else if ($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != "") {
32
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT).",60000";
33 33
 		$sql_altitude = $start_altitude;
34 34
 	} else $sql_altitude = '';
35 35
 } else $sql_altitude = '';
36 36
 
37 37
 //calculuation for the pagination
38
-if(!isset($_GET['limit']))
38
+if (!isset($_GET['limit']))
39 39
 {
40 40
 	if (!isset($_GET['number_results']))
41 41
 	{
@@ -43,17 +43,17 @@  discard block
 block discarded – undo
43 43
 		$limit_end = 25;
44 44
 		$absolute_difference = 25;
45 45
 	} else {
46
-		if ($_GET['number_results'] > 1000){
46
+		if ($_GET['number_results'] > 1000) {
47 47
 			$_GET['number_results'] = 1000;
48 48
 		}
49 49
 		$limit_start = 0;
50
-		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
51
-		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
50
+		$limit_end = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
51
+		$absolute_difference = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
52 52
 	}
53
-}  else {
53
+} else {
54 54
 	$limit_explode = explode(",", $_GET['limit']);
55
-	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
56
-	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
55
+	$limit_start = filter_var($limit_explode[0], FILTER_SANITIZE_NUMBER_INT);
56
+	$limit_end = filter_var($limit_explode[1], FILTER_SANITIZE_NUMBER_INT);
57 57
 }
58 58
 
59 59
 $absolute_difference = abs($limit_start - $limit_end);
@@ -70,34 +70,34 @@  discard block
 block discarded – undo
70 70
 
71 71
 if (isset($_GET['sort'])) $sort = $_GET['sort'];
72 72
 else $sort = '';
73
-$q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
74
-$id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_NUMBER_INT);
75
-$registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
76
-$aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING);
77
-$manufacturer = filter_input(INPUT_GET,'manufacturer',FILTER_SANITIZE_STRING);
78
-$highlights = filter_input(INPUT_GET,'highlights',FILTER_SANITIZE_STRING);
79
-$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
80
-$airline_country = filter_input(INPUT_GET,'airline_country',FILTER_SANITIZE_STRING);
81
-$airline_type = filter_input(INPUT_GET,'airline_type',FILTER_SANITIZE_STRING);
82
-$airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING);
83
-$airport_country = filter_input(INPUT_GET,'airport_country',FILTER_SANITIZE_STRING);
84
-$callsign = filter_input(INPUT_GET,'callsign',FILTER_SANITIZE_STRING);
85
-$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING);
86
-$pilot_id = filter_input(INPUT_GET,'pilot_id',FILTER_SANITIZE_STRING);
87
-$pilot_name = filter_input(INPUT_GET,'pilot_name',FILTER_SANITIZE_STRING);
88
-$departure_airport_route = filter_input(INPUT_GET,'departure_airport_route',FILTER_SANITIZE_STRING);
89
-$arrival_airport_route = filter_input(INPUT_GET,'arrival_airport_route',FILTER_SANITIZE_STRING);
73
+$q = filter_input(INPUT_GET, 'q', FILTER_SANITIZE_STRING);
74
+$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
75
+$registration = filter_input(INPUT_GET, 'registratrion', FILTER_SANITIZE_STRING);
76
+$aircraft = filter_input(INPUT_GET, 'aircraft', FILTER_SANITIZE_STRING);
77
+$manufacturer = filter_input(INPUT_GET, 'manufacturer', FILTER_SANITIZE_STRING);
78
+$highlights = filter_input(INPUT_GET, 'highlights', FILTER_SANITIZE_STRING);
79
+$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
80
+$airline_country = filter_input(INPUT_GET, 'airline_country', FILTER_SANITIZE_STRING);
81
+$airline_type = filter_input(INPUT_GET, 'airline_type', FILTER_SANITIZE_STRING);
82
+$airport = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING);
83
+$airport_country = filter_input(INPUT_GET, 'airport_country', FILTER_SANITIZE_STRING);
84
+$callsign = filter_input(INPUT_GET, 'callsign', FILTER_SANITIZE_STRING);
85
+$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING);
86
+$pilot_id = filter_input(INPUT_GET, 'pilot_id', FILTER_SANITIZE_STRING);
87
+$pilot_name = filter_input(INPUT_GET, 'pilot_name', FILTER_SANITIZE_STRING);
88
+$departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route', FILTER_SANITIZE_STRING);
89
+$arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route', FILTER_SANITIZE_STRING);
90 90
 if ($id != '') {
91 91
 	$spotter_array = $Spotter->getSpotterDataByID($id);
92 92
 } else {
93
-	$spotter_array = $Spotter->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'');
93
+	$spotter_array = $Spotter->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, '');
94 94
 }
95 95
 
96 96
 $output = '{';
97 97
 	$output .= '"type": "FeatureCollection",';
98 98
 	$output .= '"features": [';
99 99
 if (!empty($spotter_array)) {
100
-	foreach($spotter_array as $spotter_item) {
100
+	foreach ($spotter_array as $spotter_item) {
101 101
 		//waypoint plotting
102 102
 		$output .= '{';  
103 103
 		$output .= '"type": "Feature",';
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 			$output .= '"coordinates": [';
165 165
 			foreach ($archive_data as $coord_data) {
166 166
 				$output .= '[';
167
-				$output .=  $coord_data['longitude'].', ';
168
-				$output .=  $coord_data['latitude'];
167
+				$output .= $coord_data['longitude'].', ';
168
+				$output .= $coord_data['latitude'];
169 169
 				$output .= '],';
170 170
 			}
171 171
 			$output = substr($output, 0, -1);
Please login to merge, or discard this patch.
Braces   +18 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,8 +16,12 @@  discard block
 block discarded – undo
16 16
 	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
17 17
 		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
18 18
 		$sql_date = $end_date;
19
-	} else $sql_date = '';
20
-} else $sql_date = '';
19
+	} else {
20
+		$sql_date = '';
21
+	}
22
+	} else {
23
+	$sql_date = '';
24
+}
21 25
 
22 26
 if (isset($_GET['highest_altitude'])) {
23 27
 	//for altitude manipulation
@@ -31,8 +35,12 @@  discard block
 block discarded – undo
31 35
 	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
32 36
 		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
33 37
 		$sql_altitude = $start_altitude;
34
-	} else $sql_altitude = '';
35
-} else $sql_altitude = '';
38
+	} else {
39
+		$sql_altitude = '';
40
+	}
41
+	} else {
42
+	$sql_altitude = '';
43
+}
36 44
 
37 45
 //calculuation for the pagination
38 46
 if(!isset($_GET['limit']))
@@ -50,7 +58,7 @@  discard block
 block discarded – undo
50 58
 		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
51 59
 		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
52 60
 	}
53
-}  else {
61
+} else {
54 62
 	$limit_explode = explode(",", $_GET['limit']);
55 63
 	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
56 64
 	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -68,8 +76,11 @@  discard block
 block discarded – undo
68 76
 
69 77
 header('Content-Type: application/json');
70 78
 
71
-if (isset($_GET['sort'])) $sort = $_GET['sort'];
72
-else $sort = '';
79
+if (isset($_GET['sort'])) {
80
+	$sort = $_GET['sort'];
81
+} else {
82
+	$sort = '';
83
+}
73 84
 $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
74 85
 $id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_NUMBER_INT);
75 86
 $registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
Please login to merge, or discard this patch.
search-xml.php 2 patches
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -5,52 +5,52 @@  discard block
 block discarded – undo
5 5
 $Spotter = new Spotter();
6 6
 if (isset($_GET['start_date'])) {
7 7
 	//for the date manipulation into the query
8
-	if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
9
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
10
-		$end_date = date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
8
+	if ($_GET['start_date'] != "" && $_GET['end_date'] != "") {
9
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
10
+		$end_date = date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
11 11
 		$sql_date = $start_date.",".$end_date;
12
-	} else if($_GET['start_date'] != ""){
13
-		$start_date = date("Y-m-d",strtotime($_GET['start_date']))." 00:00:00";
12
+	} else if ($_GET['start_date'] != "") {
13
+		$start_date = date("Y-m-d", strtotime($_GET['start_date']))." 00:00:00";
14 14
 		$sql_date = $start_date;
15
-	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
16
-		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
15
+	} else if ($_GET['start_date'] == "" && $_GET['end_date'] != "") {
16
+		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d", strtotime($_GET['end_date']))." 00:00:00";
17 17
 		$sql_date = $end_date;
18 18
 	} else $sql_date = '';
19 19
 } else $sql_date = '';
20 20
 
21 21
 if (isset($_GET['highest_altitude'])) {
22 22
 	//for altitude manipulation
23
-	if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
24
-		$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
25
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT);
23
+	if ($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != "") {
24
+		$end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
25
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT);
26 26
 		$sql_altitude = $start_altitude.",".$end_altitude;
27
-	} else if($_GET['highest_altitude'] != ""){
28
-		$end_altitude = filter_input(INPUT_GET,'highest_altitude',FILTER_SANITIZE_NUMBER_INT);
27
+	} else if ($_GET['highest_altitude'] != "") {
28
+		$end_altitude = filter_input(INPUT_GET, 'highest_altitude', FILTER_SANITIZE_NUMBER_INT);
29 29
 		$sql_altitude = $end_altitude;
30
-	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
31
-		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
30
+	} else if ($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != "") {
31
+		$start_altitude = filter_input(INPUT_GET, 'lowest_altitude', FILTER_SANITIZE_NUMBER_INT).",60000";
32 32
 		$sql_altitude = $start_altitude;
33 33
 	} else $sql_altitude = '';
34 34
 } else $sql_altitude = '';
35 35
 
36 36
 //calculuation for the pagination
37
-if(!isset($_GET['limit'])) {
37
+if (!isset($_GET['limit'])) {
38 38
 	if (!isset($_GET['number_results'])) {
39 39
 		$limit_start = 0;
40 40
 		$limit_end = 25;
41 41
 		$absolute_difference = 25;
42 42
 	} else {
43
-		if ($_GET['number_results'] > 1000){
43
+		if ($_GET['number_results'] > 1000) {
44 44
 			$_GET['number_results'] = 1000;
45 45
 		}
46 46
 		$limit_start = 0;
47
-		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
48
-		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
47
+		$limit_end = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
48
+		$absolute_difference = filter_input(INPUT_GET, 'number_results', FILTER_SANITIZE_NUMBER_INT);
49 49
 	}
50
-}  else {
50
+} else {
51 51
 	$limit_explode = explode(",", $_GET['limit']);
52
-	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
53
-	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
52
+	$limit_start = filter_var($limit_explode[0], FILTER_SANITIZE_NUMBER_INT);
53
+	$limit_end = filter_var($limit_explode[1], FILTER_SANITIZE_NUMBER_INT);
54 54
 }
55 55
 
56 56
 $absolute_difference = abs($limit_start - $limit_end);
@@ -67,27 +67,27 @@  discard block
 block discarded – undo
67 67
 
68 68
 if (isset($_GET['sort'])) $sort = $_GET['sort'];
69 69
 else $sort = '';
70
-$q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
71
-$id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_NUMBER_INT);
72
-$registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
73
-$aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING);
74
-$manufacturer = filter_input(INPUT_GET,'manufacturer',FILTER_SANITIZE_STRING);
75
-$highlights = filter_input(INPUT_GET,'highlights',FILTER_SANITIZE_STRING);
76
-$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
77
-$airline_country = filter_input(INPUT_GET,'airline_country',FILTER_SANITIZE_STRING);
78
-$airline_type = filter_input(INPUT_GET,'airline_type',FILTER_SANITIZE_STRING);
79
-$airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING);
80
-$airport_country = filter_input(INPUT_GET,'airport_country',FILTER_SANITIZE_STRING);
81
-$callsign = filter_input(INPUT_GET,'callsign',FILTER_SANITIZE_STRING);
82
-$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING);
83
-$pilot_id = filter_input(INPUT_GET,'pilot_id',FILTER_SANITIZE_STRING);
84
-$pilot_name = filter_input(INPUT_GET,'pilot_name',FILTER_SANITIZE_STRING);
85
-$departure_airport_route = filter_input(INPUT_GET,'departure_airport_route',FILTER_SANITIZE_STRING);
86
-$arrival_airport_route = filter_input(INPUT_GET,'arrival_airport_route',FILTER_SANITIZE_STRING);
70
+$q = filter_input(INPUT_GET, 'q', FILTER_SANITIZE_STRING);
71
+$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
72
+$registration = filter_input(INPUT_GET, 'registratrion', FILTER_SANITIZE_STRING);
73
+$aircraft = filter_input(INPUT_GET, 'aircraft', FILTER_SANITIZE_STRING);
74
+$manufacturer = filter_input(INPUT_GET, 'manufacturer', FILTER_SANITIZE_STRING);
75
+$highlights = filter_input(INPUT_GET, 'highlights', FILTER_SANITIZE_STRING);
76
+$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
77
+$airline_country = filter_input(INPUT_GET, 'airline_country', FILTER_SANITIZE_STRING);
78
+$airline_type = filter_input(INPUT_GET, 'airline_type', FILTER_SANITIZE_STRING);
79
+$airport = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING);
80
+$airport_country = filter_input(INPUT_GET, 'airport_country', FILTER_SANITIZE_STRING);
81
+$callsign = filter_input(INPUT_GET, 'callsign', FILTER_SANITIZE_STRING);
82
+$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING);
83
+$pilot_id = filter_input(INPUT_GET, 'pilot_id', FILTER_SANITIZE_STRING);
84
+$pilot_name = filter_input(INPUT_GET, 'pilot_name', FILTER_SANITIZE_STRING);
85
+$departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route', FILTER_SANITIZE_STRING);
86
+$arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route', FILTER_SANITIZE_STRING);
87 87
 if ($id != '') {
88 88
 	$spotter_array = $Spotter->getSpotterDataByID($id);
89 89
 } else {
90
-	$spotter_array = $Spotter->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'');
90
+	$spotter_array = $Spotter->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, '');
91 91
 }
92 92
 $output = '<?xml version="1.0" encoding="UTF-8" ?>';
93 93
 $output .= '<flightairmap>';
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 $output .= '<link>http://'.$_SERVER['HTTP_HOST'].$globalURL.'</link>';
96 96
 $output .= '<aircrafts>';
97 97
 if (!empty($spotter_array)) {
98
-	foreach($spotter_array as $spotter_item) {
98
+	foreach ($spotter_array as $spotter_item) {
99 99
 		$output .= '<aircraft>';
100 100
 		$output .= '<id>'.$spotter_item['spotter_id'].'</id>';
101 101
 		$output .= '<ident>'.$spotter_item['ident'].'</ident>';
Please login to merge, or discard this patch.
Braces   +18 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,8 +15,12 @@  discard block
 block discarded – undo
15 15
 	} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
16 16
 		$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
17 17
 		$sql_date = $end_date;
18
-	} else $sql_date = '';
19
-} else $sql_date = '';
18
+	} else {
19
+		$sql_date = '';
20
+	}
21
+	} else {
22
+	$sql_date = '';
23
+}
20 24
 
21 25
 if (isset($_GET['highest_altitude'])) {
22 26
 	//for altitude manipulation
@@ -30,8 +34,12 @@  discard block
 block discarded – undo
30 34
 	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
31 35
 		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
32 36
 		$sql_altitude = $start_altitude;
33
-	} else $sql_altitude = '';
34
-} else $sql_altitude = '';
37
+	} else {
38
+		$sql_altitude = '';
39
+	}
40
+	} else {
41
+	$sql_altitude = '';
42
+}
35 43
 
36 44
 //calculuation for the pagination
37 45
 if(!isset($_GET['limit'])) {
@@ -47,7 +55,7 @@  discard block
 block discarded – undo
47 55
 		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
48 56
 		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
49 57
 	}
50
-}  else {
58
+} else {
51 59
 	$limit_explode = explode(",", $_GET['limit']);
52 60
 	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
53 61
 	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -65,8 +73,11 @@  discard block
 block discarded – undo
65 73
 
66 74
 header('Content-Type: application/xml');
67 75
 
68
-if (isset($_GET['sort'])) $sort = $_GET['sort'];
69
-else $sort = '';
76
+if (isset($_GET['sort'])) {
77
+	$sort = $_GET['sort'];
78
+} else {
79
+	$sort = '';
80
+}
70 81
 $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
71 82
 $id = filter_input(INPUT_GET,'id',FILTER_SANITIZE_NUMBER_INT);
72 83
 $registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
Please login to merge, or discard this patch.