Completed
Push — master ( 6c4f55...213543 )
by Yannick
10:31
created
require/class.Connection.php 1 patch
Doc Comments   +20 added lines patch added patch discarded remove patch
@@ -6,6 +6,9 @@  discard block
 block discarded – undo
6 6
 	public $dbs = array();
7 7
 	public $latest_schema = 38;
8 8
 	
9
+	/**
10
+	 * @param string $dbname
11
+	 */
9 12
 	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
10 13
 	    global $globalDBdriver, $globalNoDB;
11 14
 	    if (isset($globalNoDB) && $globalNoDB === TRUE) {
@@ -141,6 +144,9 @@  discard block
 block discarded – undo
141 144
 		return true;
142 145
 	}
143 146
 
147
+	/**
148
+	 * @param string $table
149
+	 */
144 150
 	public function tableExists($table)
145 151
 	{
146 152
 		global $globalDBdriver, $globalDBname;
@@ -190,6 +196,11 @@  discard block
 block discarded – undo
190 196
 	/*
191 197
 	* Check if index exist
192 198
 	*/
199
+
200
+	/**
201
+	 * @param string $table
202
+	 * @param string $index
203
+	 */
193 204
 	public function indexExists($table,$index)
194 205
 	{
195 206
 		global $globalDBdriver, $globalDBname;
@@ -232,6 +243,10 @@  discard block
 block discarded – undo
232 243
 		return $columns;
233 244
 	}
234 245
 
246
+	/**
247
+	 * @param string $table
248
+	 * @param string $column
249
+	 */
235 250
 	public function getColumnType($table,$column) {
236 251
 		$select = $this->db->query('SELECT '.$column.' FROM '.$table);
237 252
 		$tomet = $select->getColumnMeta(0);
@@ -242,6 +257,11 @@  discard block
 block discarded – undo
242 257
 	* Check if a column name exist in a table
243 258
 	* @return Boolean column exist or not
244 259
 	*/
260
+
261
+	/**
262
+	 * @param string $table
263
+	 * @param string $name
264
+	 */
245 265
 	public function checkColumnName($table,$name)
246 266
 	{
247 267
 		global $globalDBdriver, $globalDBname;
Please login to merge, or discard this patch.
require/class.Image.php 2 patches
Doc Comments   +13 added lines patch added patch discarded remove patch
@@ -254,6 +254,7 @@  discard block
 block discarded – undo
254 254
 	*
255 255
 	* @param String $aircraft_registration the registration of the aircraft
256 256
 	* @param String $aircraft_name type of the aircraft
257
+	* @param string $type
257 258
 	* @return Array the aircraft thumbnail, orignal url and copyright
258 259
 	*
259 260
 	*/
@@ -287,6 +288,7 @@  discard block
 block discarded – undo
287 288
 	*
288 289
 	* @param String $registration the registration of the aircraft
289 290
 	* @param String $name type of the aircraft
291
+	* @param string $type
290 292
 	* @return Array the aircraft thumbnail, orignal url and copyright
291 293
 	*
292 294
 	*/
@@ -325,6 +327,7 @@  discard block
 block discarded – undo
325 327
 	*
326 328
 	* @param String $aircraft_registration the registration of the aircraft
327 329
 	* @param String $aircraft_name type of the aircraft
330
+	* @param string $type
328 331
 	* @return Array the aircraft thumbnail, orignal url and copyright
329 332
 	*
330 333
 	*/
@@ -367,6 +370,7 @@  discard block
 block discarded – undo
367 370
 	*
368 371
 	* @param String $aircraft_registration the registration of the aircraft
369 372
 	* @param String $aircraft_name type of the aircraft
373
+	* @param string $type
370 374
 	* @return Array the aircraft thumbnail, orignal url and copyright
371 375
 	*
372 376
 	*/
@@ -401,6 +405,7 @@  discard block
 block discarded – undo
401 405
 	*
402 406
 	* @param String $registration the registration of the aircraft
403 407
 	* @param String $name type of the aircraft
408
+	* @param string $type
404 409
 	* @return Array the aircraft thumbnail, orignal url and copyright
405 410
 	*
406 411
 	*/
@@ -429,6 +434,10 @@  discard block
 block discarded – undo
429 434
 		return false;
430 435
 	}
431 436
 
437
+	/**
438
+	 * @param string $type
439
+	 * @param string $aircraft_icao
440
+	 */
432 441
 	public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) {
433 442
 		$Common = new Common();
434 443
 		//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
@@ -450,6 +459,7 @@  discard block
 block discarded – undo
450 459
 	*
451 460
 	* @param String $aircraft_registration the registration of the aircraft
452 461
 	* @param String $aircraft_name type of the aircraft
462
+	* @param string $type
453 463
 	* @return Array the aircraft thumbnail, orignal url and copyright
454 464
 	*
455 465
 	*/
@@ -482,6 +492,7 @@  discard block
 block discarded – undo
482 492
 	*
483 493
 	* @param String $aircraft_registration the registration of the aircraft
484 494
 	* @param String $aircraft_name type of the aircraft
495
+	* @param string $type
485 496
 	* @return Array the aircraft thumbnail, orignal url and copyright
486 497
 	*
487 498
 	*/
@@ -507,6 +518,7 @@  discard block
 block discarded – undo
507 518
 	*
508 519
 	* @param String $registration the registration of the aircraft/mmsi
509 520
 	* @param String $name name
521
+	* @param string $type
510 522
 	* @return Array the aircraft thumbnail, orignal url and copyright
511 523
 	*
512 524
 	*/
@@ -568,6 +580,7 @@  discard block
 block discarded – undo
568 580
 	*
569 581
 	* @param String $aircraft_registration the registration of the aircraft
570 582
 	* @param String $aircraft_name type of the aircraft
583
+	* @param string $type
571 584
 	* @return Array the aircraft thumbnail, orignal url and copyright
572 585
 	*
573 586
 	*/
Please login to merge, or discard this patch.
Braces   +188 added lines, -69 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
23 23
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24 24
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
25 25
 		$reg = $registration;
26
-		if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao;
26
+		if ($reg == '' && $aircraft_icao != '') {
27
+			$reg = $aircraft_icao.$airline_icao;
28
+		}
27 29
 		$reg = trim($reg);
28 30
 		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
29 31
 			FROM spotter_image 
@@ -31,9 +33,13 @@  discard block
 block discarded – undo
31 33
 		$sth = $this->db->prepare($query);
32 34
 		$sth->execute(array(':registration' => $reg));
33 35
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
34
-		if (!empty($result)) return $result;
35
-		elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
36
-		else return array();
36
+		if (!empty($result)) {
37
+			return $result;
38
+		} elseif ($registration != '') {
39
+			return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
40
+		} else {
41
+			return array();
42
+		}
37 43
 	}
38 44
 
39 45
 	/**
@@ -76,8 +82,11 @@  discard block
 block discarded – undo
76 82
 	public function getExifCopyright($url) {
77 83
 		$exif = exif_read_data($url);
78 84
 		$copyright = '';
79
-		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
80
-		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
85
+		if (isset($exif['COMPUTED']['copyright'])) {
86
+			$copyright = $exif['COMPUTED']['copyright'];
87
+		} elseif (isset($exif['copyright'])) {
88
+			$copyright = $exif['copyright'];
89
+		}
81 90
 		if ($copyright != '') {
82 91
 			$copyright = str_replace('Copyright ','',$copyright);
83 92
 			$copyright = str_replace('© ','',$copyright);
@@ -95,17 +104,27 @@  discard block
 block discarded – undo
95 104
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
96 105
 	{
97 106
 		global $globalDebug,$globalAircraftImageFetch;
98
-		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
107
+		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) {
108
+			return '';
109
+		}
99 110
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
100 111
 		$registration = trim($registration);
101 112
 		//getting the aircraft image
102
-		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
103
-		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
104
-		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
113
+		if ($globalDebug && $registration != '') {
114
+			echo 'Try to find an aircraft image for '.$registration.'...';
115
+		} elseif ($globalDebug && $aircraft_icao != '') {
116
+			echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
117
+		} elseif ($globalDebug && $airline_icao != '') {
118
+			echo 'Try to find an aircraft image for '.$airline_icao.'...';
119
+		}
105 120
 		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
106
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
121
+		if ($registration == '' && $aircraft_icao != '') {
122
+			$registration = $aircraft_icao.$airline_icao;
123
+		}
107 124
 		if ($image_url['original'] != '') {
108
-			if ($globalDebug) echo 'Found !'."\n";
125
+			if ($globalDebug) {
126
+				echo 'Found !'."\n";
127
+			}
109 128
 			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
110 129
 			try {
111 130
 				$sth = $this->db->prepare($query);
@@ -114,7 +133,9 @@  discard block
 block discarded – undo
114 133
 				echo $e->getMessage()."\n";
115 134
 				return "error";
116 135
 			}
117
-		} elseif ($globalDebug) echo "Not found :'(\n";
136
+		} elseif ($globalDebug) {
137
+			echo "Not found :'(\n";
138
+		}
118 139
 		return "success";
119 140
 	}
120 141
 
@@ -127,7 +148,9 @@  discard block
 block discarded – undo
127 148
 	public function addMarineImage($mmsi,$imo = '',$name = '')
128 149
 	{
129 150
 		global $globalDebug,$globalMarineImageFetch;
130
-		if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return '';
151
+		if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) {
152
+			return '';
153
+		}
131 154
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
132 155
 		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
133 156
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
@@ -137,16 +160,22 @@  discard block
 block discarded – undo
137 160
 			$identity = $Marine->getIdentity($mmsi);
138 161
 			if (isset($identity[0]['mmsi'])) {
139 162
 				$imo = $identity[0]['imo'];
140
-				if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name'];
163
+				if ($identity[0]['ship_name'] != '') {
164
+					$name = $identity[0]['ship_name'];
165
+				}
141 166
 			}
142 167
 		}
143 168
 		unset($Marine);
144 169
 
145 170
 		//getting the aircraft image
146
-		if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...';
171
+		if ($globalDebug && $name != '') {
172
+			echo 'Try to find an vessel image for '.$name.'...';
173
+		}
147 174
 		$image_url = $this->findMarineImage($mmsi,$imo,$name);
148 175
 		if ($image_url['original'] != '') {
149
-			if ($globalDebug) echo 'Found !'."\n";
176
+			if ($globalDebug) {
177
+				echo 'Found !'."\n";
178
+			}
150 179
 			$query  = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)";
151 180
 			try {
152 181
 				$sth = $this->db->prepare($query);
@@ -155,7 +184,9 @@  discard block
 block discarded – undo
155 184
 				echo $e->getMessage()."\n";
156 185
 				return "error";
157 186
 			}
158
-		} elseif ($globalDebug) echo "Not found :'(\n";
187
+		} elseif ($globalDebug) {
188
+			echo "Not found :'(\n";
189
+		}
159 190
 		return "success";
160 191
 	}
161 192
 
@@ -170,41 +201,85 @@  discard block
 block discarded – undo
170 201
 	{
171 202
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO;
172 203
 		$Spotter = new Spotter($this->db);
173
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
204
+		if (!isset($globalIVAO)) {
205
+			$globalIVAO = FALSE;
206
+		}
174 207
 		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
175 208
 		if ($aircraft_registration != '') {
176
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
209
+			if (strpos($aircraft_registration,'/') !== false) {
210
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
211
+			}
177 212
 			$aircraft_registration = urlencode(trim($aircraft_registration));
178 213
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
179
-			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
180
-			else $aircraft_name = '';
181
-			if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao'];
182
-			else $aircraft_icao = '';
183
-			if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao'];
184
-			else $airline_icao = '';
214
+			if (isset($aircraft_info[0]['aircraft_name'])) {
215
+				$aircraft_name = $aircraft_info[0]['aircraft_name'];
216
+			} else {
217
+				$aircraft_name = '';
218
+			}
219
+			if (isset($aircraft_info[0]['aircraft_icao'])) {
220
+				$aircraft_name = $aircraft_info[0]['aircraft_icao'];
221
+			} else {
222
+				$aircraft_icao = '';
223
+			}
224
+			if (isset($aircraft_info[0]['airline_icao'])) {
225
+				$airline_icao = $aircraft_info[0]['airline_icao'];
226
+			} else {
227
+				$airline_icao = '';
228
+			}
185 229
 		} elseif ($aircraft_icao != '') {
186 230
 			$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao);
187
-			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
188
-			else $aircraft_name = '';
231
+			if (isset($aircraft_info[0]['type'])) {
232
+				$aircraft_name = $aircraft_info[0]['type'];
233
+			} else {
234
+				$aircraft_name = '';
235
+			}
189 236
 			$aircraft_registration = $aircraft_icao;
190
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
237
+		} else {
238
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
239
+		}
191 240
 		unset($Spotter);
192
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
241
+		if (!isset($globalAircraftImageSources)) {
242
+			$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
243
+		}
193 244
 		foreach ($globalAircraftImageSources as $source) {
194 245
 			$source = strtolower($source);
195
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
196
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
197
-			if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
198
-			if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
199
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
200
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
201
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
202
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
203
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
204
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
205
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
206
-		}
207
-		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
246
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') {
247
+				$images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
248
+			}
249
+			if ($source == 'planespotters' && !$globalIVAO) {
250
+				$images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
251
+			}
252
+			if ($source == 'flickr') {
253
+				$images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
254
+			}
255
+			if ($source == 'bing') {
256
+				$images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
257
+			}
258
+			if ($source == 'deviantart') {
259
+				$images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
260
+			}
261
+			if ($source == 'wikimedia') {
262
+				$images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
263
+			}
264
+			if ($source == 'jetphotos' && !$globalIVAO) {
265
+				$images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
266
+			}
267
+			if ($source == 'planepictures' && !$globalIVAO) {
268
+				$images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
269
+			}
270
+			if ($source == 'airportdata' && !$globalIVAO) {
271
+				$images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
272
+			}
273
+			if ($source == 'customsources') {
274
+				$images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
275
+			}
276
+			if (isset($images_array) && $images_array['original'] != '') {
277
+				return $images_array;
278
+			}
279
+		}
280
+		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) {
281
+			return $this->findAircraftImage($aircraft_icao);
282
+		}
208 283
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
209 284
 	}
210 285
 
@@ -224,7 +299,9 @@  discard block
 block discarded – undo
224 299
 		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
225 300
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
226 301
 		$name = trim($name);
227
-		if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
302
+		if (strlen($name) < 4) {
303
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
304
+		}
228 305
 		/*
229 306
 		$Marine = new Marine($this->db);
230 307
 		if ($imo == '' || $name == '') {
@@ -236,15 +313,29 @@  discard block
 block discarded – undo
236 313
 		}
237 314
 		unset($Marine);
238 315
 		*/
239
-		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
316
+		if (!isset($globalMarineImageSources)) {
317
+			$globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
318
+		}
240 319
 		foreach ($globalMarineImageSources as $source) {
241 320
 			$source = strtolower($source);
242
-			if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name);
243
-			if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name);
244
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name);
245
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name);
246
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name);
247
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
321
+			if ($source == 'flickr') {
322
+				$images_array = $this->fromFlickr('marine',$mmsi,$name);
323
+			}
324
+			if ($source == 'bing') {
325
+				$images_array = $this->fromBing('marine',$mmsi,$name);
326
+			}
327
+			if ($source == 'deviantart') {
328
+				$images_array = $this->fromDeviantart('marine',$mmsi,$name);
329
+			}
330
+			if ($source == 'wikimedia') {
331
+				$images_array = $this->fromWikimedia('marine',$mmsi,$name);
332
+			}
333
+			if ($source == 'customsources') {
334
+				$images_array = $this->fromCustomSource('marine',$mmsi,$name);
335
+			}
336
+			if (isset($images_array) && $images_array['original'] != '') {
337
+				return $images_array;
338
+			}
248 339
 		}
249 340
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
250 341
 	}
@@ -407,11 +498,17 @@  discard block
 block discarded – undo
407 498
 	public function fromFlickr($type,$registration,$name='') {
408 499
 		$Common = new Common();
409 500
 		if ($type == 'aircraft') {
410
-			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
411
-			else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft';
501
+			if ($name != '') {
502
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
503
+			} else {
504
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft';
505
+			}
412 506
 		} elseif ($type == 'marine') {
413
-			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.urlencode($name);
414
-			else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',vessel';
507
+			if ($name != '') {
508
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.urlencode($name);
509
+			} else {
510
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',vessel';
511
+			}
415 512
 		}
416 513
 		$data = $Common->getData($url);
417 514
 		if ($xml = simplexml_load_string($data)) {
@@ -456,9 +553,14 @@  discard block
 block discarded – undo
456 553
 	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
457 554
 		global $globalImageBingKey;
458 555
 		$Common = new Common();
459
-		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
460
-		if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
461
-		else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
556
+		if (!isset($globalImageBingKey) || $globalImageBingKey == '') {
557
+			return false;
558
+		}
559
+		if ($aircraft_name != '') {
560
+			$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
561
+		} else {
562
+			$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
563
+		}
462 564
 		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
463 565
 		$data = $Common->getData($url,'get','',$headers);
464 566
 		$result = json_decode($data);
@@ -513,17 +615,25 @@  discard block
 block discarded – undo
513 615
 	public function fromWikimedia($type,$registration,$name='') {
514 616
 		$Common = new Common();
515 617
 		if ($type == 'aircraft') {
516
-			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
517
-			else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
618
+			if ($name != '') {
619
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
620
+			} else {
621
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
622
+			}
518 623
 		} elseif ($type == 'marine') {
519
-			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'"';
520
-			else return false;
624
+			if ($name != '') {
625
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'"';
626
+			} else {
627
+				return false;
628
+			}
521 629
 		}
522 630
 		$data = $Common->getData($url);
523 631
 		$result = json_decode($data);
524 632
 		if (isset($result->query->search[0]->title)) {
525 633
 			$fileo = $result->query->search[0]->title;
526
-			if (substr($fileo,-3) == 'pdf') return false;
634
+			if (substr($fileo,-3) == 'pdf') {
635
+				return false;
636
+			}
527 637
 			$file = urlencode($fileo);
528 638
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
529 639
 			$data2 = $Common->getData($url2);
@@ -594,18 +704,27 @@  discard block
 block discarded – undo
594 704
 					$image_url = array();
595 705
 					$image_url['thumbnail'] = $url_thumbnail;
596 706
 					$image_url['original'] = $url;
597
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
598
-					else $exifCopyright = '';
599
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
600
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
601
-					else $image_url['copyright'] = $source['source_website'];
707
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
708
+						$exifCopyright = $this->getExifCopyright($url);
709
+					} else {
710
+						$exifCopyright = '';
711
+					}
712
+					if ($exifCopyright  != '') {
713
+						$image_url['copyright'] = $exifCopyright;
714
+					} elseif (isset($source['copyright'])) {
715
+						$image_url['copyright'] = $source['copyright'];
716
+					} else {
717
+						$image_url['copyright'] = $source['source_website'];
718
+					}
602 719
 					$image_url['source_website'] = $source['source_website'];
603 720
 					$image_url['source'] = $source['source'];
604 721
 					return $image_url;
605 722
 				}
606 723
 			}
607 724
 			return false;
608
-		} else return false;
725
+		} else {
726
+			return false;
727
+		}
609 728
 	}
610 729
 }
611 730
 
Please login to merge, or discard this patch.
index.php 1 patch
Braces   +393 added lines, -101 removed lines patch added patch discarded remove patch
@@ -150,11 +150,26 @@  discard block
 block discarded – undo
150 150
 				<li><div class="checkbox"><label><input type="checkbox" name="notamcb" value="1" onclick="showNotam();" /><?php echo _("Display NOTAM"); ?></label></div></li>
151 151
 				<li><?php echo _("NOTAM scope:"); ?>
152 152
 					<select class="selectpicker" onchange="notamscope(this);">
153
-						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') print ' selected'; ?>>All</option>
154
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') print ' selected'; ?>>Airport/Enroute warning</option>
155
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') print ' selected'; ?>>Airport warning</option>
156
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') print ' selected'; ?>>Navigation warning</option>
157
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') print ' selected'; ?>>Enroute warning</option>
153
+						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') {
154
+	print ' selected';
155
+}
156
+?>>All</option>
157
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') {
158
+	print ' selected';
159
+}
160
+?>>Airport/Enroute warning</option>
161
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') {
162
+	print ' selected';
163
+}
164
+?>>Airport warning</option>
165
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') {
166
+	print ' selected';
167
+}
168
+?>>Navigation warning</option>
169
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') {
170
+	print ' selected';
171
+}
172
+?>>Enroute warning</option>
158 173
 					</select
159 174
 				</li>
160 175
 			</ul>
@@ -182,7 +197,12 @@  discard block
 block discarded – undo
182 197
 		        <div class="form-group">
183 198
 			    <label>From (UTC):</label>
184 199
 		            <div class='input-group date' id='datetimepicker1'>
185
-            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) print $_POST['start_date']; elseif (isset($_COOKIE['archive_begin'])) print date("m/d/Y h:i a",$_COOKIE['archive_begin']); ?>" required />
200
+            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) {
201
+	print $_POST['start_date'];
202
+} elseif (isset($_COOKIE['archive_begin'])) {
203
+	print date("m/d/Y h:i a",$_COOKIE['archive_begin']);
204
+}
205
+?>" required />
186 206
 		                <span class="input-group-addon">
187 207
             			    <span class="glyphicon glyphicon-calendar"></span>
188 208
 		                </span>
@@ -191,7 +211,12 @@  discard block
 block discarded – undo
191 211
 		        <div class="form-group">
192 212
 			    <label>To (UTC):</label>
193 213
 		            <div class='input-group date' id='datetimepicker2'>
194
-		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) print $_POST['end_date']; elseif (isset($_COOKIE['archive_end'])) print date("m/d/Y h:i a",$_COOKIE['archive_end']); ?>" />
214
+		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) {
215
+	print $_POST['end_date'];
216
+} elseif (isset($_COOKIE['archive_end'])) {
217
+	print date("m/d/Y h:i a",$_COOKIE['archive_end']);
218
+}
219
+?>" />
195 220
             			<span class="input-group-addon">
196 221
 		                    <span class="glyphicon glyphicon-calendar"></span>
197 222
             			</span>
@@ -217,8 +242,20 @@  discard block
 block discarded – undo
217 242
 
218 243
 		    <li><?php echo _("Playback speed:"); ?>
219 244
 			<div class="range">
220
-			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) print $_POST['archivespeed']; elseif (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?>">
221
-			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?></output>
245
+			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) {
246
+	print $_POST['archivespeed'];
247
+} elseif (isset($_COOKIE['archive_speed'])) {
248
+	print $_COOKIE['archive_speed'];
249
+} else {
250
+	print '1';
251
+}
252
+?>">
253
+			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) {
254
+	print $_COOKIE['archive_speed'];
255
+} else {
256
+	print '1';
257
+}
258
+?></output>
222 259
 			</div>
223 260
 		    </li>
224 261
 		    <li><input type="submit" name="archive" value="Show archive" class="btn btn-primary" /></li>
@@ -240,15 +277,27 @@  discard block
 block discarded – undo
240 277
 		    <li><?php echo _("Type of Map:"); ?>
241 278
 			<select  class="selectpicker" onchange="mapType(this);">
242 279
 			    <?php
243
-				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
244
-				else $MapType = $_COOKIE['MapType'];
280
+				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') {
281
+					$MapType = $globalMapProvider;
282
+				} else {
283
+					$MapType = $_COOKIE['MapType'];
284
+				}
245 285
 			    ?>
246 286
 			    <?php
247 287
 				if (isset($globalBingMapKey) && $globalBingMapKey != '') {
248 288
 			    ?>
249
-			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
250
-			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
251
-			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
289
+			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') {
290
+	print ' selected';
291
+}
292
+?>>Bing-Aerial</option>
293
+			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') {
294
+	print ' selected';
295
+}
296
+?>>Bing-Hybrid</option>
297
+			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') {
298
+	print ' selected';
299
+}
300
+?>>Bing-Road</option>
252 301
 			    <?php
253 302
 				}
254 303
 			    ?>
@@ -258,56 +307,131 @@  discard block
 block discarded – undo
258 307
 			    <?php
259 308
 				    if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
260 309
 			    ?>
261
-			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
262
-			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
263
-			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
310
+			    <option value="Here-Aerial"<?php if ($MapType == 'Here') {
311
+	print ' selected';
312
+}
313
+?>>Here-Aerial</option>
314
+			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') {
315
+	print ' selected';
316
+}
317
+?>>Here-Hybrid</option>
318
+			    <option value="Here-Road"<?php if ($MapType == 'Here') {
319
+	print ' selected';
320
+}
321
+?>>Here-Road</option>
264 322
 			    <?php
265 323
 				    }
266 324
 			    ?>
267 325
 			    <?php
268 326
 				    if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
269 327
 			    ?>
270
-			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
271
-			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
272
-			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
273
-			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
328
+			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') {
329
+	print ' selected';
330
+}
331
+?>>Google Roadmap</option>
332
+			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') {
333
+	print ' selected';
334
+}
335
+?>>Google Satellite</option>
336
+			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') {
337
+	print ' selected';
338
+}
339
+?>>Google Hybrid</option>
340
+			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') {
341
+	print ' selected';
342
+}
343
+?>>Google Terrain</option>
274 344
 			    <?php
275 345
 				    }
276 346
 			    ?>
277 347
 			    <?php
278 348
 				    if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
279 349
 			    ?>
280
-			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
281
-			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
282
-			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
350
+			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') {
351
+	print ' selected';
352
+}
353
+?>>MapQuest-OSM</option>
354
+			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') {
355
+	print ' selected';
356
+}
357
+?>>MapQuest-Aerial</option>
358
+			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') {
359
+	print ' selected';
360
+}
361
+?>>MapQuest-Hybrid</option>
283 362
 			    <?php
284 363
 				    }
285 364
 			    ?>
286
-			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
365
+			    <option value="Yandex"<?php if ($MapType == 'Yandex') {
366
+	print ' selected';
367
+}
368
+?>>Yandex</option>
287 369
 			    <?php
288 370
 				}
289 371
 			    ?>
290 372
 			    <?php
291 373
 				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
292
-					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
293
-					else $MapBoxId = $_COOKIE['MapTypeId'];
374
+					if (!isset($_COOKIE['MapTypeId'])) {
375
+						$MapBoxId = 'default';
376
+					} else {
377
+						$MapBoxId = $_COOKIE['MapTypeId'];
378
+					}
294 379
 			    ?>
295
-			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
296
-			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
297
-			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
298
-			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') print ' selected'; ?>>Mapbox dark</option>
299
-			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') print ' selected'; ?>>Mapbox satellite</option>
300
-			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') print ' selected'; ?>>Mapbox streets-satellite</option>
301
-			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') print ' selected'; ?>>Mapbox streets-basic</option>
302
-			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') print ' selected'; ?>>Mapbox comic</option>
303
-			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') print ' selected'; ?>>Mapbox outdoors</option>
304
-			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') print ' selected'; ?>>Mapbox pencil</option>
305
-			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
306
-			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
380
+			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') {
381
+	print ' selected';
382
+}
383
+?>>Mapbox default</option>
384
+			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') {
385
+	print ' selected';
386
+}
387
+?>>Mapbox streets</option>
388
+			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') {
389
+	print ' selected';
390
+}
391
+?>>Mapbox light</option>
392
+			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') {
393
+	print ' selected';
394
+}
395
+?>>Mapbox dark</option>
396
+			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') {
397
+	print ' selected';
398
+}
399
+?>>Mapbox satellite</option>
400
+			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') {
401
+	print ' selected';
402
+}
403
+?>>Mapbox streets-satellite</option>
404
+			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') {
405
+	print ' selected';
406
+}
407
+?>>Mapbox streets-basic</option>
408
+			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') {
409
+	print ' selected';
410
+}
411
+?>>Mapbox comic</option>
412
+			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') {
413
+	print ' selected';
414
+}
415
+?>>Mapbox outdoors</option>
416
+			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') {
417
+	print ' selected';
418
+}
419
+?>>Mapbox pencil</option>
420
+			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') {
421
+	print ' selected';
422
+}
423
+?>>Mapbox pirates</option>
424
+			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') {
425
+	print ' selected';
426
+}
427
+?>>Mapbox emerald</option>
307 428
 			    <?php
308 429
 				    }
309 430
 			    ?>
310
-			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
431
+			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') {
432
+	print ' selected';
433
+}
434
+?>>OpenStreetMap</option>
311 435
 			</select>
312 436
 		    </li>
313 437
 <?php
@@ -315,9 +439,18 @@  discard block
 block discarded – undo
315 439
 ?>
316 440
 		    <li><?php echo _("Type of Terrain:"); ?>
317 441
 			<select  class="selectpicker" onchange="terrainType(this);">
318
-			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option>
319
-			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option>
320
-			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option>
442
+			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') {
443
+	print ' selected';
444
+}
445
+?>>stk terrain</option>
446
+			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') {
447
+	print ' selected';
448
+}
449
+?>>ellipsoid</option>
450
+			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') {
451
+	print ' selected';
452
+}
453
+?>>vr terrain</option>
321 454
 			</select>
322 455
 		    </li>
323 456
 <?php
@@ -327,18 +460,36 @@  discard block
 block discarded – undo
327 460
     if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
328 461
 ?>
329 462
 		    
330
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
331
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) print 'checked'; ?> ><?php echo _("Display flight path"); ?></label></div></li>
332
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li>
333
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
463
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') {
464
+	print 'checked';
465
+}
466
+?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
467
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) {
468
+	print 'checked';
469
+}
470
+?> ><?php echo _("Display flight path"); ?></label></div></li>
471
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) {
472
+	print 'checked';
473
+}
474
+?> ><?php echo _("Display flight route on click"); ?></label></div></li>
475
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) {
476
+	print 'checked';
477
+}
478
+?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
334 479
 <?php
335 480
     }
336 481
 ?>
337
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
482
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') {
483
+	print 'checked';
484
+}
485
+?> ><?php echo _("Display airports on map"); ?></label></div></li>
338 486
 <?php
339 487
     if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
340 488
 ?>
341
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
489
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) {
490
+	print 'checked';
491
+}
492
+?> ><?php echo _("Show mini-map"); ?></label></div></li>
342 493
 <?php
343 494
     }
344 495
     if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
@@ -352,17 +503,25 @@  discard block
 block discarded – undo
352 503
 			if (function_exists('array_column')) {
353 504
 			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
354 505
 		    ?>
355
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
506
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
507
+	print 'checked';
508
+}
509
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
356 510
 		    <?php
357 511
 			    }
358 512
 			} elseif (isset($globalSources)) {
359 513
 			    $dispolar = false;
360 514
 			    foreach ($globalSources as $testsource) {
361
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
515
+			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) {
516
+			        	$dispolar = true;
517
+			        }
362 518
 			    }
363 519
 			    if ($dispolar) {
364 520
 		    ?>
365
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
521
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
522
+	print 'checked';
523
+}
524
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
366 525
 		    <?php
367 526
 			    }
368 527
 		        }
@@ -374,12 +533,22 @@  discard block
 block discarded – undo
374 533
 		    <?php
375 534
 		        if (extension_loaded('gd') && function_exists('gd_info')) {
376 535
 		    ?>
377
-		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
536
+		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') {
537
+	print 'checked';
538
+}
539
+?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
378 540
 		    <?php 
379 541
 			if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
380 542
 		    ?>
381 543
 		    <li><?php echo _("Aircraft icon color:"); ?>
382
-			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>">
544
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
545
+	print $_COOKIE['IconColor'];
546
+} elseif (isset($globalAircraftIconColor)) {
547
+	print $globalAircraftIconColor;
548
+} else {
549
+	print '1a3151';
550
+}
551
+?>">
383 552
 		    </li>
384 553
 		    <?php
385 554
 			    }
@@ -389,30 +558,71 @@  discard block
 block discarded – undo
389 558
 		        if (extension_loaded('gd') && function_exists('gd_info')) {
390 559
 		    ?>
391 560
 		    <li><?php echo _("Marine icon color:"); ?>
392
-			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>">
561
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
562
+	print $_COOKIE['MarineIconColor'];
563
+} elseif (isset($globalMarineIconColor)) {
564
+	print $globalMarineIconColor;
565
+} else {
566
+	print '1a3151';
567
+}
568
+?>">
393 569
 		    </li>
394 570
 		    <?php
395 571
 		        }
396 572
 		    ?>
397 573
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
398 574
 			<div class="range">
399
-			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
400
-			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?></output>
575
+			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) {
576
+	print $_COOKIE['AirportZoom'];
577
+} elseif (isset($globalAirportZoom)) {
578
+	print $globalAirportZoom;
579
+} else {
580
+	print '7';
581
+}
582
+?>">
583
+			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) {
584
+	print $_COOKIE['AirportZoom'];
585
+} elseif (isset($globalAirportZoom)) {
586
+	print $globalAirportZoom;
587
+} else {
588
+	print '7';
589
+}
590
+?></output>
401 591
 			</div>
402 592
 		    </li>
403 593
 <?php
404 594
     } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
405 595
 ?>
406
-		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Aircraft color"); ?></li>
596
+		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') {
597
+	print 'checked';
598
+}
599
+?> ><?php echo _("Force Aircraft color"); ?></li>
407 600
 		    <li><?php echo _("Aircraft icon color:"); ?>
408
-			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print 'ff0000'; ?>">
601
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
602
+	print $_COOKIE['IconColor'];
603
+} elseif (isset($globalAircraftIconColor)) {
604
+	print $globalAircraftIconColor;
605
+} else {
606
+	print 'ff0000';
607
+}
608
+?>">
409 609
 		    </li>
410 610
 <?php
411 611
 	if (isset($globalMarine) && $globalMarine) {
412 612
 ?>
413
-		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Marine color"); ?></li>
613
+		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') {
614
+	print 'checked';
615
+}
616
+?> ><?php echo _("Force Marine color"); ?></li>
414 617
 		    <li><?php echo _("Marine icon color:"); ?>
415
-			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print 'ff0000'; ?>">
618
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
619
+	print $_COOKIE['MarineIconColor'];
620
+} elseif (isset($globalMarineIconColor)) {
621
+	print $globalMarineIconColor;
622
+} else {
623
+	print 'ff0000';
624
+}
625
+?>">
416 626
 		    </li>
417 627
 <?php
418 628
 	}
@@ -420,22 +630,46 @@  discard block
 block discarded – undo
420 630
 ?>
421 631
 		    <li><?php echo _("Distance unit:"); ?>
422 632
 			<select class="selectpicker" onchange="unitdistance(this);">
423
-			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) echo ' selected'; ?>>km</option>
424
-			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) echo ' selected'; ?>>nm</option>
425
-			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) echo ' selected'; ?>>mi</option>
633
+			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
634
+	echo ' selected';
635
+}
636
+?>>km</option>
637
+			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
638
+	echo ' selected';
639
+}
640
+?>>nm</option>
641
+			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
642
+	echo ' selected';
643
+}
644
+?>>mi</option>
426 645
 		        </select>
427 646
 		    </li>
428 647
 		    <li><?php echo _("Altitude unit:"); ?>
429 648
 			<select class="selectpicker" onchange="unitaltitude(this);">
430
-			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) echo ' selected'; ?>>m</option>
431
-			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) echo ' selected'; ?>>feet</option>
649
+			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) {
650
+	echo ' selected';
651
+}
652
+?>>m</option>
653
+			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
654
+	echo ' selected';
655
+}
656
+?>>feet</option>
432 657
 		        </select>
433 658
 		    </li>
434 659
 		    <li><?php echo _("Speed unit:"); ?>
435 660
 			<select class="selectpicker" onchange="unitspeed(this);">
436
-			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) echo ' selected'; ?>>km/h</option>
437
-			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) echo ' selected'; ?>>mph</option>
438
-			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) echo ' selected'; ?>>knots</option>
661
+			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) {
662
+	echo ' selected';
663
+}
664
+?>>km/h</option>
665
+			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
666
+	echo ' selected';
667
+}
668
+?>>mph</option>
669
+			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
670
+	echo ' selected';
671
+}
672
+?>>knots</option>
439 673
 		        </select>
440 674
 		    </li>
441 675
 
@@ -450,9 +684,18 @@  discard block
 block discarded – undo
450 684
 		    <?php
451 685
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
452 686
 		    ?>
453
-			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
454
-			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
455
-			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
687
+			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) {
688
+	print 'checked';
689
+}
690
+?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
691
+			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) {
692
+	print 'checked';
693
+}
694
+?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
695
+			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) {
696
+	print 'checked';
697
+}
698
+?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
456 699
 		    <?php
457 700
 			}
458 701
 		    ?>
@@ -460,10 +703,16 @@  discard block
 block discarded – undo
460 703
 			if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
461 704
 		    ?>
462 705
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
463
-			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
706
+			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) {
707
+	print 'checked';
708
+}
709
+?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
464 710
 			<?php } ?>
465 711
 			<?php if (isset($globalAPRS) && $globalAPRS) { ?>
466
-			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) print 'checked'; ?> ><?php echo _("Display APRS data"); ?></label></div></li>
712
+			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) {
713
+	print 'checked';
714
+}
715
+?> ><?php echo _("Display APRS data"); ?></label></div></li>
467 716
 			<?php } ?>
468 717
 		    <?php
469 718
 			}
@@ -480,7 +729,9 @@  discard block
 block discarded – undo
480 729
 				}
481 730
 				foreach($allairlinenames as $airline) {
482 731
 					$airline_name = $airline['airline_name'];
483
-					if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...';
732
+					if (strlen($airline_name) > 30) {
733
+						$airline_name = substr($airline_name,0,30).'...';
734
+					}
484 735
 					if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['filter_Airlines']))) {
485 736
 						echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>';
486 737
 					} else {
@@ -498,7 +749,10 @@  discard block
 block discarded – undo
498 749
 		    <li><?php echo _("Display alliance:"); ?>
499 750
 		    <br/>
500 751
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
501
-			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
752
+			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') {
753
+	echo ' selected';
754
+}
755
+?>><?php echo _("All"); ?></option>
502 756
 			    <?php
503 757
 				foreach($allalliancenames as $alliance) {
504 758
 					$alliance_name = $alliance['alliance'];
@@ -539,10 +793,22 @@  discard block
 block discarded – undo
539 793
 		    ?>
540 794
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
541 795
 			<select class="selectpicker" onchange="airlinestype(this);">
542
-			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
543
-			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') echo ' selected'; ?>><?php echo _("Passenger"); ?></option>
544
-			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') echo ' selected'; ?>><?php echo _("Cargo"); ?></option>
545
-			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') echo ' selected'; ?>><?php echo _("Military"); ?></option>
796
+			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') {
797
+	echo ' selected';
798
+}
799
+?>><?php echo _("All"); ?></option>
800
+			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') {
801
+	echo ' selected';
802
+}
803
+?>><?php echo _("Passenger"); ?></option>
804
+			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') {
805
+	echo ' selected';
806
+}
807
+?>><?php echo _("Cargo"); ?></option>
808
+			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') {
809
+	echo ' selected';
810
+}
811
+?>><?php echo _("Military"); ?></option>
546 812
 			</select>
547 813
 		    </li>
548 814
 		    <?php
@@ -550,7 +816,10 @@  discard block
 block discarded – undo
550 816
 		    ?>
551 817
 		    <li>
552 818
 			<?php echo _("Display flight with ident:"); ?>
553
-			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
819
+			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) {
820
+	print $_COOKIE['filter_ident'];
821
+}
822
+?>" />
554 823
 		    </li>
555 824
 		</ul>
556 825
 	    </form>
@@ -566,7 +835,10 @@  discard block
 block discarded – undo
566 835
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
567 836
 	    <form>
568 837
 		<ul>
569
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') print 'checked'; ?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
838
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') {
839
+	print 'checked';
840
+}
841
+?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
570 842
 		    <li><?php echo _("Type:"); ?>
571 843
 			<select class="selectpicker" multiple onchange="sattypes(this);">
572 844
 			    <?php
@@ -574,25 +846,45 @@  discard block
 block discarded – undo
574 846
 				$types = $Satellite->get_tle_types();
575 847
 				foreach ($types as $type) {
576 848
 					$type_name = $type['tle_type'];
577
-					if ($type_name == 'musson') $type_name = 'Russian LEO Navigation';
578
-					else if ($type_name == 'nnss') $type_name = 'Navi Navigation Satellite System';
579
-					else if ($type_name == 'sbas') $type_name = 'Satellite-Based Augmentation System';
580
-					else if ($type_name == 'glo-ops') $type_name = 'Glonass Operational';
581
-					else if ($type_name == 'gps-ops') $type_name = 'GPS Operational';
582
-					else if ($type_name == 'argos') $type_name = 'ARGOS Data Collection System';
583
-					else if ($type_name == 'tdrss') $type_name = 'Tracking and Data Relay Satellite System';
584
-					else if ($type_name == 'sarsat') $type_name = 'Search & Rescue';
585
-					else if ($type_name == 'dmc') $type_name = 'Disaster Monitoring';
586
-					else if ($type_name == 'resource') $type_name = 'Earth Resources';
587
-					else if ($type_name == 'stations') $type_name = 'Space Stations';
588
-					else if ($type_name == 'geo') $type_name = 'Geostationary';
589
-					else if ($type_name == 'amateur') $type_name = 'Amateur Radio';
590
-					else if ($type_name == 'x-comm') $type_name = 'Experimental';
591
-					else if ($type_name == 'other-comm') $type_name = 'Other Comm';
592
-					else if ($type_name == 'science') $type_name = 'Space & Earth Science';
593
-					else if ($type_name == 'military') $type_name = 'Miscellaneous Military';
594
-					else if ($type_name == 'radar') $type_name = 'Radar Calibration';
595
-					else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches';
849
+					if ($type_name == 'musson') {
850
+						$type_name = 'Russian LEO Navigation';
851
+					} else if ($type_name == 'nnss') {
852
+						$type_name = 'Navi Navigation Satellite System';
853
+					} else if ($type_name == 'sbas') {
854
+						$type_name = 'Satellite-Based Augmentation System';
855
+					} else if ($type_name == 'glo-ops') {
856
+						$type_name = 'Glonass Operational';
857
+					} else if ($type_name == 'gps-ops') {
858
+						$type_name = 'GPS Operational';
859
+					} else if ($type_name == 'argos') {
860
+						$type_name = 'ARGOS Data Collection System';
861
+					} else if ($type_name == 'tdrss') {
862
+						$type_name = 'Tracking and Data Relay Satellite System';
863
+					} else if ($type_name == 'sarsat') {
864
+						$type_name = 'Search & Rescue';
865
+					} else if ($type_name == 'dmc') {
866
+						$type_name = 'Disaster Monitoring';
867
+					} else if ($type_name == 'resource') {
868
+						$type_name = 'Earth Resources';
869
+					} else if ($type_name == 'stations') {
870
+						$type_name = 'Space Stations';
871
+					} else if ($type_name == 'geo') {
872
+						$type_name = 'Geostationary';
873
+					} else if ($type_name == 'amateur') {
874
+						$type_name = 'Amateur Radio';
875
+					} else if ($type_name == 'x-comm') {
876
+						$type_name = 'Experimental';
877
+					} else if ($type_name == 'other-comm') {
878
+						$type_name = 'Other Comm';
879
+					} else if ($type_name == 'science') {
880
+						$type_name = 'Space & Earth Science';
881
+					} else if ($type_name == 'military') {
882
+						$type_name = 'Miscellaneous Military';
883
+					} else if ($type_name == 'radar') {
884
+						$type_name = 'Radar Calibration';
885
+					} else if ($type_name == 'tle-new') {
886
+						$type_name = 'Last 30 days launches';
887
+					}
596 888
 					
597 889
 					if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) {
598 890
 						print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>';
Please login to merge, or discard this patch.
require/class.MarineImport.php 1 patch
Braces   +152 added lines, -52 removed lines patch added patch discarded remove patch
@@ -53,7 +53,9 @@  discard block
 block discarded – undo
53 53
 
54 54
     public function checkAll() {
55 55
 	global $globalDebug;
56
-	if ($globalDebug) echo "Update last seen tracked data...\n";
56
+	if ($globalDebug) {
57
+		echo "Update last seen tracked data...\n";
58
+	}
57 59
 	foreach ($this->all_tracked as $key => $flight) {
58 60
 	    if (isset($this->all_tracked[$key]['id'])) {
59 61
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -66,13 +68,17 @@  discard block
 block discarded – undo
66 68
     public function del() {
67 69
 	global $globalDebug, $globalNoDB, $globalNoImport;
68 70
 	// Delete old infos
69
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
71
+	if ($globalDebug) {
72
+		echo 'Delete old values and update latest data...'."\n";
73
+	}
70 74
 	foreach ($this->all_tracked as $key => $flight) {
71 75
     	    if (isset($flight['lastupdate'])) {
72 76
         	if ($flight['lastupdate'] < (time()-3000)) {
73 77
             	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
74 78
             		if (isset($this->all_tracked[$key]['id'])) {
75
-            		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
79
+            		    if ($globalDebug) {
80
+            		    	echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
81
+            		    }
76 82
 			    /*
77 83
 			    $MarineLive = new MarineLive();
78 84
             		    $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
@@ -82,7 +88,9 @@  discard block
 block discarded – undo
82 88
             		    $Marine = new Marine($this->db);
83 89
             		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
84 90
 				$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']);
85
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
91
+				if ($globalDebug && $result != 'success') {
92
+					echo '!!! ERROR : '.$result."\n";
93
+				}
86 94
 			    }
87 95
 			    // Put in archive
88 96
 //				$Marine->db = null;
@@ -96,7 +104,9 @@  discard block
 block discarded – undo
96 104
 
97 105
     public function add($line) {
98 106
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine;
99
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
107
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
108
+		$globalCoordMinChange = '0.02';
109
+	}
100 110
 	date_default_timezone_set('UTC');
101 111
 	$dataFound = false;
102 112
 	$send = false;
@@ -121,8 +131,11 @@  discard block
 block discarded – undo
121 131
 		
122 132
 		$Common = new Common();
123 133
 		$AIS = new AIS();
124
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
125
-	        else $id = trim($line['id']);
134
+	        if (!isset($line['id'])) {
135
+	        	$id = trim($line['mmsi']);
136
+	        } else {
137
+	        	$id = trim($line['id']);
138
+	        }
126 139
 		
127 140
 		if (!isset($this->all_tracked[$id])) {
128 141
 		    $this->all_tracked[$id] = array();
@@ -130,10 +143,16 @@  discard block
 block discarded – undo
130 143
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => ''));
131 144
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
132 145
 		    if (!isset($line['id'])) {
133
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
146
+			if (!isset($globalDaemon)) {
147
+				$globalDaemon = TRUE;
148
+			}
134 149
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
135
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
136
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
150
+		     } else {
151
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
152
+		     }
153
+		    if ($globalAllTracked !== FALSE) {
154
+		    	$dataFound = true;
155
+		    }
137 156
 		}
138 157
 		
139 158
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
@@ -183,13 +202,19 @@  discard block
 block discarded – undo
183 202
 				$Marine = new Marine($this->db);
184 203
 				$fromsource = NULL;
185 204
 				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
186
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
205
+				if ($globalDebug && $result != 'success') {
206
+					echo '!!! ERROR : '.$result."\n";
207
+				}
187 208
 				$Marine->db = null;
188
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
209
+				if ($globalDebugTimeElapsed) {
210
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
211
+				}
189 212
 			    }
190 213
 			}
191 214
 		    }
192
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
215
+		    if (!isset($this->all_tracked[$id]['id'])) {
216
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
217
+		    }
193 218
 		}
194 219
 
195 220
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -200,14 +225,21 @@  discard block
 block discarded – undo
200 225
 		    if ($distance > 1000 && $distance < 10000) {
201 226
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
202 227
 			$speed = $speed*3.6;
203
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
204
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
228
+			if ($speed < 1000) {
229
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
230
+			}
231
+  			if ($globalDebug) {
232
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
233
+  			}
205 234
 		    }
206 235
 		}
207 236
 
208 237
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
209
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
210
-	    	    else unset($timediff);
238
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
239
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
240
+	    	    } else {
241
+	    	    	unset($timediff);
242
+	    	    }
211 243
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
212 244
 			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'])) {
213 245
 			    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'])) {
@@ -215,22 +247,32 @@  discard block
 block discarded – undo
215 247
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
216 248
 				$this->all_tracked[$id]['putinarchive'] = true;
217 249
 				
218
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
250
+				if ($globalDebug) {
251
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
252
+				}
219 253
 				$timeelapsed = microtime(true);
220 254
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
221 255
 				    $Marine = new Marine($this->db);
222 256
 				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
223
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
257
+				    if (!empty($all_country)) {
258
+				    	$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
259
+				    }
224 260
 				    $Marine->db = null;
225
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
261
+				    if ($globalDebugTimeElapsed) {
262
+				    	echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
263
+				    }
226 264
 				}
227 265
 				$this->tmd = 0;
228
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
266
+				if ($globalDebug) {
267
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
268
+				}
229 269
 			    }
230 270
 			}
231 271
 
232 272
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
233
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
273
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
274
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
275
+				}
234 276
 				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') {
235 277
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
236 278
 				    $dataFound = true;
@@ -239,8 +281,12 @@  discard block
 block discarded – undo
239 281
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
240 282
 			}
241 283
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
242
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
243
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
284
+			    if ($line['longitude'] > 180) {
285
+			    	$line['longitude'] = $line['longitude'] - 360;
286
+			    }
287
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
288
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
289
+				}
244 290
 				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') {
245 291
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
246 292
 				    $dataFound = true;
@@ -258,7 +304,9 @@  discard block
 block discarded – undo
258 304
 		    }
259 305
 		}
260 306
 		if (isset($line['last_update']) && $line['last_update'] != '') {
261
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
307
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
308
+		    	$dataFound = true;
309
+		    }
262 310
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
263 311
 		}
264 312
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -276,15 +324,21 @@  discard block
 block discarded – undo
276 324
 		}
277 325
 		
278 326
 		if (isset($line['heading']) && $line['heading'] != '') {
279
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
327
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
328
+		    	$this->all_tracked[$id]['putinarchive'] = true;
329
+		    }
280 330
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
281 331
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
282 332
 		    //$dataFound = true;
283 333
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
284 334
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
285 335
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
286
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
287
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
336
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
337
+		    	$this->all_tracked[$id]['putinarchive'] = true;
338
+		    }
339
+  		    if ($globalDebug) {
340
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
341
+  		    }
288 342
   		}
289 343
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
290 344
 
@@ -292,8 +346,11 @@  discard block
 block discarded – undo
292 346
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
293 347
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
294 348
 		    } else {
295
-				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";
296
-				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
+				}
297 354
 				return '';
298 355
 		    }
299 356
 		} else {
@@ -308,23 +365,38 @@  discard block
 block discarded – undo
308 365
 		        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'])) {
309 366
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
310 367
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
311
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
368
+				    if ($globalDebug) {
369
+				    	echo "Check if aircraft is already in DB...";
370
+				    }
312 371
 				    $timeelapsed = microtime(true);
313 372
 				    $MarineLive = new MarineLive($this->db);
314 373
 				    if (isset($line['id'])) {
315 374
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
316
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
375
+					if ($globalDebugTimeElapsed) {
376
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
377
+					}
317 378
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
318 379
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
319
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
380
+					if ($globalDebugTimeElapsed) {
381
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
382
+					}
320 383
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
321 384
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
322
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
323
-				    } else $recent_ident = '';
385
+					if ($globalDebugTimeElapsed) {
386
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
387
+					}
388
+				    } else {
389
+				    	$recent_ident = '';
390
+				    }
324 391
 				    $MarineLive->db=null;
325
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
326
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
327
-				} else $recent_ident = '';
392
+				    if ($globalDebug && $recent_ident == '') {
393
+				    	echo " Not in DB.\n";
394
+				    } elseif ($globalDebug && $recent_ident != '') {
395
+				    	echo " Already in DB.\n";
396
+				    }
397
+				} else {
398
+					$recent_ident = '';
399
+				}
328 400
 			    } else {
329 401
 				$recent_ident = '';
330 402
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -332,18 +404,26 @@  discard block
 block discarded – undo
332 404
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
333 405
 			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
334 406
 			    {
335
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
407
+				if ($globalDebug) {
408
+					echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
409
+				}
336 410
 				//adds the spotter data for the archive
337 411
 				    $highlight = '';
338
-				    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')));
412
+				    if (!isset($this->all_tracked[$id]['id'])) {
413
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
414
+				    }
339 415
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
340 416
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
341 417
 					    $timeelapsed = microtime(true);
342 418
 					    $Marine = new Marine($this->db);
343 419
 					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
344 420
 					    $Marine->db = null;
345
-					    if ($globalDebug && isset($result)) echo $result."\n";
346
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
421
+					    if ($globalDebug && isset($result)) {
422
+					    	echo $result."\n";
423
+					    }
424
+					    if ($globalDebugTimeElapsed) {
425
+					    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
426
+					    }
347 427
 					}
348 428
 				    }
349 429
 				    /*
@@ -378,13 +458,17 @@  discard block
 block discarded – undo
378 458
 				$this->all_tracked[$id]['addedMarine'] = 1;
379 459
 				//print_r($this->all_tracked[$id]);
380 460
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
381
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
461
+				    if ($globalDebug) {
462
+				    	echo "---- Deleting Live Marine data older than 9 hours...";
463
+				    }
382 464
 				    //MarineLive->deleteLiveMarineDataNotUpdated();
383 465
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
384 466
 					$MarineLive = new MarineLive($this->db);
385 467
 					$MarineLive->deleteLiveMarineData();
386 468
 					$MarineLive->db=null;
387
-					if ($globalDebug) echo " Done\n";
469
+					if ($globalDebug) {
470
+						echo " Done\n";
471
+					}
388 472
 				    }
389 473
 				    $this->last_delete = time();
390 474
 				}
@@ -410,15 +494,21 @@  discard block
 block discarded – undo
410 494
 
411 495
 		    if (!$ignoreImport) {
412 496
 			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'])) {
413
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
497
+				if ($globalDebug) {
498
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
499
+				}
414 500
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
415 501
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
416 502
 					$timeelapsed = microtime(true);
417 503
 					$MarineLive = new MarineLive($this->db);
418 504
 					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
419 505
 					$MarineLive->db = null;
420
-					if ($globalDebug) echo $result."\n";
421
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
506
+					if ($globalDebug) {
507
+						echo $result."\n";
508
+					}
509
+					if ($globalDebugTimeElapsed) {
510
+						echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
511
+					}
422 512
 				    }
423 513
 				}
424 514
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
@@ -481,19 +571,27 @@  discard block
 block discarded – undo
481 571
 				*/
482 572
 
483 573
 				$this->all_tracked[$id]['lastupdate'] = time();
484
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
485
-			} 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";
574
+				if ($this->all_tracked[$id]['putinarchive']) {
575
+					$send = true;
576
+				}
577
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
578
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
579
+			}
486 580
 			//$this->del();
487 581
 			
488 582
 			
489 583
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
490 584
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
491
-				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
585
+				if ($globalDebug) {
586
+					echo "---- Deleting Live Marine data Not updated since 2 hour...";
587
+				}
492 588
 				$MarineLive = new MarineLive($this->db);
493 589
 				$MarineLive->deleteLiveMarineDataNotUpdated();
494 590
 				$MarineLive->db = null;
495 591
 				//MarineLive->deleteLiveMarineData();
496
-				if ($globalDebug) echo " Done\n";
592
+				if ($globalDebug) {
593
+					echo " Done\n";
594
+				}
497 595
 			    }
498 596
 			    $this->last_delete_hourly = time();
499 597
 			}
@@ -502,7 +600,9 @@  discard block
 block discarded – undo
502 600
 		    //$ignoreImport = false;
503 601
 		}
504 602
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
505
-		if ($send) return $this->all_tracked[$id];
603
+		if ($send) {
604
+			return $this->all_tracked[$id];
605
+		}
506 606
 	    }
507 607
 	}
508 608
     }
Please login to merge, or discard this patch.
require/class.MarineLive.php 1 patch
Braces   +65 added lines, -22 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -76,8 +78,11 @@  discard block
 block discarded – undo
76 78
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77 79
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
78 80
 		}
79
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81
+		if ($filter_query_where == '' && $where) {
82
+			$filter_query_where = ' WHERE';
83
+		} elseif ($filter_query_where != '' && $and) {
84
+			$filter_query_where .= ' AND';
85
+		}
81 86
 		if ($filter_query_where != '') {
82 87
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
83 88
 		}
@@ -119,7 +124,9 @@  discard block
 block discarded – undo
119 124
 			}
120 125
 		}
121 126
 
122
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
127
+		if (!isset($globalLiveInterval)) {
128
+			$globalLiveInterval = '200';
129
+		}
123 130
 		if ($globalDBdriver == 'mysql') {
124 131
 			//$query  = "SELECT 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";
125 132
 			$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;
@@ -144,7 +151,9 @@  discard block
 block discarded – undo
144 151
 
145 152
 		$filter_query = $this->getFilter($filter,true,true);
146 153
 
147
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
154
+		if (!isset($globalLiveInterval)) {
155
+			$globalLiveInterval = '200';
156
+		}
148 157
 		if ($globalDBdriver == 'mysql') {
149 158
 			$query  = 'SELECT 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 
150 159
 			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";
@@ -178,7 +187,9 @@  discard block
 block discarded – undo
178 187
 
179 188
 		$filter_query = $this->getFilter($filter,true,true);
180 189
 
181
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
190
+		if (!isset($globalLiveInterval)) {
191
+			$globalLiveInterval = '200';
192
+		}
182 193
 		if ($globalDBdriver == 'mysql') {
183 194
 			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
184 195
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
@@ -211,7 +222,9 @@  discard block
 block discarded – undo
211 222
 		global $globalDBdriver, $globalLiveInterval;
212 223
 		$filter_query = $this->getFilter($filter,true,true);
213 224
 
214
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
225
+		if (!isset($globalLiveInterval)) {
226
+			$globalLiveInterval = '200';
227
+		}
215 228
 		if ($globalDBdriver == 'mysql') {
216 229
 			$query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
217 230
 		} else {
@@ -239,7 +252,9 @@  discard block
 block discarded – undo
239 252
 	{
240 253
 		global $globalDBdriver, $globalLiveInterval;
241 254
 		$Spotter = new Spotter($this->db);
242
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
255
+		if (!isset($globalLiveInterval)) {
256
+			$globalLiveInterval = '200';
257
+		}
243 258
 		$filter_query = $this->getFilter($filter);
244 259
 
245 260
 		if (is_array($coord)) {
@@ -247,7 +262,9 @@  discard block
 block discarded – undo
247 262
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
248 263
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
249 264
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
250
-		} else return array();
265
+		} else {
266
+			return array();
267
+		}
251 268
 		if ($globalDBdriver == 'mysql') {
252 269
 			$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'.$filter_query;
253 270
 		} else {
@@ -267,7 +284,9 @@  discard block
 block discarded – undo
267 284
 	{
268 285
 		global $globalDBdriver, $globalLiveInterval;
269 286
 		$Spotter = new Spotter($this->db);
270
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
287
+		if (!isset($globalLiveInterval)) {
288
+			$globalLiveInterval = '200';
289
+		}
271 290
 		$filter_query = $this->getFilter($filter);
272 291
 
273 292
 		if (is_array($coord)) {
@@ -275,7 +294,9 @@  discard block
 block discarded – undo
275 294
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
276 295
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
277 296
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
278
-		} else return array();
297
+		} else {
298
+			return array();
299
+		}
279 300
 		if ($globalDBdriver == 'mysql') {
280 301
 			$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 
281 302
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
@@ -443,11 +464,15 @@  discard block
 block discarded – undo
443 464
 		//$query  = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date';
444 465
 		if ($globalDBdriver == 'mysql') {
445 466
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
446
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
467
+			if ($liveinterval) {
468
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
469
+			}
447 470
 			$query .= ' ORDER BY date';
448 471
 		} else {
449 472
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
450
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
473
+			if ($liveinterval) {
474
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
475
+			}
451 476
 			$query .= ' ORDER BY date';
452 477
 		}
453 478
 
@@ -542,7 +567,9 @@  discard block
 block discarded – undo
542 567
 				$i++;
543 568
 				$j++;
544 569
 				if ($j == 30) {
545
-					if ($globalDebug) echo ".";
570
+					if ($globalDebug) {
571
+						echo ".";
572
+					}
546 573
 				    	try {
547 574
 						
548 575
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -822,7 +849,9 @@  discard block
 block discarded – undo
822 849
 			{
823 850
 				return false;
824 851
 			}
825
-		} else return '';
852
+		} else {
853
+			return '';
854
+		}
826 855
 
827 856
 		if ($longitude != '')
828 857
 		{
@@ -830,7 +859,9 @@  discard block
 block discarded – undo
830 859
 			{
831 860
 				return false;
832 861
 			}
833
-		} else return '';
862
+		} else {
863
+			return '';
864
+		}
834 865
 
835 866
 
836 867
 		if ($heading != '')
@@ -839,7 +870,9 @@  discard block
 block discarded – undo
839 870
 			{
840 871
 				return false;
841 872
 			}
842
-		} else $heading = 0;
873
+		} else {
874
+			$heading = 0;
875
+		}
843 876
 
844 877
 		if ($groundspeed != '')
845 878
 		{
@@ -847,9 +880,13 @@  discard block
 block discarded – undo
847 880
 			{
848 881
 				return false;
849 882
 			}
850
-		} else $groundspeed = 0;
883
+		} else {
884
+			$groundspeed = 0;
885
+		}
851 886
 		date_default_timezone_set('UTC');
852
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
887
+		if ($date == '') {
888
+			$date = date("Y-m-d H:i:s", time());
889
+		}
853 890
 
854 891
         
855 892
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -870,9 +907,15 @@  discard block
 block discarded – undo
870 907
 		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
871 908
 		
872 909
 
873
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
874
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
875
-            	if ($arrival_date == '') $arrival_date = NULL;
910
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
911
+            		$groundspeed = 0;
912
+            	}
913
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
914
+            		$heading = 0;
915
+            	}
916
+            	if ($arrival_date == '') {
917
+            		$arrival_date = NULL;
918
+            	}
876 919
 		$query  = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
877 920
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)';
878 921
 
Please login to merge, or discard this patch.
require/class.TrackerLive.php 1 patch
Braces   +65 added lines, -22 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -76,8 +78,11 @@  discard block
 block discarded – undo
76 78
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77 79
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
78 80
 		}
79
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81
+		if ($filter_query_where == '' && $where) {
82
+			$filter_query_where = ' WHERE';
83
+		} elseif ($filter_query_where != '' && $and) {
84
+			$filter_query_where .= ' AND';
85
+		}
81 86
 		if ($filter_query_where != '') {
82 87
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
83 88
 		}
@@ -119,7 +124,9 @@  discard block
 block discarded – undo
119 124
 			}
120 125
 		}
121 126
 
122
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
127
+		if (!isset($globalLiveInterval)) {
128
+			$globalLiveInterval = '200';
129
+		}
123 130
 		if ($globalDBdriver == 'mysql') {
124 131
 			//$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate";
125 132
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -144,7 +151,9 @@  discard block
 block discarded – undo
144 151
 
145 152
 		$filter_query = $this->getFilter($filter,true,true);
146 153
 
147
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
154
+		if (!isset($globalLiveInterval)) {
155
+			$globalLiveInterval = '200';
156
+		}
148 157
 		if ($globalDBdriver == 'mysql') {
149 158
 			$query  = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
150 159
 			FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0";
@@ -182,7 +191,9 @@  discard block
 block discarded – undo
182 191
 
183 192
 		$filter_query = $this->getFilter($filter,true,true);
184 193
 
185
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194
+		if (!isset($globalLiveInterval)) {
195
+			$globalLiveInterval = '200';
196
+		}
186 197
 		if ($globalDBdriver == 'mysql') {
187 198
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
188 199
 			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
@@ -215,7 +226,9 @@  discard block
 block discarded – undo
215 226
 		global $globalDBdriver, $globalLiveInterval;
216 227
 		$filter_query = $this->getFilter($filter,true,true);
217 228
 
218
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
229
+		if (!isset($globalLiveInterval)) {
230
+			$globalLiveInterval = '200';
231
+		}
219 232
 		if ($globalDBdriver == 'mysql') {
220 233
 			$query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
221 234
 		} else {
@@ -243,7 +256,9 @@  discard block
 block discarded – undo
243 256
 	{
244 257
 		global $globalDBdriver, $globalLiveInterval;
245 258
 		$Spotter = new Spotter($this->db);
246
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
259
+		if (!isset($globalLiveInterval)) {
260
+			$globalLiveInterval = '200';
261
+		}
247 262
 		$filter_query = $this->getFilter($filter);
248 263
 
249 264
 		if (is_array($coord)) {
@@ -251,7 +266,9 @@  discard block
 block discarded – undo
251 266
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
252 267
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
253 268
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
254
-		} else return array();
269
+		} else {
270
+			return array();
271
+		}
255 272
 		if ($globalDBdriver == 'mysql') {
256 273
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
257 274
 		} else {
@@ -271,7 +288,9 @@  discard block
 block discarded – undo
271 288
 	{
272 289
 		global $globalDBdriver, $globalLiveInterval;
273 290
 		$Spotter = new Spotter($this->db);
274
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
291
+		if (!isset($globalLiveInterval)) {
292
+			$globalLiveInterval = '200';
293
+		}
275 294
 		$filter_query = $this->getFilter($filter);
276 295
 
277 296
 		if (is_array($coord)) {
@@ -279,7 +298,9 @@  discard block
 block discarded – undo
279 298
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
280 299
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
281 300
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
282
-		} else return array();
301
+		} else {
302
+			return array();
303
+		}
283 304
 		if ($globalDBdriver == 'mysql') {
284 305
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
285 306
 			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
@@ -472,11 +493,15 @@  discard block
 block discarded – undo
472 493
 		//$query  = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date';
473 494
 		if ($globalDBdriver == 'mysql') {
474 495
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
475
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
496
+			if ($liveinterval) {
497
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
498
+			}
476 499
 			$query .= ' ORDER BY date';
477 500
 		} else {
478 501
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
479
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
502
+			if ($liveinterval) {
503
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
504
+			}
480 505
 			$query .= ' ORDER BY date';
481 506
 		}
482 507
 
@@ -571,7 +596,9 @@  discard block
 block discarded – undo
571 596
 				$i++;
572 597
 				$j++;
573 598
 				if ($j == 30) {
574
-					if ($globalDebug) echo ".";
599
+					if ($globalDebug) {
600
+						echo ".";
601
+					}
575 602
 				    	try {
576 603
 						
577 604
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -818,7 +845,9 @@  discard block
 block discarded – undo
818 845
 			{
819 846
 				return false;
820 847
 			}
821
-		} else return '';
848
+		} else {
849
+			return '';
850
+		}
822 851
 
823 852
 		if ($longitude != '')
824 853
 		{
@@ -826,7 +855,9 @@  discard block
 block discarded – undo
826 855
 			{
827 856
 				return false;
828 857
 			}
829
-		} else return '';
858
+		} else {
859
+			return '';
860
+		}
830 861
 
831 862
 		if ($altitude != '')
832 863
 		{
@@ -834,7 +865,9 @@  discard block
 block discarded – undo
834 865
 			{
835 866
 				return false;
836 867
 			}
837
-		} else $altitude = 0;
868
+		} else {
869
+			$altitude = 0;
870
+		}
838 871
 
839 872
 		if ($heading != '')
840 873
 		{
@@ -842,7 +875,9 @@  discard block
 block discarded – undo
842 875
 			{
843 876
 				return false;
844 877
 			}
845
-		} else $heading = 0;
878
+		} else {
879
+			$heading = 0;
880
+		}
846 881
 
847 882
 		if ($groundspeed != '')
848 883
 		{
@@ -850,9 +885,13 @@  discard block
 block discarded – undo
850 885
 			{
851 886
 				return false;
852 887
 			}
853
-		} else $groundspeed = 0;
888
+		} else {
889
+			$groundspeed = 0;
890
+		}
854 891
 		date_default_timezone_set('UTC');
855
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
892
+		if ($date == '') {
893
+			$date = date("Y-m-d H:i:s", time());
894
+		}
856 895
 
857 896
         
858 897
 		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
@@ -868,8 +907,12 @@  discard block
 block discarded – undo
868 907
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
869 908
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
870 909
 
871
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
872
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
910
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
911
+            		$groundspeed = 0;
912
+            	}
913
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
914
+            		$heading = 0;
915
+            	}
873 916
             	
874 917
 		$query  = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
875 918
 		VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Braces   +153 added lines, -55 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -68,8 +70,11 @@  discard block
 block discarded – undo
68 70
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
69 71
 			}
70 72
 		}
71
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
72
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
73
+		if ($filter_query_where == '' && $where) {
74
+			$filter_query_where = ' WHERE';
75
+		} elseif ($filter_query_where != '' && $and) {
76
+			$filter_query_where .= ' AND';
77
+		}
73 78
 		if ($filter_query_where != '') {
74 79
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
75 80
 		}
@@ -123,31 +128,51 @@  discard block
 block discarded – undo
123 128
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
124 129
 			} elseif (isset($row['spotter_archive_output_id'])) {
125 130
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
126
-			*/} 
127
-			elseif (isset($row['marineid'])) {
131
+			*/} elseif (isset($row['marineid'])) {
128 132
 				$temp_array['marineid'] = $row['marineid'];
129 133
 			} else {
130 134
 				$temp_array['marineid'] = '';
131 135
 			}
132
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
133
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
134
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
135
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
136
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
137
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
138
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
136
+			if (isset($row['fammarine_id'])) {
137
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
138
+			}
139
+			if (isset($row['mmsi'])) {
140
+				$temp_array['mmsi'] = $row['mmsi'];
141
+			}
142
+			if (isset($row['type'])) {
143
+				$temp_array['type'] = $row['type'];
144
+			}
145
+			if (isset($row['ident'])) {
146
+				$temp_array['ident'] = $row['ident'];
147
+			}
148
+			if (isset($row['latitude'])) {
149
+				$temp_array['latitude'] = $row['latitude'];
150
+			}
151
+			if (isset($row['longitude'])) {
152
+				$temp_array['longitude'] = $row['longitude'];
153
+			}
154
+			if (isset($row['format_source'])) {
155
+				$temp_array['format_source'] = $row['format_source'];
156
+			}
139 157
 			if (isset($row['heading'])) {
140 158
 				$temp_array['heading'] = $row['heading'];
141 159
 				$heading_direction = $this->parseDirection($row['heading']);
142
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
160
+				if (isset($heading_direction[0]['direction_fullname'])) {
161
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
162
+				}
163
+			}
164
+			if (isset($row['ground_speed'])) {
165
+				$temp_array['ground_speed'] = $row['ground_speed'];
143 166
 			}
144
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
145 167
 
146 168
 			if($temp_array['mmsi'] != "" && isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE)
147 169
 			{
148 170
 				$Image = new Image($this->db);
149
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
150
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
171
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
172
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
173
+				} else {
174
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
175
+				}
151 176
 				unset($Image);
152 177
 				if (count($image_array) > 0) {
153 178
 					$temp_array['image'] = $image_array[0]['image'];
@@ -199,13 +224,21 @@  discard block
 block discarded – undo
199 224
 			}
200 225
 			
201 226
 			$fromsource = NULL;
202
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
203
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
204
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
227
+			if (isset($row['source_name']) && $row['source_name'] != '') {
228
+				$temp_array['source_name'] = $row['source_name'];
229
+			}
230
+			if (isset($row['over_country']) && $row['over_country'] != '') {
231
+				$temp_array['over_country'] = $row['over_country'];
232
+			}
233
+			if (isset($row['distance']) && $row['distance'] != '') {
234
+				$temp_array['distance'] = $row['distance'];
235
+			}
205 236
 			$temp_array['query_number_rows'] = $num_rows;
206 237
 			$spotter_array[] = $temp_array;
207 238
 		}
208
-		if ($num_rows == 0) return array();
239
+		if ($num_rows == 0) {
240
+			return array();
241
+		}
209 242
 		$spotter_array[0]['query_number_rows'] = $num_rows;
210 243
 		return $spotter_array;
211 244
 	}	
@@ -236,8 +269,12 @@  discard block
 block discarded – undo
236 269
 			{
237 270
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
238 271
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
239
-			} else $limit_query = "";
240
-		} else $limit_query = "";
272
+			} else {
273
+				$limit_query = "";
274
+			}
275
+		} else {
276
+			$limit_query = "";
277
+		}
241 278
 		
242 279
 		if ($sort != "")
243 280
 		{
@@ -265,7 +302,9 @@  discard block
 block discarded – undo
265 302
 		global $global_query;
266 303
 		
267 304
 		date_default_timezone_set('UTC');
268
-		if ($id == '') return array();
305
+		if ($id == '') {
306
+			return array();
307
+		}
269 308
 		$additional_query = "marine_output.fammarine_id = :id";
270 309
 		$query_values = array(':id' => $id);
271 310
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -408,8 +447,11 @@  discard block
 block discarded – undo
408 447
 		$query .= " ORDER BY marine_output.source_name ASC";
409 448
 
410 449
 		$sth = $this->db->prepare($query);
411
-		if (!empty($query_values)) $sth->execute($query_values);
412
-		else $sth->execute();
450
+		if (!empty($query_values)) {
451
+			$sth->execute($query_values);
452
+		} else {
453
+			$sth->execute();
454
+		}
413 455
 
414 456
 		$source_array = array();
415 457
 		$temp_array = array();
@@ -464,8 +506,11 @@  discard block
 block discarded – undo
464 506
 		$sth = $this->db->prepare($query);
465 507
 		$sth->execute(array(':mmsi' => $mmsi));
466 508
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
467
-		if (isset($result[0])) return $result[0];
468
-		else return array();
509
+		if (isset($result[0])) {
510
+			return $result[0];
511
+		} else {
512
+			return array();
513
+		}
469 514
 	}
470 515
 
471 516
 	/*
@@ -481,7 +526,9 @@  discard block
 block discarded – undo
481 526
 			date_default_timezone_set($globalTimezone);
482 527
 			$datetime = new DateTime();
483 528
 			$offset = $datetime->format('P');
484
-		} else $offset = '+00:00';
529
+		} else {
530
+			$offset = '+00:00';
531
+		}
485 532
 
486 533
 		if ($globalDBdriver == 'mysql') {
487 534
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -685,9 +732,15 @@  discard block
 block discarded – undo
685 732
             		$latitude = 0;
686 733
             		$longitude = 0;
687 734
             	}
688
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
689
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
690
-                if ($arrival_date == '') $arrival_date = NULL;
735
+                if ($heading == '' || $Common->isInteger($heading) === false) {
736
+                	$heading = 0;
737
+                }
738
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
739
+                	$groundspeed = 0;
740
+                }
741
+                if ($arrival_date == '') {
742
+                	$arrival_date = NULL;
743
+                }
691 744
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
692 745
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
693 746
 
@@ -851,12 +904,18 @@  discard block
 block discarded – undo
851 904
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
852 905
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
853 906
 		 if ($olderthanmonths > 0) {
854
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
855
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
907
+			if ($globalDBdriver == 'mysql') {
908
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
909
+			} else {
910
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
911
+			}
856 912
 		}
857 913
 		if ($sincedate != '') {
858
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
859
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
914
+			if ($globalDBdriver == 'mysql') {
915
+				$query .= " AND marine_output.date > '".$sincedate."'";
916
+			} else {
917
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
918
+			}
860 919
 		}
861 920
 		$query_values = array();
862 921
 		if ($year != '') {
@@ -887,7 +946,9 @@  discard block
 block discarded – undo
887 946
 			}
888 947
 		}
889 948
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
890
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
949
+		if ($limit) {
950
+			$query .= " LIMIT 10 OFFSET 0";
951
+		}
891 952
       		
892 953
 		$sth = $this->db->prepare($query);
893 954
 		$sth->execute($query_values);
@@ -922,7 +983,9 @@  discard block
 block discarded – undo
922 983
 			date_default_timezone_set($globalTimezone);
923 984
 			$datetime = new DateTime();
924 985
 			$offset = $datetime->format('P');
925
-		} else $offset = '+00:00';
986
+		} else {
987
+			$offset = '+00:00';
988
+		}
926 989
 
927 990
 		if ($globalDBdriver == 'mysql') {
928 991
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -972,7 +1035,9 @@  discard block
 block discarded – undo
972 1035
 			date_default_timezone_set($globalTimezone);
973 1036
 			$datetime = new DateTime();
974 1037
 			$offset = $datetime->format('P');
975
-		} else $offset = '+00:00';
1038
+		} else {
1039
+			$offset = '+00:00';
1040
+		}
976 1041
 		$filter_query = $this->getFilter($filters,true,true);
977 1042
 		if ($globalDBdriver == 'mysql') {
978 1043
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1018,7 +1083,9 @@  discard block
 block discarded – undo
1018 1083
 			date_default_timezone_set($globalTimezone);
1019 1084
 			$datetime = new DateTime();
1020 1085
 			$offset = $datetime->format('P');
1021
-		} else $offset = '+00:00';
1086
+		} else {
1087
+			$offset = '+00:00';
1088
+		}
1022 1089
 		$filter_query = $this->getFilter($filters,true,true);
1023 1090
 		if ($globalDBdriver == 'mysql') {
1024 1091
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1066,7 +1133,9 @@  discard block
 block discarded – undo
1066 1133
 			date_default_timezone_set($globalTimezone);
1067 1134
 			$datetime = new DateTime();
1068 1135
 			$offset = $datetime->format('P');
1069
-		} else $offset = '+00:00';
1136
+		} else {
1137
+			$offset = '+00:00';
1138
+		}
1070 1139
 
1071 1140
 		if ($globalDBdriver == 'mysql') {
1072 1141
 			$query  = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1115,7 +1184,9 @@  discard block
 block discarded – undo
1115 1184
 			date_default_timezone_set($globalTimezone);
1116 1185
 			$datetime = new DateTime();
1117 1186
 			$offset = $datetime->format('P');
1118
-		} else $offset = '+00:00';
1187
+		} else {
1188
+			$offset = '+00:00';
1189
+		}
1119 1190
 		$filter_query = $this->getFilter($filters,true,true);
1120 1191
 		if ($globalDBdriver == 'mysql') {
1121 1192
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1164,7 +1235,9 @@  discard block
 block discarded – undo
1164 1235
 			date_default_timezone_set($globalTimezone);
1165 1236
 			$datetime = new DateTime();
1166 1237
 			$offset = $datetime->format('P');
1167
-		} else $offset = '+00:00';
1238
+		} else {
1239
+			$offset = '+00:00';
1240
+		}
1168 1241
 
1169 1242
 		$orderby_sql = '';
1170 1243
 		if ($orderby == "hour")
@@ -1233,7 +1306,9 @@  discard block
 block discarded – undo
1233 1306
 			date_default_timezone_set($globalTimezone);
1234 1307
 			$datetime = new DateTime($date);
1235 1308
 			$offset = $datetime->format('P');
1236
-		} else $offset = '+00:00';
1309
+		} else {
1310
+			$offset = '+00:00';
1311
+		}
1237 1312
 
1238 1313
 		if ($globalDBdriver == 'mysql') {
1239 1314
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1281,7 +1356,9 @@  discard block
 block discarded – undo
1281 1356
 			date_default_timezone_set($globalTimezone);
1282 1357
 			$datetime = new DateTime();
1283 1358
 			$offset = $datetime->format('P');
1284
-		} else $offset = '+00:00';
1359
+		} else {
1360
+			$offset = '+00:00';
1361
+		}
1285 1362
 
1286 1363
 		if ($globalDBdriver == 'mysql') {
1287 1364
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1345,8 +1422,11 @@  discard block
 block discarded – undo
1345 1422
 				$query_values = array_merge($query_values,array(':month' => $month));
1346 1423
 			}
1347 1424
 		}
1348
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1349
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1425
+		if (empty($query_values)) {
1426
+			$queryi .= $this->getFilter($filters);
1427
+		} else {
1428
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1429
+		}
1350 1430
 		
1351 1431
 		$sth = $this->db->prepare($queryi);
1352 1432
 		$sth->execute($query_values);
@@ -1368,7 +1448,9 @@  discard block
 block discarded – undo
1368 1448
 			date_default_timezone_set($globalTimezone);
1369 1449
 			$datetime = new DateTime();
1370 1450
 			$offset = $datetime->format('P');
1371
-		} else $offset = '+00:00';
1451
+		} else {
1452
+			$offset = '+00:00';
1453
+		}
1372 1454
 
1373 1455
 		if ($globalDBdriver == 'mysql') {
1374 1456
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1472,7 +1554,9 @@  discard block
 block discarded – undo
1472 1554
 	*/
1473 1555
 	public function parseDirection($direction = 0)
1474 1556
 	{
1475
-		if ($direction == '') $direction = 0;
1557
+		if ($direction == '') {
1558
+			$direction = 0;
1559
+		}
1476 1560
 		$direction_array = array();
1477 1561
 		$temp_array = array();
1478 1562
 
@@ -1561,7 +1645,9 @@  discard block
 block discarded – undo
1561 1645
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1562 1646
 	
1563 1647
 		$Connection = new Connection($this->db);
1564
-		if (!$Connection->tableExists('countries')) return '';
1648
+		if (!$Connection->tableExists('countries')) {
1649
+			return '';
1650
+		}
1565 1651
 	
1566 1652
 		try {
1567 1653
 			/*
@@ -1581,9 +1667,13 @@  discard block
 block discarded – undo
1581 1667
 			$sth->closeCursor();
1582 1668
 			if (count($row) > 0) {
1583 1669
 				return $row;
1584
-			} else return '';
1670
+			} else {
1671
+				return '';
1672
+			}
1585 1673
 		} catch (PDOException $e) {
1586
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1674
+			if (isset($globalDebug) && $globalDebug) {
1675
+				echo 'Error : '.$e->getMessage()."\n";
1676
+			}
1587 1677
 			return '';
1588 1678
 		}
1589 1679
 	
@@ -1601,7 +1691,9 @@  discard block
 block discarded – undo
1601 1691
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1602 1692
 	
1603 1693
 		$Connection = new Connection($this->db);
1604
-		if (!$Connection->tableExists('countries')) return '';
1694
+		if (!$Connection->tableExists('countries')) {
1695
+			return '';
1696
+		}
1605 1697
 	
1606 1698
 		try {
1607 1699
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1613,9 +1705,13 @@  discard block
 block discarded – undo
1613 1705
 			$sth->closeCursor();
1614 1706
 			if (count($row) > 0) {
1615 1707
 				return $row;
1616
-			} else return '';
1708
+			} else {
1709
+				return '';
1710
+			}
1617 1711
 		} catch (PDOException $e) {
1618
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1712
+			if (isset($globalDebug) && $globalDebug) {
1713
+				echo 'Error : '.$e->getMessage()."\n";
1714
+			}
1619 1715
 			return '';
1620 1716
 		}
1621 1717
 	
@@ -1633,7 +1729,9 @@  discard block
 block discarded – undo
1633 1729
 	{
1634 1730
 		global $globalBitlyAccessToken;
1635 1731
 		
1636
-		if ($globalBitlyAccessToken == '') return $url;
1732
+		if ($globalBitlyAccessToken == '') {
1733
+			return $url;
1734
+		}
1637 1735
         
1638 1736
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1639 1737
 		
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Braces   +80 added lines, -27 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -118,8 +120,11 @@  discard block
 block discarded – undo
118 120
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
119 121
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
120 122
 		}
121
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
122
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
123
+		if ($filter_query_where == '' && $where) {
124
+			$filter_query_where = ' WHERE';
125
+		} elseif ($filter_query_where != '' && $and) {
126
+			$filter_query_where .= ' AND';
127
+		}
123 128
 		if ($filter_query_where != '') {
124 129
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
125 130
 		}
@@ -161,7 +166,9 @@  discard block
 block discarded – undo
161 166
 			}
162 167
 		}
163 168
 
164
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
169
+		if (!isset($globalLiveInterval)) {
170
+			$globalLiveInterval = '200';
171
+		}
165 172
 		if ($globalDBdriver == 'mysql') {
166 173
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
167 174
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -186,7 +193,9 @@  discard block
 block discarded – undo
186 193
 
187 194
 		$filter_query = $this->getFilter($filter,true,true);
188 195
 
189
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
196
+		if (!isset($globalLiveInterval)) {
197
+			$globalLiveInterval = '200';
198
+		}
190 199
 		if ($globalDBdriver == 'mysql') {
191 200
 //			$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query";
192 201
 //			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao';
@@ -243,7 +252,9 @@  discard block
 block discarded – undo
243 252
 
244 253
 		$filter_query = $this->getFilter($filter,true,true);
245 254
 
246
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
255
+		if (!isset($globalLiveInterval)) {
256
+			$globalLiveInterval = '200';
257
+		}
247 258
 		if ($globalDBdriver == 'mysql') {
248 259
 /*
249 260
 			$query  = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
@@ -287,7 +298,9 @@  discard block
 block discarded – undo
287 298
 		global $globalDBdriver, $globalLiveInterval;
288 299
 		$filter_query = $this->getFilter($filter,true,true);
289 300
 
290
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
301
+		if (!isset($globalLiveInterval)) {
302
+			$globalLiveInterval = '200';
303
+		}
291 304
 		if ($globalDBdriver == 'mysql') {
292 305
 			//$query  = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query;
293 306
 			$query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
@@ -317,7 +330,9 @@  discard block
 block discarded – undo
317 330
 	{
318 331
 		global $globalDBdriver, $globalLiveInterval;
319 332
 		$Spotter = new Spotter($this->db);
320
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
333
+		if (!isset($globalLiveInterval)) {
334
+			$globalLiveInterval = '200';
335
+		}
321 336
 		$filter_query = $this->getFilter($filter);
322 337
 
323 338
 		if (is_array($coord)) {
@@ -325,7 +340,9 @@  discard block
 block discarded – undo
325 340
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
326 341
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
327 342
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
328
-		} else return array();
343
+		} else {
344
+			return array();
345
+		}
329 346
 		if ($globalDBdriver == 'mysql') {
330 347
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
331 348
 		} else {
@@ -346,7 +363,9 @@  discard block
 block discarded – undo
346 363
 	{
347 364
 		global $globalDBdriver, $globalLiveInterval;
348 365
 		$Spotter = new Spotter($this->db);
349
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
366
+		if (!isset($globalLiveInterval)) {
367
+			$globalLiveInterval = '200';
368
+		}
350 369
 		$filter_query = $this->getFilter($filter,true,true);
351 370
 
352 371
 		if (is_array($coord)) {
@@ -354,7 +373,9 @@  discard block
 block discarded – undo
354 373
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
355 374
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
356 375
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
357
-		} else return array();
376
+		} else {
377
+			return array();
378
+		}
358 379
 		if ($globalDBdriver == 'mysql') {
359 380
 			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
360 381
 			FROM spotter_live 
@@ -568,11 +589,15 @@  discard block
 block discarded – undo
568 589
 		//$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
569 590
 		if ($globalDBdriver == 'mysql') {
570 591
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
571
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
592
+			if ($liveinterval) {
593
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
594
+			}
572 595
 			$query .= ' ORDER BY date';
573 596
 		} else {
574 597
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
575
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
598
+			if ($liveinterval) {
599
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
600
+			}
576 601
 			$query .= ' ORDER BY date';
577 602
 		}
578 603
 
@@ -667,7 +692,9 @@  discard block
 block discarded – undo
667 692
 				$i++;
668 693
 				$j++;
669 694
 				if ($j == 30) {
670
-					if ($globalDebug) echo ".";
695
+					if ($globalDebug) {
696
+						echo ".";
697
+					}
671 698
 				    	try {
672 699
 						
673 700
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -974,7 +1001,9 @@  discard block
 block discarded – undo
974 1001
 			{
975 1002
 				return false;
976 1003
 			}
977
-		} else return '';
1004
+		} else {
1005
+			return '';
1006
+		}
978 1007
 
979 1008
 		if ($longitude != '')
980 1009
 		{
@@ -982,7 +1011,9 @@  discard block
 block discarded – undo
982 1011
 			{
983 1012
 				return false;
984 1013
 			}
985
-		} else return '';
1014
+		} else {
1015
+			return '';
1016
+		}
986 1017
 
987 1018
 		if ($waypoints != '')
988 1019
 		{
@@ -998,7 +1029,9 @@  discard block
 block discarded – undo
998 1029
 			{
999 1030
 				return false;
1000 1031
 			}
1001
-		} else $altitude = 0;
1032
+		} else {
1033
+			$altitude = 0;
1034
+		}
1002 1035
 
1003 1036
 		if ($heading != '')
1004 1037
 		{
@@ -1006,7 +1039,9 @@  discard block
 block discarded – undo
1006 1039
 			{
1007 1040
 				return false;
1008 1041
 			}
1009
-		} else $heading = 0;
1042
+		} else {
1043
+			$heading = 0;
1044
+		}
1010 1045
 
1011 1046
 		if ($groundspeed != '')
1012 1047
 		{
@@ -1014,9 +1049,13 @@  discard block
 block discarded – undo
1014 1049
 			{
1015 1050
 				return false;
1016 1051
 			}
1017
-		} else $groundspeed = 0;
1052
+		} else {
1053
+			$groundspeed = 0;
1054
+		}
1018 1055
 		date_default_timezone_set('UTC');
1019
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1056
+		if ($date == '') {
1057
+			$date = date("Y-m-d H:i:s", time());
1058
+		}
1020 1059
 
1021 1060
         
1022 1061
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -1060,14 +1099,24 @@  discard block
 block discarded – undo
1060 1099
 		$arrival_airport_country = '';
1061 1100
 		
1062 1101
             	
1063
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1064
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1065
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1066
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1102
+            	if ($squawk == '' || $Common->isInteger($squawk) === false ) {
1103
+            		$squawk = NULL;
1104
+            	}
1105
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) {
1106
+            		$verticalrate = NULL;
1107
+            	}
1108
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1109
+            		$groundspeed = 0;
1110
+            	}
1111
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1112
+            		$heading = 0;
1113
+            	}
1067 1114
 		
1068 1115
 		$query = '';
1069 1116
 		if ($globalArchive) {
1070
-			if ($globalDebug) echo '-- Delete previous data -- ';
1117
+			if ($globalDebug) {
1118
+				echo '-- Delete previous data -- ';
1119
+			}
1071 1120
 			$query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;';
1072 1121
 		}
1073 1122
 
@@ -1083,10 +1132,14 @@  discard block
 block discarded – undo
1083 1132
 			return "error : ".$e->getMessage();
1084 1133
 		}
1085 1134
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1086
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1135
+		    if ($globalDebug) {
1136
+		    	echo '(Add to SBS archive : ';
1137
+		    }
1087 1138
 		    $SpotterArchive = new SpotterArchive($this->db);
1088 1139
 		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1089
-		    if ($globalDebug) echo $result.')';
1140
+		    if ($globalDebug) {
1141
+		    	echo $result.')';
1142
+		    }
1090 1143
 		}
1091 1144
 		return "success";
1092 1145
 
Please login to merge, or discard this patch.
js/map-marine.2d.js.php 1 patch
Braces   +42 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,8 +5,11 @@  discard block
 block discarded – undo
5 5
 setcookie("MapFormat",'2d');
6 6
 
7 7
 // Compressed GeoJson is used if true
8
-if (!isset($globalJsonCompress)) $compress = true;
9
-else $compress = $globalJsonCompress;
8
+if (!isset($globalJsonCompress)) {
9
+	$compress = true;
10
+} else {
11
+	$compress = $globalJsonCompress;
12
+}
10 13
 ?>
11 14
 
12 15
 
@@ -142,9 +145,13 @@  discard block
 block discarded – undo
142 145
 		    if (callsign != ""){ markerMarineLabel += callsign; }
143 146
 		    if (type != ""){ markerMarineLabel += ' - '+type; }
144 147
 <?php
145
-	if (isset($_COOKIE['MarineIconColor'])) $MarineIconColor = $_COOKIE['MarineIconColor'];
146
-	elseif (isset($globalMarineIconColor)) $MarineIconColor = $globalMarineIconColor;
147
-	else $MarineIconColor = '1a3151';
148
+	if (isset($_COOKIE['MarineIconColor'])) {
149
+		$MarineIconColor = $_COOKIE['MarineIconColor'];
150
+	} elseif (isset($globalMarineIconColor)) {
151
+		$MarineIconColor = $globalMarineIconColor;
152
+	} else {
153
+		$MarineIconColor = '1a3151';
154
+	}
148 155
 	if (!isset($ident) && !isset($fammarine_id)) {
149 156
 ?>
150 157
 		    info_marine_update(feature.properties.fc);
@@ -179,7 +186,12 @@  discard block
 block discarded – undo
179 186
 <?php
180 187
 		} else {
181 188
 ?>
182
-		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
189
+		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
190
+	print $archiveupdatetime*1000;
191
+} else {
192
+	print $globalMapRefresh*1000+20000;
193
+}
194
+?>+feature.properties.sqt*1000);
183 195
 		    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
184 196
 <?php
185 197
 		}
@@ -228,7 +240,12 @@  discard block
 block discarded – undo
228 240
 <?php
229 241
 		} else {
230 242
 ?>
231
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
243
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
244
+	print $archiveupdatetime*1000;
245
+} else {
246
+	print $globalMapRefresh*1000+20000;
247
+}
248
+?>+feature.properties.sqt*1000);
232 249
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
233 250
 <?php
234 251
 		}
@@ -276,7 +293,12 @@  discard block
 block discarded – undo
276 293
 <?php
277 294
 		} else {
278 295
 ?>
279
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
296
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
297
+	print $archiveupdatetime*1000;
298
+} else {
299
+	print $globalMapRefresh*1000+20000;
300
+}
301
+?>+feature.properties.sqt*1000);
280 302
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
281 303
 <?php
282 304
 		}
@@ -559,14 +581,24 @@  discard block
 block discarded – undo
559 581
 	if (isset($archive) && $archive) {
560 582
 ?>
561 583
 //then load it again every 30 seconds
562
-//  var reload = setInterval(function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>);
584
+//  var reload = setInterval(function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) {
585
+	print ($globalMapRefresh*1000)/2;
586
+} else {
587
+	print '15000';
588
+}
589
+?>);
563 590
 reloadMarinePage = setInterval(function(){if (noTimeout) getLiveMarineData(0)},<?php print $archiveupdatetime*1000; ?>);
564 591
 <?php
565 592
 	} else {
566 593
 ?>
567 594
 //then load it again every 30 seconds
568 595
 reloadMarinePage = setInterval(
569
-    function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
596
+    function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) {
597
+	print $globalMapRefresh*1000;
598
+} else {
599
+	print '30000';
600
+}
601
+?>);
570 602
 <?php
571 603
 	}
572 604
 ?>
Please login to merge, or discard this patch.