Completed
Push — master ( 9ccc85...3105cd )
by Yannick
33:11
created
statistics-route-airport.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 $route_array = $Spotter->countAllRoutes();
19 19
 print '<div id="chart" class="chart" width="100%"></div><script>';
20 20
 $route_data = '';
21
-foreach($route_array as $route_item)
21
+foreach ($route_array as $route_item)
22 22
 {
23 23
 	$route_data .= '[ "'.$route_item['airport_departure_icao'].' - '.$route_item['airport_arrival_icao'].'",'.$route_item['route_count'].'],';
24 24
 }
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	print '</thead>';
47 47
 	print '<tbody>';
48 48
 	$i = 1;
49
-	foreach($route_array as $route_item)
49
+	foreach ($route_array as $route_item)
50 50
 	{
51 51
 		print '<tr>';
52 52
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
5 5
 $Spotter = new Spotter();
6 6
 $title = _("Statistics").' - '._("Most common Route by Airport");
7 7
 require_once('header.php');
8
-if (!isset($filter_name)) $filter_name = '';
8
+if (!isset($filter_name)) {
9
+	$filter_name = '';
10
+}
9 11
 include('statistics-sub-menu.php'); 
10 12
 
11 13
 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
Please login to merge, or discard this patch.
incident.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3
-$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
3
+$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING);
4 4
 if ($date == '') $date = date('Y-m-d');
5 5
 header('Location: '.$globalURL.'/incident/'.$date);
6 6
 ?>
7 7
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
4
-if ($date == '') $date = date('Y-m-d');
4
+if ($date == '') {
5
+	$date = date('Y-m-d');
6
+}
5 7
 header('Location: '.$globalURL.'/incident/'.$date);
6 8
 ?>
7 9
\ No newline at end of file
Please login to merge, or discard this patch.
date-statistics-departure-airport-country.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -3,13 +3,13 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 $Spotter = new Spotter();
6
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
7
-$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
8
-$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
6
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
7
+$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING);
8
+$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort);
9 9
 
10 10
 if (!empty($spotter_array))
11 11
 {
12
-	$title = sprintf(_("Most Common Departure Airports by Country on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
12
+	$title = sprintf(_("Most Common Departure Airports by Country on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
13 13
 
14 14
 	require_once('header.php');
15 15
 	print '<div class="select-item">';
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
 	print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>';
28 28
 	print '<br />';
29 29
 	print '<div class="info column">';
30
-	print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
30
+	print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
31 31
 	print '</div>';
32 32
 
33 33
 	include('date-sub-menu.php');
34 34
 	print '<div class="column">';
35 35
 	print '<h2>'._("Most Common Departure Airports by Country").'</h2>';
36
-	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
36
+	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
37 37
 	$airport_country_array = $Spotter->countAllDepartureAirportCountriesByDate($date);
38 38
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
39 39
 	print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
42 42
 	print 'var series = [';
43 43
 	$country_data = '';
44
-	foreach($airport_country_array as $airport_item)
44
+	foreach ($airport_country_array as $airport_item)
45 45
 	{
46 46
 		$country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],';
47 47
 	}
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		print '</thead>';
90 90
 		print '<tbody>';
91 91
 		$i = 1;
92
-		foreach($airport_country_array as $airport_item)
92
+		foreach ($airport_country_array as $airport_item)
93 93
 		{
94 94
 			print '<tr>';
95 95
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
manufacturer-sub-menu.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@  discard block
 block discarded – undo
3 3
 </span>
4 4
 <div class="sub-menu sub-menu-container">
5 5
 	<ul class="nav nav-pills">
6
-		<li><a href="<?php print $globalURL; ?>/manufacturer/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-detailed"){ print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li>
6
+		<li><a href="<?php print $globalURL; ?>/manufacturer/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-detailed") { print 'class="active"'; } ?>><?php echo _("Detailed"); ?></a></li>
7 7
 		<li class="dropdown">
8
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-aircraft" || strtolower($current_page) == "manufacturer-statistics-registration"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
8
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-aircraft" || strtolower($current_page) == "manufacturer-statistics-registration") { print 'active'; } ?>" data-toggle="dropdown" href="#">
9 9
 		      <?php echo _("Aircraft"); ?> <span class="caret"></span>
10 10
 		    </a>
11 11
 		    <ul class="dropdown-menu" role="menu">
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 		    </ul>
15 15
 		</li>
16 16
 		<li class="dropdown">
17
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-airline" || strtolower($current_page) == "manufacturer-statistics-airline-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
17
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-airline" || strtolower($current_page) == "manufacturer-statistics-airline-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
18 18
 		      <?php echo _("Airline"); ?> <span class="caret"></span>
19 19
 		    </a>
20 20
 		    <ul class="dropdown-menu" role="menu">
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 		    </ul>
24 24
 		</li>
25 25
 		<li class="dropdown">
26
-		    <a class="dropdown-toggle <?php if(strtolower($current_page) == "manufacturer-statistics-departure-airport" || strtolower($current_page) == "manufacturer-statistics-departure-airport-country" || strtolower($current_page) == "manufacturer-statistics-arrival-airport" || strtolower($current_page) == "manufacturer-statistics-arrival-airport-country"){ print 'active'; } ?>" data-toggle="dropdown" href="#">
26
+		    <a class="dropdown-toggle <?php if (strtolower($current_page) == "manufacturer-statistics-departure-airport" || strtolower($current_page) == "manufacturer-statistics-departure-airport-country" || strtolower($current_page) == "manufacturer-statistics-arrival-airport" || strtolower($current_page) == "manufacturer-statistics-arrival-airport-country") { print 'active'; } ?>" data-toggle="dropdown" href="#">
27 27
 		      <?php echo _("Airport"); ?> <span class="caret"></span>
28 28
 		    </a>
29 29
 		    <ul class="dropdown-menu" role="menu">
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 			  <li><a href="<?php print $globalURL; ?>/manufacturer/statistics/arrival-airport-country/<?php print $manufacturer; ?>"><?php echo _("Arrival Airport by Country"); ?></a></li>
34 34
 		    </ul>
35 35
 		</li>
36
-		<li><a href="<?php print $globalURL; ?>/manufacturer/statistics/route/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-route"){ print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li>
37
-		<li><a href="<?php print $globalURL; ?>/manufacturer/statistics/time/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-time"){ print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li>
36
+		<li><a href="<?php print $globalURL; ?>/manufacturer/statistics/route/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-route") { print 'class="active"'; } ?>><?php echo _("Route"); ?></a></li>
37
+		<li><a href="<?php print $globalURL; ?>/manufacturer/statistics/time/<?php print $manufacturer; ?>" <?php if (strtolower($current_page) == "manufacturer-statistics-time") { print 'class="active"'; } ?>><?php echo _("Time"); ?></a></li>
38 38
 	</ul>
39 39
 </div>
40 40
\ No newline at end of file
Please login to merge, or discard this patch.
require/class.Image.php 4 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 $registration the registration of the aircraft
570 582
 	* @param String $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.
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
 	}
24 24
 
25 25
 	/**
26
-	* Gets the images based on the aircraft registration
27
-	*
28
-	* @return Array the images list
29
-	*
30
-	*/
26
+	 * Gets the images based on the aircraft registration
27
+	 *
28
+	 * @return Array the images list
29
+	 *
30
+	 */
31 31
 	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
32 32
 	{
33 33
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
 	}
49 49
 
50 50
 	/**
51
-	* Gets the images based on the ship name
52
-	*
53
-	* @return Array the images list
54
-	*
55
-	*/
51
+	 * Gets the images based on the ship name
52
+	 *
53
+	 * @return Array the images list
54
+	 *
55
+	 */
56 56
 	public function getMarineImage($mmsi,$imo = '',$name = '',$type_name = '')
57 57
 	{
58 58
 		global $globalMarineImagePics;
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
 	}
91 91
 
92 92
 	/**
93
-	* Gets the image copyright based on the Exif data
94
-	*
95
-	* @return String image copyright
96
-	*
97
-	*/
93
+	 * Gets the image copyright based on the Exif data
94
+	 *
95
+	 * @return String image copyright
96
+	 *
97
+	 */
98 98
 	public function getExifCopyright($url) {
99 99
 		$exif = exif_read_data($url);
100 100
 		$copyright = '';
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 	}
110 110
 
111 111
 	/**
112
-	* Adds the images based on the aircraft registration
113
-	*
114
-	* @return String either success or error
115
-	*
116
-	*/
112
+	 * Adds the images based on the aircraft registration
113
+	 *
114
+	 * @return String either success or error
115
+	 *
116
+	 */
117 117
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
118 118
 	{
119 119
 		global $globalDebug,$globalAircraftImageFetch, $globalOffline;
@@ -141,11 +141,11 @@  discard block
 block discarded – undo
141 141
 	}
142 142
 
143 143
 	/**
144
-	* Adds the images based on the marine name
145
-	*
146
-	* @return String either success or error
147
-	*
148
-	*/
144
+	 * Adds the images based on the marine name
145
+	 *
146
+	 * @return String either success or error
147
+	 *
148
+	 */
149 149
 	public function addMarineImage($mmsi,$imo = '',$name = '')
150 150
 	{
151 151
 		global $globalDebug,$globalMarineImageFetch, $globalOffline;
@@ -182,12 +182,12 @@  discard block
 block discarded – undo
182 182
 	}
183 183
 
184 184
 	/**
185
-	* Gets the aircraft image
186
-	*
187
-	* @param String $aircraft_registration the registration of the aircraft
188
-	* @return Array the aircraft thumbnail, orignal url and copyright
189
-	*
190
-	*/
185
+	 * Gets the aircraft image
186
+	 *
187
+	 * @param String $aircraft_registration the registration of the aircraft
188
+	 * @return Array the aircraft thumbnail, orignal url and copyright
189
+	 *
190
+	 */
191 191
 	public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '')
192 192
 	{
193 193
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
 	}
232 232
 
233 233
 	/**
234
-	* Gets the vessel image
235
-	*
236
-	* @param String $mmsi the vessel mmsi
237
-	* @param String $imo the vessel imo
238
-	* @param String $name the vessel name
239
-	* @return Array the aircraft thumbnail, orignal url and copyright
240
-	*
241
-	*/
234
+	 * Gets the vessel image
235
+	 *
236
+	 * @param String $mmsi the vessel mmsi
237
+	 * @param String $imo the vessel imo
238
+	 * @param String $name the vessel name
239
+	 * @return Array the aircraft thumbnail, orignal url and copyright
240
+	 *
241
+	 */
242 242
 	public function findMarineImage($mmsi,$imo = '',$name = '')
243 243
 	{
244 244
 		global $globalMarineImageSources;
@@ -272,13 +272,13 @@  discard block
 block discarded – undo
272 272
 	}
273 273
 
274 274
 	/**
275
-	* Gets the aircraft image from Planespotters
276
-	*
277
-	* @param String $aircraft_registration the registration of the aircraft
278
-	* @param String $aircraft_name type of the aircraft
279
-	* @return Array the aircraft thumbnail, orignal url and copyright
280
-	*
281
-	*/
275
+	 * Gets the aircraft image from Planespotters
276
+	 *
277
+	 * @param String $aircraft_registration the registration of the aircraft
278
+	 * @param String $aircraft_name type of the aircraft
279
+	 * @return Array the aircraft thumbnail, orignal url and copyright
280
+	 *
281
+	 */
282 282
 	public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') {
283 283
 		$Common = new Common();
284 284
 		// If aircraft registration is only number, also check with aircraft model
@@ -306,13 +306,13 @@  discard block
 block discarded – undo
306 306
 	}
307 307
 
308 308
 	/**
309
-	* Gets the aircraft image from Deviantart
310
-	*
311
-	* @param String $registration the registration of the aircraft
312
-	* @param String $name type of the aircraft
313
-	* @return Array the aircraft thumbnail, orignal url and copyright
314
-	*
315
-	*/
309
+	 * Gets the aircraft image from Deviantart
310
+	 *
311
+	 * @param String $registration the registration of the aircraft
312
+	 * @param String $name type of the aircraft
313
+	 * @return Array the aircraft thumbnail, orignal url and copyright
314
+	 *
315
+	 */
316 316
 	public function fromDeviantart($type,$registration, $name='') {
317 317
 		$Common = new Common();
318 318
 		if ($type == 'aircraft') {
@@ -346,13 +346,13 @@  discard block
 block discarded – undo
346 346
 	}
347 347
 
348 348
 	/**
349
-	* Gets the aircraft image from JetPhotos
350
-	*
351
-	* @param String $aircraft_registration the registration of the aircraft
352
-	* @param String $aircraft_name type of the aircraft
353
-	* @return Array the aircraft thumbnail, orignal url and copyright
354
-	*
355
-	*/
349
+	 * Gets the aircraft image from JetPhotos
350
+	 *
351
+	 * @param String $aircraft_registration the registration of the aircraft
352
+	 * @param String $aircraft_name type of the aircraft
353
+	 * @return Array the aircraft thumbnail, orignal url and copyright
354
+	 *
355
+	 */
356 356
 	public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') {
357 357
 		$Common = new Common();
358 358
 		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
@@ -388,13 +388,13 @@  discard block
 block discarded – undo
388 388
 	}
389 389
 
390 390
 	/**
391
-	* Gets the aircraft image from PlanePictures
392
-	*
393
-	* @param String $aircraft_registration the registration of the aircraft
394
-	* @param String $aircraft_name type of the aircraft
395
-	* @return Array the aircraft thumbnail, orignal url and copyright
396
-	*
397
-	*/
391
+	 * Gets the aircraft image from PlanePictures
392
+	 *
393
+	 * @param String $aircraft_registration the registration of the aircraft
394
+	 * @param String $aircraft_name type of the aircraft
395
+	 * @return Array the aircraft thumbnail, orignal url and copyright
396
+	 *
397
+	 */
398 398
 	public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') {
399 399
 		$Common = new Common();
400 400
 		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
@@ -422,13 +422,13 @@  discard block
 block discarded – undo
422 422
 	}
423 423
 
424 424
 	/**
425
-	* Gets the aircraft image from Flickr
426
-	*
427
-	* @param String $registration the registration of the aircraft
428
-	* @param String $name type of the aircraft
429
-	* @return Array the aircraft thumbnail, orignal url and copyright
430
-	*
431
-	*/
425
+	 * Gets the aircraft image from Flickr
426
+	 *
427
+	 * @param String $registration the registration of the aircraft
428
+	 * @param String $name type of the aircraft
429
+	 * @return Array the aircraft thumbnail, orignal url and copyright
430
+	 *
431
+	 */
432 432
 	public function fromFlickr($type,$registration,$name='') {
433 433
 		$Common = new Common();
434 434
 		if ($type == 'aircraft') {
@@ -472,13 +472,13 @@  discard block
 block discarded – undo
472 472
 	}
473 473
 
474 474
 	/**
475
-	* Gets the aircraft image from Bing
476
-	*
477
-	* @param String $aircraft_registration the registration of the aircraft
478
-	* @param String $aircraft_name type of the aircraft
479
-	* @return Array the aircraft thumbnail, orignal url and copyright
480
-	*
481
-	*/
475
+	 * Gets the aircraft image from Bing
476
+	 *
477
+	 * @param String $aircraft_registration the registration of the aircraft
478
+	 * @param String $aircraft_name type of the aircraft
479
+	 * @return Array the aircraft thumbnail, orignal url and copyright
480
+	 *
481
+	 */
482 482
 	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
483 483
 		global $globalImageBingKey;
484 484
 		$Common = new Common();
@@ -509,13 +509,13 @@  discard block
 block discarded – undo
509 509
 	}
510 510
 
511 511
 	/**
512
-	* Gets the aircraft image from airport-data
513
-	*
514
-	* @param String $aircraft_registration the registration of the aircraft
515
-	* @param String $aircraft_name type of the aircraft
516
-	* @return Array the aircraft thumbnail, orignal url and copyright
517
-	*
518
-	*/
512
+	 * Gets the aircraft image from airport-data
513
+	 *
514
+	 * @param String $aircraft_registration the registration of the aircraft
515
+	 * @param String $aircraft_name type of the aircraft
516
+	 * @return Array the aircraft thumbnail, orignal url and copyright
517
+	 *
518
+	 */
519 519
 	public function fromAirportData($type,$aircraft_registration,$aircraft_name='') {
520 520
 		$Common = new Common();
521 521
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
@@ -534,13 +534,13 @@  discard block
 block discarded – undo
534 534
 	}
535 535
 
536 536
 	/**
537
-	* Gets image from WikiMedia
538
-	*
539
-	* @param String $registration the registration of the aircraft/mmsi
540
-	* @param String $name name
541
-	* @return Array the aircraft thumbnail, orignal url and copyright
542
-	*
543
-	*/
537
+	 * Gets image from WikiMedia
538
+	 *
539
+	 * @param String $registration the registration of the aircraft/mmsi
540
+	 * @param String $name name
541
+	 * @return Array the aircraft thumbnail, orignal url and copyright
542
+	 *
543
+	 */
544 544
 	public function fromWikimedia($type,$registration,$name='') {
545 545
 		$Common = new Common();
546 546
 		if ($type == 'aircraft') {
@@ -595,13 +595,13 @@  discard block
 block discarded – undo
595 595
 	}
596 596
 
597 597
 	/**
598
-	* Gets the aircraft image from custom url
599
-	*
600
-	* @param String $registration the registration of the aircraft
601
-	* @param String $name type of the aircraft
602
-	* @return Array the aircraft thumbnail, orignal url and copyright
603
-	*
604
-	*/
598
+	 * Gets the aircraft image from custom url
599
+	 *
600
+	 * @param String $registration the registration of the aircraft
601
+	 * @param String $name type of the aircraft
602
+	 * @return Array the aircraft thumbnail, orignal url and copyright
603
+	 *
604
+	 */
605 605
 	public function fromCustomSource($type,$registration,$name='') {
606 606
 		global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug;
607 607
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
Please login to merge, or discard this patch.
Spacing   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -28,22 +28,22 @@  discard block
 block discarded – undo
28 28
 	* @return Array the images list
29 29
 	*
30 30
 	*/
31
-	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
31
+	public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
32 32
 	{
33
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
34
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
35
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
33
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
34
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
35
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
36 36
 		$reg = $registration;
37 37
 		if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao;
38 38
 		$reg = trim($reg);
39
-		$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 
39
+		$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 
40 40
 			FROM spotter_image 
41 41
 			WHERE spotter_image.registration = :registration LIMIT 1";
42 42
 		$sth = $this->db->prepare($query);
43 43
 		$sth->execute(array(':registration' => $reg));
44 44
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
45 45
 		if (!empty($result)) return $result;
46
-		elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
46
+		elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) return $this->getSpotterImage('', $aircraft_icao, $airline_icao);
47 47
 		else return array();
48 48
 	}
49 49
 
@@ -53,34 +53,34 @@  discard block
 block discarded – undo
53 53
 	* @return Array the images list
54 54
 	*
55 55
 	*/
56
-	public function getMarineImage($mmsi,$imo = '',$name = '',$type_name = '')
56
+	public function getMarineImage($mmsi, $imo = '', $name = '', $type_name = '')
57 57
 	{
58 58
 		global $globalMarineImagePics;
59
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
60
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
61
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
62
-		$type_name = str_replace('&#39;',"'",filter_var($type_name,FILTER_SANITIZE_STRING));
59
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
60
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
61
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
62
+		$type_name = str_replace('&#39;', "'", filter_var($type_name, FILTER_SANITIZE_STRING));
63 63
 		if (isset($globalMarineImagePics) && !empty($globalMarineImagePics)) {
64 64
 			if ($type_name != '' && isset($globalMarineImagePics['type'][$type_name])) {
65 65
 				if (!isset($globalMarineImagePics['type'][$type_name]['image_thumbnail'])) {
66 66
 					$globalMarineImagePics['type'][$type_name]['image_thumbnail'] = $globalMarineImagePics['type'][$type_name]['image'];
67 67
 				}
68
-				return array($globalMarineImagePics['type'][$type_name]+array('image_thumbnail' => '','image' => '', 'image_copyright' => '','image_source' => '','image_source_website' => ''));
68
+				return array($globalMarineImagePics['type'][$type_name] + array('image_thumbnail' => '', 'image' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
69 69
 			}
70 70
 		}
71 71
 		$name = trim($name);
72 72
 		if ($mmsi == '' && $imo == '' && $name == '') return array();
73
-		$query  = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name 
73
+		$query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name 
74 74
 			FROM marine_image 
75 75
 			WHERE marine_image.mmsi = :mmsi";
76 76
 		$query_data = array(':mmsi' => $mmsi);
77 77
 		if ($imo != '') {
78 78
 			$query .= " AND marine_image.imo = :imo";
79
-			$query_data = array_merge($query_data,array(':imo' => $imo));
79
+			$query_data = array_merge($query_data, array(':imo' => $imo));
80 80
 		}
81 81
 		if ($name != '') {
82 82
 			$query .= " AND marine_image.name = :name";
83
-			$query_data = array_merge($query_data,array(':name' => $name));
83
+			$query_data = array_merge($query_data, array(':name' => $name));
84 84
 		}
85 85
 		$query .= " LIMIT 1";
86 86
 		$sth = $this->db->prepare($query);
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
 		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
102 102
 		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
103 103
 		if ($copyright != '') {
104
-			$copyright = str_replace('Copyright ','',$copyright);
105
-			$copyright = str_replace('© ','',$copyright);
106
-			$copyright = str_replace('(c) ','',$copyright);
104
+			$copyright = str_replace('Copyright ', '', $copyright);
105
+			$copyright = str_replace('© ', '', $copyright);
106
+			$copyright = str_replace('(c) ', '', $copyright);
107 107
 		}
108 108
 		return $copyright;
109 109
 	}
@@ -114,25 +114,25 @@  discard block
 block discarded – undo
114 114
 	* @return String either success or error
115 115
 	*
116 116
 	*/
117
-	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
117
+	public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
118 118
 	{
119
-		global $globalDebug,$globalAircraftImageFetch, $globalOffline;
119
+		global $globalDebug, $globalAircraftImageFetch, $globalOffline;
120 120
 		if ((isset($globalAircraftImageFetch) && $globalAircraftImageFetch === FALSE) || (isset($globalOffline) && $globalOffline === TRUE)) return '';
121
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
121
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
122 122
 		$registration = trim($registration);
123 123
 		//getting the aircraft image
124 124
 		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
125 125
 		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
126 126
 		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
127
-		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
127
+		$image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao);
128 128
 		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
129 129
 		if ($image_url['original'] != '') {
130 130
 			if ($globalDebug) echo 'Found !'."\n";
131
-			$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)";
131
+			$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)";
132 132
 			try {
133 133
 				$sth = $this->db->prepare($query);
134
-				$sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website']));
135
-			} catch(PDOException $e) {
134
+				$sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website']));
135
+			} catch (PDOException $e) {
136 136
 				echo $e->getMessage()."\n";
137 137
 				return "error";
138 138
 			}
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 	* @return String either success or error
147 147
 	*
148 148
 	*/
149
-	public function addMarineImage($mmsi,$imo = '',$name = '')
149
+	public function addMarineImage($mmsi, $imo = '', $name = '')
150 150
 	{
151
-		global $globalDebug,$globalMarineImageFetch, $globalOffline;
151
+		global $globalDebug, $globalMarineImageFetch, $globalOffline;
152 152
 		if ((isset($globalMarineImageFetch) && !$globalMarineImageFetch) || (isset($globalOffline) && $globalOffline === TRUE)) return '';
153
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
154
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
155
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
153
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
154
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
155
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
156 156
 		$name = trim($name);
157 157
 		$Marine = new Marine($this->db);
158 158
 		if ($imo == '' || $name == '') {
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
 
167 167
 		//getting the aircraft image
168 168
 		if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...';
169
-		$image_url = $this->findMarineImage($mmsi,$imo,$name);
169
+		$image_url = $this->findMarineImage($mmsi, $imo, $name);
170 170
 		if ($image_url['original'] != '') {
171 171
 			if ($globalDebug) echo 'Found !'."\n";
172
-			$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)";
172
+			$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)";
173 173
 			try {
174 174
 				$sth = $this->db->prepare($query);
175
-				$sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':name' => $name,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website']));
176
-			} catch(PDOException $e) {
175
+				$sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':name' => $name, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website']));
176
+			} catch (PDOException $e) {
177 177
 				echo $e->getMessage()."\n";
178 178
 				return "error";
179 179
 			}
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
194 194
 		$Spotter = new Spotter($this->db);
195 195
 		if (!isset($globalIVAO)) $globalIVAO = FALSE;
196
-		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
196
+		$aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING);
197 197
 		if ($aircraft_registration != '' && $aircraft_registration != 'NA' && (!isset($globalVA) || $globalVA !== TRUE)) {
198
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
198
+			if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
199 199
 			$aircraft_registration = urlencode(trim($aircraft_registration));
200 200
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
201 201
 			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
@@ -209,25 +209,25 @@  discard block
 block discarded – undo
209 209
 			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
210 210
 			else $aircraft_name = '';
211 211
 			$aircraft_registration = $aircraft_icao;
212
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
212
+		} else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
213 213
 		unset($Spotter);
214
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
214
+		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
215 215
 		foreach ($globalAircraftImageSources as $source) {
216 216
 			$source = strtolower($source);
217
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
218
-			if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
219
-			if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
220
-			if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
221
-			if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
222
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
223
-			if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
224
-			if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
225
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
226
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
217
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft', $aircraft_icao, $airline_icao);
218
+			if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft', $aircraft_registration, $aircraft_name);
219
+			if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft', $aircraft_registration, $aircraft_name);
220
+			if ($source == 'bing') $images_array = $this->fromBing('aircraft', $aircraft_registration, $aircraft_name);
221
+			if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft', $aircraft_registration, $aircraft_name);
222
+			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft', $aircraft_registration, $aircraft_name);
223
+			if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft', $aircraft_registration, $aircraft_name);
224
+			if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft', $aircraft_registration, $aircraft_name);
225
+			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft', $aircraft_registration, $aircraft_name);
226
+			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft', $aircraft_registration, $aircraft_name);
227 227
 			if (isset($images_array) && $images_array['original'] != '') return $images_array;
228 228
 		}
229 229
 		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
230
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
230
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
231 231
 	}
232 232
 
233 233
 	/**
@@ -239,14 +239,14 @@  discard block
 block discarded – undo
239 239
 	* @return Array the aircraft thumbnail, orignal url and copyright
240 240
 	*
241 241
 	*/
242
-	public function findMarineImage($mmsi,$imo = '',$name = '')
242
+	public function findMarineImage($mmsi, $imo = '', $name = '')
243 243
 	{
244 244
 		global $globalMarineImageSources;
245
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
245
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
246 246
 		//$imo = filter_var($imo,FILTER_SANITIZE_STRING);
247
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
247
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
248 248
 		$name = trim($name);
249
-		if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
249
+		if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
250 250
 		/*
251 251
 		$Marine = new Marine($this->db);
252 252
 		if ($imo == '' || $name == '') {
@@ -258,17 +258,17 @@  discard block
 block discarded – undo
258 258
 		}
259 259
 		unset($Marine);
260 260
 		*/
261
-		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
261
+		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing');
262 262
 		foreach ($globalMarineImageSources as $source) {
263 263
 			$source = strtolower($source);
264
-			if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name);
265
-			if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name);
266
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name);
267
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name);
268
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name);
264
+			if ($source == 'flickr') $images_array = $this->fromFlickr('marine', $mmsi, $name);
265
+			if ($source == 'bing') $images_array = $this->fromBing('marine', $mmsi, $name);
266
+			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine', $mmsi, $name);
267
+			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine', $mmsi, $name);
268
+			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine', $mmsi, $name);
269 269
 			if (isset($images_array) && $images_array['original'] != '') return $images_array;
270 270
 		}
271
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
271
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
272 272
 	}
273 273
 
274 274
 	/**
@@ -279,25 +279,25 @@  discard block
 block discarded – undo
279 279
 	* @return Array the aircraft thumbnail, orignal url and copyright
280 280
 	*
281 281
 	*/
282
-	public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') {
282
+	public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') {
283 283
 		$Common = new Common();
284 284
 		// If aircraft registration is only number, also check with aircraft model
285
-		if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') {
286
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
285
+		if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') {
286
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
287 287
 		} else {
288 288
 			//$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss';
289
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
289
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
290 290
 		}
291 291
 		$data = $Common->getData($url);
292 292
 		if (substr($data, 0, 5) != "<?xml") return false;
293 293
 		if ($xml = simplexml_load_string($data)) {
294 294
 			if (isset($xml->channel->item)) {
295 295
 				$image_url = array();
296
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
296
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
297 297
 				$image_url['thumbnail'] = $thumbnail_url;
298
-				$image_url['original'] = str_replace('thumbnail','original',$thumbnail_url);
299
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
300
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
298
+				$image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url);
299
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
300
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
301 301
 				$image_url['source'] = 'planespotters';
302 302
 				return $image_url;
303 303
 			}
@@ -313,31 +313,31 @@  discard block
 block discarded – undo
313 313
 	* @return Array the aircraft thumbnail, orignal url and copyright
314 314
 	*
315 315
 	*/
316
-	public function fromDeviantart($type,$registration, $name='') {
316
+	public function fromDeviantart($type, $registration, $name = '') {
317 317
 		$Common = new Common();
318 318
 		if ($type == 'aircraft') {
319 319
 			// If aircraft registration is only number, also check with aircraft model
320
-			if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') {
321
-				$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name);
320
+			if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') {
321
+				$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name);
322 322
 			} else {
323
-				$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration;
323
+				$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration;
324 324
 			}
325 325
 		} elseif ($type == 'marine') {
326
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"';
326
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"';
327 327
 		} else {
328
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"';
328
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"';
329 329
 		}
330 330
 		$data = $Common->getData($url);
331 331
 		if (substr($data, 0, 5) != "<?xml") return false;
332 332
 		if ($xml = simplexml_load_string($data)) {
333 333
 			if (isset($xml->channel->item->link)) {
334 334
 				$image_url = array();
335
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
335
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
336 336
 				$image_url['thumbnail'] = $thumbnail_url;
337
-				$original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
337
+				$original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
338 338
 				$image_url['original'] = $original_url;
339
-				$image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
340
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
339
+				$image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
340
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
341 341
 				$image_url['source'] = 'deviantart';
342 342
 				return $image_url;
343 343
 			}
@@ -353,32 +353,32 @@  discard block
 block discarded – undo
353 353
 	* @return Array the aircraft thumbnail, orignal url and copyright
354 354
 	*
355 355
 	*/
356
-	public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') {
356
+	public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') {
357 357
 		$Common = new Common();
358
-		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
358
+		$url = 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
359 359
 		$data = $Common->getData($url);
360 360
 		$dom = new DOMDocument();
361 361
 		@$dom->loadHTML($data);
362 362
 		$all_pics = array();
363
-		foreach($dom->getElementsByTagName('img') as $image) {
363
+		foreach ($dom->getElementsByTagName('img') as $image) {
364 364
 			if ($image->getAttribute('itemprop') == "http://schema.org/image") {
365 365
 				$all_pics[] = $image->getAttribute('src');
366 366
 			}
367 367
 		}
368 368
 		$all_authors = array();
369
-		foreach($dom->getElementsByTagName('meta') as $author) {
369
+		foreach ($dom->getElementsByTagName('meta') as $author) {
370 370
 			if ($author->getAttribute('itemprop') == "http://schema.org/author") {
371 371
 				$all_authors[] = $author->getAttribute('content');
372 372
 			}
373 373
 		}
374 374
 		$all_ref = array();
375
-		foreach($dom->getElementsByTagName('a') as $link) {
375
+		foreach ($dom->getElementsByTagName('a') as $link) {
376 376
 			$all_ref[] = $link->getAttribute('href');
377 377
 		}
378 378
 		if (isset($all_pics[0])) {
379 379
 			$image_url = array();
380 380
 			$image_url['thumbnail'] = $all_pics[0];
381
-			$image_url['original'] = str_replace('_tb','',$all_pics[0]);
381
+			$image_url['original'] = str_replace('_tb', '', $all_pics[0]);
382 382
 			$image_url['copyright'] = $all_authors[0];
383 383
 			$image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8];
384 384
 			$image_url['source'] = 'JetPhotos';
@@ -395,24 +395,24 @@  discard block
 block discarded – undo
395 395
 	* @return Array the aircraft thumbnail, orignal url and copyright
396 396
 	*
397 397
 	*/
398
-	public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') {
398
+	public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') {
399 399
 		$Common = new Common();
400
-		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
400
+		$url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
401 401
 		$data = $Common->getData($url);
402 402
 		$dom = new DOMDocument();
403 403
 		@$dom->loadHTML($data);
404 404
 		$all_pics = array();
405
-		foreach($dom->getElementsByTagName('img') as $image) {
405
+		foreach ($dom->getElementsByTagName('img') as $image) {
406 406
 			$all_pics[] = $image->getAttribute('src');
407 407
 		}
408 408
 		$all_links = array();
409
-		foreach($dom->getElementsByTagName('a') as $link) {
410
-			$all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href'));
409
+		foreach ($dom->getElementsByTagName('a') as $link) {
410
+			$all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href'));
411 411
 		}
412
-		if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) {
412
+		if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) {
413 413
 			$image_url = array();
414 414
 			$image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1];
415
-			$image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]);
415
+			$image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]);
416 416
 			$image_url['copyright'] = $all_links[6]['text'];
417 417
 			$image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href'];
418 418
 			$image_url['source'] = 'PlanePictures';
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 	* @return Array the aircraft thumbnail, orignal url and copyright
430 430
 	*
431 431
 	*/
432
-	public function fromFlickr($type,$registration,$name='') {
432
+	public function fromFlickr($type, $registration, $name = '') {
433 433
 		$Common = new Common();
434 434
 		if ($type == 'aircraft') {
435 435
 			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);
@@ -442,12 +442,12 @@  discard block
 block discarded – undo
442 442
 		if (substr($data, 0, 5) != "<?xml") return false;
443 443
 		if ($xml = simplexml_load_string($data)) {
444 444
 			if (isset($xml->channel->item)) {
445
-				$original_url = trim((string)$xml->channel->item->enclosure->attributes()->url);
445
+				$original_url = trim((string) $xml->channel->item->enclosure->attributes()->url);
446 446
 				$image_url = array();
447 447
 				$image_url['thumbnail'] = $original_url;
448 448
 				$image_url['original'] = $original_url;
449
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
450
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
449
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
450
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
451 451
 				$image_url['source'] = 'flickr';
452 452
 				return $image_url;
453 453
 			}
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 		return false;
456 456
 	}
457 457
 
458
-	public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) {
458
+	public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) {
459 459
 		$Common = new Common();
460 460
 		//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
461 461
 		if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) {
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 	* @return Array the aircraft thumbnail, orignal url and copyright
480 480
 	*
481 481
 	*/
482
-	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
482
+	public function fromBing($type, $aircraft_registration, $aircraft_name = '') {
483 483
 		global $globalImageBingKey;
484 484
 		$Common = new Common();
485 485
 		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
 			if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27';
491 491
 			else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27';
492 492
 		}
493
-		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
494
-		$data = $Common->getData($url,'get','',$headers);
493
+		$headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey));
494
+		$data = $Common->getData($url, 'get', '', $headers);
495 495
 		$result = json_decode($data);
496 496
 		if (isset($result->d->results[0]->MediaUrl)) {
497 497
 			$image_url = array();
@@ -516,14 +516,14 @@  discard block
 block discarded – undo
516 516
 	* @return Array the aircraft thumbnail, orignal url and copyright
517 517
 	*
518 518
 	*/
519
-	public function fromAirportData($type,$aircraft_registration,$aircraft_name='') {
519
+	public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') {
520 520
 		$Common = new Common();
521 521
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
522 522
 		$data = $Common->getData($url);
523 523
 		$result = json_decode($data);
524 524
 		if (isset($result->count) && $result->count > 0) {
525 525
 			$image_url = array();
526
-			$image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image);
526
+			$image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image);
527 527
 			$image_url['source_website'] = $result->data[0]->link;
528 528
 			$image_url['thumbnail'] = $result->data[0]->image;
529 529
 			$image_url['copyright'] = $result->data[0]->photographer;
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 	* @return Array the aircraft thumbnail, orignal url and copyright
542 542
 	*
543 543
 	*/
544
-	public function fromWikimedia($type,$registration,$name='') {
544
+	public function fromWikimedia($type, $registration, $name = '') {
545 545
 		$Common = new Common();
546 546
 		if ($type == 'aircraft') {
547 547
 			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);
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 		$result = json_decode($data);
555 555
 		if (isset($result->query->search[0]->title)) {
556 556
 			$fileo = $result->query->search[0]->title;
557
-			if (substr($fileo,-3) == 'pdf') return false;
557
+			if (substr($fileo, -3) == 'pdf') return false;
558 558
 			$file = urlencode($fileo);
559 559
 			$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;
560 560
 			$data2 = $Common->getData($url2);
@@ -579,11 +579,11 @@  discard block
 block discarded – undo
579 579
 				if (isset($result2->query->pages)) {
580 580
 					foreach ($result2->query->pages as $page) {
581 581
 						if (isset($page->imageinfo[0]->extmetadata->Artist)) {
582
-							$image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
582
+							$image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
583 583
 							if (isset($page->imageinfo[0]->extmetadata->License->value)) {
584 584
 								$image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')';
585 585
 							}
586
-							$image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright']));
586
+							$image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright']));
587 587
 							return $image_url;
588 588
 						}
589 589
 					}
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 	* @return Array the aircraft thumbnail, orignal url and copyright
603 603
 	*
604 604
 	*/
605
-	public function fromCustomSource($type,$registration,$name='') {
605
+	public function fromCustomSource($type, $registration, $name = '') {
606 606
 		global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug;
607 607
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
608 608
 		if (!empty($globalAircraftImageCustomSources) && $type == 'aircraft') {
@@ -619,15 +619,15 @@  discard block
 block discarded – undo
619 619
 					print_r($source);
620 620
 					print_r($customsources);
621 621
 				}
622
-				$url = str_replace('{registration}',$registration,$source['original']);
623
-				$url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']);
622
+				$url = str_replace('{registration}', $registration, $source['original']);
623
+				$url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']);
624 624
 				if ($Common->urlexist($url)) {
625 625
 					$image_url = array();
626 626
 					$image_url['thumbnail'] = $url_thumbnail;
627 627
 					$image_url['original'] = $url;
628 628
 					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
629 629
 					else $exifCopyright = '';
630
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
630
+					if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright;
631 631
 					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
632 632
 					else $image_url['copyright'] = $source['source_website'];
633 633
 					$image_url['source_website'] = $source['source_website'];
@@ -651,19 +651,19 @@  discard block
 block discarded – undo
651 651
 					print_r($source);
652 652
 					print_r($customsources);
653 653
 				}
654
-				$url = str_replace('{registration}',$registration,$source['original']);
655
-				$url = str_replace('{mmsi}',$registration,$url);
656
-				$url = str_replace('{name}',$name,$url);
657
-				$url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']);
658
-				$url_thumbnail = str_replace('{mmsi}',$registration,$url_thumbnail);
659
-				$url_thumbnail = str_replace('{name}',$name,$url_thumbnail);
654
+				$url = str_replace('{registration}', $registration, $source['original']);
655
+				$url = str_replace('{mmsi}', $registration, $url);
656
+				$url = str_replace('{name}', $name, $url);
657
+				$url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']);
658
+				$url_thumbnail = str_replace('{mmsi}', $registration, $url_thumbnail);
659
+				$url_thumbnail = str_replace('{name}', $name, $url_thumbnail);
660 660
 				if ($Common->urlexist($url)) {
661 661
 					$image_url = array();
662 662
 					$image_url['thumbnail'] = $url_thumbnail;
663 663
 					$image_url['original'] = $url;
664 664
 					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
665 665
 					else $exifCopyright = '';
666
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
666
+					if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright;
667 667
 					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
668 668
 					else $image_url['copyright'] = $source['source_website'];
669 669
 					$image_url['source_website'] = $source['source_website'];
Please login to merge, or discard this patch.
Braces   +223 added lines, -82 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@  discard block
 block discarded – undo
19 19
 	public function __construct($dbc = null) {
20 20
 		$Connection = new Connection($dbc);
21 21
 		$this->db = $Connection->db();
22
-		if ($this->db === null) die('Error: No DB connection. (Image)');
22
+		if ($this->db === null) {
23
+			die('Error: No DB connection. (Image)');
24
+		}
23 25
 	}
24 26
 
25 27
 	/**
@@ -34,7 +36,9 @@  discard block
 block discarded – undo
34 36
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
35 37
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
36 38
 		$reg = $registration;
37
-		if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao;
39
+		if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') {
40
+			$reg = $aircraft_icao.$airline_icao;
41
+		}
38 42
 		$reg = trim($reg);
39 43
 		$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 
40 44
 			FROM spotter_image 
@@ -42,9 +46,13 @@  discard block
 block discarded – undo
42 46
 		$sth = $this->db->prepare($query);
43 47
 		$sth->execute(array(':registration' => $reg));
44 48
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
45
-		if (!empty($result)) return $result;
46
-		elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
47
-		else return array();
49
+		if (!empty($result)) {
50
+			return $result;
51
+		} elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) {
52
+			return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
53
+		} else {
54
+			return array();
55
+		}
48 56
 	}
49 57
 
50 58
 	/**
@@ -69,7 +77,9 @@  discard block
 block discarded – undo
69 77
 			}
70 78
 		}
71 79
 		$name = trim($name);
72
-		if ($mmsi == '' && $imo == '' && $name == '') return array();
80
+		if ($mmsi == '' && $imo == '' && $name == '') {
81
+			return array();
82
+		}
73 83
 		$query  = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name 
74 84
 			FROM marine_image 
75 85
 			WHERE marine_image.mmsi = :mmsi";
@@ -98,8 +108,11 @@  discard block
 block discarded – undo
98 108
 	public function getExifCopyright($url) {
99 109
 		$exif = exif_read_data($url);
100 110
 		$copyright = '';
101
-		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
102
-		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
111
+		if (isset($exif['COMPUTED']['copyright'])) {
112
+			$copyright = $exif['COMPUTED']['copyright'];
113
+		} elseif (isset($exif['copyright'])) {
114
+			$copyright = $exif['copyright'];
115
+		}
103 116
 		if ($copyright != '') {
104 117
 			$copyright = str_replace('Copyright ','',$copyright);
105 118
 			$copyright = str_replace('© ','',$copyright);
@@ -117,17 +130,27 @@  discard block
 block discarded – undo
117 130
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
118 131
 	{
119 132
 		global $globalDebug,$globalAircraftImageFetch, $globalOffline;
120
-		if ((isset($globalAircraftImageFetch) && $globalAircraftImageFetch === FALSE) || (isset($globalOffline) && $globalOffline === TRUE)) return '';
133
+		if ((isset($globalAircraftImageFetch) && $globalAircraftImageFetch === FALSE) || (isset($globalOffline) && $globalOffline === TRUE)) {
134
+			return '';
135
+		}
121 136
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
122 137
 		$registration = trim($registration);
123 138
 		//getting the aircraft image
124
-		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
125
-		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
126
-		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
139
+		if ($globalDebug && $registration != '') {
140
+			echo 'Try to find an aircraft image for '.$registration.'...';
141
+		} elseif ($globalDebug && $aircraft_icao != '') {
142
+			echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
143
+		} elseif ($globalDebug && $airline_icao != '') {
144
+			echo 'Try to find an aircraft image for '.$airline_icao.'...';
145
+		}
127 146
 		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
128
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
147
+		if ($registration == '' && $aircraft_icao != '') {
148
+			$registration = $aircraft_icao.$airline_icao;
149
+		}
129 150
 		if ($image_url['original'] != '') {
130
-			if ($globalDebug) echo 'Found !'."\n";
151
+			if ($globalDebug) {
152
+				echo 'Found !'."\n";
153
+			}
131 154
 			$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)";
132 155
 			try {
133 156
 				$sth = $this->db->prepare($query);
@@ -136,7 +159,9 @@  discard block
 block discarded – undo
136 159
 				echo $e->getMessage()."\n";
137 160
 				return "error";
138 161
 			}
139
-		} elseif ($globalDebug) echo "Not found :'(\n";
162
+		} elseif ($globalDebug) {
163
+			echo "Not found :'(\n";
164
+		}
140 165
 		return "success";
141 166
 	}
142 167
 
@@ -149,7 +174,9 @@  discard block
 block discarded – undo
149 174
 	public function addMarineImage($mmsi,$imo = '',$name = '')
150 175
 	{
151 176
 		global $globalDebug,$globalMarineImageFetch, $globalOffline;
152
-		if ((isset($globalMarineImageFetch) && !$globalMarineImageFetch) || (isset($globalOffline) && $globalOffline === TRUE)) return '';
177
+		if ((isset($globalMarineImageFetch) && !$globalMarineImageFetch) || (isset($globalOffline) && $globalOffline === TRUE)) {
178
+			return '';
179
+		}
153 180
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
154 181
 		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
155 182
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
@@ -159,16 +186,22 @@  discard block
 block discarded – undo
159 186
 			$identity = $Marine->getIdentity($mmsi);
160 187
 			if (isset($identity[0]['mmsi'])) {
161 188
 				$imo = $identity[0]['imo'];
162
-				if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name'];
189
+				if ($identity[0]['ship_name'] != '') {
190
+					$name = $identity[0]['ship_name'];
191
+				}
163 192
 			}
164 193
 		}
165 194
 		unset($Marine);
166 195
 
167 196
 		//getting the aircraft image
168
-		if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...';
197
+		if ($globalDebug && $name != '') {
198
+			echo 'Try to find an vessel image for '.$name.'...';
199
+		}
169 200
 		$image_url = $this->findMarineImage($mmsi,$imo,$name);
170 201
 		if ($image_url['original'] != '') {
171
-			if ($globalDebug) echo 'Found !'."\n";
202
+			if ($globalDebug) {
203
+				echo 'Found !'."\n";
204
+			}
172 205
 			$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)";
173 206
 			try {
174 207
 				$sth = $this->db->prepare($query);
@@ -177,7 +210,9 @@  discard block
 block discarded – undo
177 210
 				echo $e->getMessage()."\n";
178 211
 				return "error";
179 212
 			}
180
-		} elseif ($globalDebug) echo "Not found :'(\n";
213
+		} elseif ($globalDebug) {
214
+			echo "Not found :'(\n";
215
+		}
181 216
 		return "success";
182 217
 	}
183 218
 
@@ -192,41 +227,85 @@  discard block
 block discarded – undo
192 227
 	{
193 228
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
194 229
 		$Spotter = new Spotter($this->db);
195
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
230
+		if (!isset($globalIVAO)) {
231
+			$globalIVAO = FALSE;
232
+		}
196 233
 		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
197 234
 		if ($aircraft_registration != '' && $aircraft_registration != 'NA' && (!isset($globalVA) || $globalVA !== TRUE)) {
198
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
235
+			if (strpos($aircraft_registration,'/') !== false) {
236
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
237
+			}
199 238
 			$aircraft_registration = urlencode(trim($aircraft_registration));
200 239
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
201
-			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
202
-			else $aircraft_name = '';
203
-			if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao'];
204
-			else $aircraft_icao = '';
205
-			if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao'];
206
-			else $airline_icao = '';
240
+			if (isset($aircraft_info[0]['aircraft_name'])) {
241
+				$aircraft_name = $aircraft_info[0]['aircraft_name'];
242
+			} else {
243
+				$aircraft_name = '';
244
+			}
245
+			if (isset($aircraft_info[0]['aircraft_icao'])) {
246
+				$aircraft_name = $aircraft_info[0]['aircraft_icao'];
247
+			} else {
248
+				$aircraft_icao = '';
249
+			}
250
+			if (isset($aircraft_info[0]['airline_icao'])) {
251
+				$airline_icao = $aircraft_info[0]['airline_icao'];
252
+			} else {
253
+				$airline_icao = '';
254
+			}
207 255
 		} elseif ($aircraft_icao != '') {
208 256
 			$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao);
209
-			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
210
-			else $aircraft_name = '';
257
+			if (isset($aircraft_info[0]['type'])) {
258
+				$aircraft_name = $aircraft_info[0]['type'];
259
+			} else {
260
+				$aircraft_name = '';
261
+			}
211 262
 			$aircraft_registration = $aircraft_icao;
212
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
263
+		} else {
264
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
265
+		}
213 266
 		unset($Spotter);
214
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
267
+		if (!isset($globalAircraftImageSources)) {
268
+			$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
269
+		}
215 270
 		foreach ($globalAircraftImageSources as $source) {
216 271
 			$source = strtolower($source);
217
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
218
-			if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
219
-			if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
220
-			if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
221
-			if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
222
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
223
-			if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
224
-			if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
225
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
226
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
227
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
228
-		}
229
-		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
272
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') {
273
+				$images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
274
+			}
275
+			if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) {
276
+				$images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
277
+			}
278
+			if ($source == 'flickr' && extension_loaded('simplexml')) {
279
+				$images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
280
+			}
281
+			if ($source == 'bing') {
282
+				$images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
283
+			}
284
+			if ($source == 'deviantart' && extension_loaded('simplexml')) {
285
+				$images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
286
+			}
287
+			if ($source == 'wikimedia') {
288
+				$images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
289
+			}
290
+			if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) {
291
+				$images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
292
+			}
293
+			if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) {
294
+				$images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
295
+			}
296
+			if ($source == 'airportdata' && !$globalIVAO) {
297
+				$images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
298
+			}
299
+			if ($source == 'customsources') {
300
+				$images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
301
+			}
302
+			if (isset($images_array) && $images_array['original'] != '') {
303
+				return $images_array;
304
+			}
305
+		}
306
+		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) {
307
+			return $this->findAircraftImage($aircraft_icao);
308
+		}
230 309
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
231 310
 	}
232 311
 
@@ -246,7 +325,9 @@  discard block
 block discarded – undo
246 325
 		//$imo = filter_var($imo,FILTER_SANITIZE_STRING);
247 326
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
248 327
 		$name = trim($name);
249
-		if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
328
+		if (strlen($name) < 4) {
329
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
330
+		}
250 331
 		/*
251 332
 		$Marine = new Marine($this->db);
252 333
 		if ($imo == '' || $name == '') {
@@ -258,15 +339,29 @@  discard block
 block discarded – undo
258 339
 		}
259 340
 		unset($Marine);
260 341
 		*/
261
-		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
342
+		if (!isset($globalMarineImageSources)) {
343
+			$globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
344
+		}
262 345
 		foreach ($globalMarineImageSources as $source) {
263 346
 			$source = strtolower($source);
264
-			if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name);
265
-			if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name);
266
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name);
267
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name);
268
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name);
269
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
347
+			if ($source == 'flickr') {
348
+				$images_array = $this->fromFlickr('marine',$mmsi,$name);
349
+			}
350
+			if ($source == 'bing') {
351
+				$images_array = $this->fromBing('marine',$mmsi,$name);
352
+			}
353
+			if ($source == 'deviantart') {
354
+				$images_array = $this->fromDeviantart('marine',$mmsi,$name);
355
+			}
356
+			if ($source == 'wikimedia') {
357
+				$images_array = $this->fromWikimedia('marine',$mmsi,$name);
358
+			}
359
+			if ($source == 'customsources') {
360
+				$images_array = $this->fromCustomSource('marine',$mmsi,$name);
361
+			}
362
+			if (isset($images_array) && $images_array['original'] != '') {
363
+				return $images_array;
364
+			}
270 365
 		}
271 366
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
272 367
 	}
@@ -289,7 +384,9 @@  discard block
 block discarded – undo
289 384
 			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
290 385
 		}
291 386
 		$data = $Common->getData($url);
292
-		if (substr($data, 0, 5) != "<?xml") return false;
387
+		if (substr($data, 0, 5) != "<?xml") {
388
+			return false;
389
+		}
293 390
 		if ($xml = simplexml_load_string($data)) {
294 391
 			if (isset($xml->channel->item)) {
295 392
 				$image_url = array();
@@ -328,7 +425,9 @@  discard block
 block discarded – undo
328 425
 			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"';
329 426
 		}
330 427
 		$data = $Common->getData($url);
331
-		if (substr($data, 0, 5) != "<?xml") return false;
428
+		if (substr($data, 0, 5) != "<?xml") {
429
+			return false;
430
+		}
332 431
 		if ($xml = simplexml_load_string($data)) {
333 432
 			if (isset($xml->channel->item->link)) {
334 433
 				$image_url = array();
@@ -432,14 +531,22 @@  discard block
 block discarded – undo
432 531
 	public function fromFlickr($type,$registration,$name='') {
433 532
 		$Common = new Common();
434 533
 		if ($type == 'aircraft') {
435
-			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);
436
-			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';
534
+			if ($name != '') {
535
+				$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);
536
+			} else {
537
+				$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';
538
+			}
437 539
 		} elseif ($type == 'marine') {
438
-			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=ship,'.urlencode($name);
439
-			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.',ship';
540
+			if ($name != '') {
541
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name);
542
+			} else {
543
+				$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.',ship';
544
+			}
440 545
 		}
441 546
 		$data = $Common->getData($url);
442
-		if (substr($data, 0, 5) != "<?xml") return false;
547
+		if (substr($data, 0, 5) != "<?xml") {
548
+			return false;
549
+		}
443 550
 		if ($xml = simplexml_load_string($data)) {
444 551
 			if (isset($xml->channel->item)) {
445 552
 				$original_url = trim((string)$xml->channel->item->enclosure->attributes()->url);
@@ -482,13 +589,21 @@  discard block
 block discarded – undo
482 589
 	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
483 590
 		global $globalImageBingKey;
484 591
 		$Common = new Common();
485
-		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
592
+		if (!isset($globalImageBingKey) || $globalImageBingKey == '') {
593
+			return false;
594
+		}
486 595
 		if ($type == 'aircraft') {
487
-			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';
488
-			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';
596
+			if ($aircraft_name != '') {
597
+				$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';
598
+			} else {
599
+				$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';
600
+			}
489 601
 		} elseif ($type == 'marine') {
490
-			if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27';
491
-			else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27';
602
+			if ($aircraft_name != '') {
603
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27';
604
+			} else {
605
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27';
606
+			}
492 607
 		}
493 608
 		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
494 609
 		$data = $Common->getData($url,'get','',$headers);
@@ -544,17 +659,25 @@  discard block
 block discarded – undo
544 659
 	public function fromWikimedia($type,$registration,$name='') {
545 660
 		$Common = new Common();
546 661
 		if ($type == 'aircraft') {
547
-			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);
548
-			else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
662
+			if ($name != '') {
663
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
664
+			} else {
665
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
666
+			}
549 667
 		} elseif ($type == 'marine') {
550
-			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"';
551
-			else return false;
668
+			if ($name != '') {
669
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"';
670
+			} else {
671
+				return false;
672
+			}
552 673
 		}
553 674
 		$data = $Common->getData($url);
554 675
 		$result = json_decode($data);
555 676
 		if (isset($result->query->search[0]->title)) {
556 677
 			$fileo = $result->query->search[0]->title;
557
-			if (substr($fileo,-3) == 'pdf') return false;
678
+			if (substr($fileo,-3) == 'pdf') {
679
+				return false;
680
+			}
558 681
 			$file = urlencode($fileo);
559 682
 			$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;
560 683
 			$data2 = $Common->getData($url2);
@@ -625,18 +748,27 @@  discard block
 block discarded – undo
625 748
 					$image_url = array();
626 749
 					$image_url['thumbnail'] = $url_thumbnail;
627 750
 					$image_url['original'] = $url;
628
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
629
-					else $exifCopyright = '';
630
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
631
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
632
-					else $image_url['copyright'] = $source['source_website'];
751
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
752
+						$exifCopyright = $this->getExifCopyright($url);
753
+					} else {
754
+						$exifCopyright = '';
755
+					}
756
+					if ($exifCopyright  != '') {
757
+						$image_url['copyright'] = $exifCopyright;
758
+					} elseif (isset($source['copyright'])) {
759
+						$image_url['copyright'] = $source['copyright'];
760
+					} else {
761
+						$image_url['copyright'] = $source['source_website'];
762
+					}
633 763
 					$image_url['source_website'] = $source['source_website'];
634 764
 					$image_url['source'] = $source['source'];
635 765
 					return $image_url;
636 766
 				}
637 767
 			}
638 768
 			return false;
639
-		} else return false;
769
+		} else {
770
+			return false;
771
+		}
640 772
 		if (!empty($globalMarineImageCustomSources) && $type == 'marine') {
641 773
 			$customsources = array();
642 774
 			if (!isset($globalMarineImageCustomSources[0])) {
@@ -661,18 +793,27 @@  discard block
 block discarded – undo
661 793
 					$image_url = array();
662 794
 					$image_url['thumbnail'] = $url_thumbnail;
663 795
 					$image_url['original'] = $url;
664
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
665
-					else $exifCopyright = '';
666
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
667
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
668
-					else $image_url['copyright'] = $source['source_website'];
796
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
797
+						$exifCopyright = $this->getExifCopyright($url);
798
+					} else {
799
+						$exifCopyright = '';
800
+					}
801
+					if ($exifCopyright  != '') {
802
+						$image_url['copyright'] = $exifCopyright;
803
+					} elseif (isset($source['copyright'])) {
804
+						$image_url['copyright'] = $source['copyright'];
805
+					} else {
806
+						$image_url['copyright'] = $source['source_website'];
807
+					}
669 808
 					$image_url['source_website'] = $source['source_website'];
670 809
 					$image_url['source'] = $source['source'];
671 810
 					return $image_url;
672 811
 				}
673 812
 			}
674 813
 			return false;
675
-		} else return false;
814
+		} else {
815
+			return false;
816
+		}
676 817
 	}
677 818
 }
678 819
 
Please login to merge, or discard this patch.
require/class.MarineArchive.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 	/**
15 15
 	* Get SQL query part for filter used
16 16
 	* @param Array $filter the filter
17
-	* @return Array the SQL part
17
+	* @return string the SQL part
18 18
 	*/
19 19
 	public function getFilter($filter = array(),$where = false,$and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
Please login to merge, or discard this patch.
Indentation   +589 added lines, -589 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
 	}
11 11
 
12 12
 	/**
13
-	* Get SQL query part for filter used
14
-	* @param Array $filter the filter
15
-	* @return Array the SQL part
16
-	*/
13
+	 * Get SQL query part for filter used
14
+	 * @param Array $filter the filter
15
+	 * @return Array the SQL part
16
+	 */
17 17
 	public function getFilter($filter = array(),$where = false,$and = false) {
18 18
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
19 19
 		$filters = array();
@@ -110,44 +110,44 @@  discard block
 block discarded – undo
110 110
 	}
111 111
 
112 112
 
113
-        /**
114
-        * Gets all the spotter information based on a particular callsign
115
-        *
116
-        * @return Array the spotter information
117
-        *
118
-        */
119
-        public function getLastArchiveMarineDataByIdent($ident)
120
-        {
113
+		/**
114
+		 * Gets all the spotter information based on a particular callsign
115
+		 *
116
+		 * @return Array the spotter information
117
+		 *
118
+		 */
119
+		public function getLastArchiveMarineDataByIdent($ident)
120
+		{
121 121
 		$Marine = new Marine($this->db);
122
-                date_default_timezone_set('UTC');
122
+				date_default_timezone_set('UTC');
123 123
 
124
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
125
-                //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
126
-                $query  = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
124
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
125
+				//$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
126
+				$query  = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
127 127
 
128
-                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident));
128
+				$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident));
129 129
 
130
-                return $spotter_array;
131
-        }
130
+				return $spotter_array;
131
+		}
132 132
 
133 133
 
134
-        /**
135
-        * Gets last the spotter information based on a particular id
136
-        *
137
-        * @return Array the spotter information
138
-        *
139
-        */
140
-        public function getLastArchiveMarineDataById($id)
141
-        {
142
-    		$Marine = new Marine($this->db);
143
-                date_default_timezone_set('UTC');
144
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
145
-                //$query  = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";
146
-                //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
147
-                $query  = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
134
+		/**
135
+		 * Gets last the spotter information based on a particular id
136
+		 *
137
+		 * @return Array the spotter information
138
+		 *
139
+		 */
140
+		public function getLastArchiveMarineDataById($id)
141
+		{
142
+			$Marine = new Marine($this->db);
143
+				date_default_timezone_set('UTC');
144
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
145
+				//$query  = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";
146
+				//$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
147
+				$query  = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
148 148
 
149 149
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
150
-                  /*
150
+				  /*
151 151
                 try {
152 152
                         $Connection = new Connection();
153 153
                         $sth = Connection->$db->prepare($query);
@@ -157,178 +157,178 @@  discard block
 block discarded – undo
157 157
                 }
158 158
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
159 159
                 */
160
-                $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id));
161
-
162
-                return $spotter_array;
163
-        }
164
-
165
-        /**
166
-        * Gets all the spotter information based on a particular id
167
-        *
168
-        * @return Array the spotter information
169
-        *
170
-        */
171
-        public function getAllArchiveMarineDataById($id)
160
+				$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id));
161
+
162
+				return $spotter_array;
163
+		}
164
+
165
+		/**
166
+		 * Gets all the spotter information based on a particular id
167
+		 *
168
+		 * @return Array the spotter information
169
+		 *
170
+		 */
171
+		public function getAllArchiveMarineDataById($id)
172 172
 	{
173
-                date_default_timezone_set('UTC');
174
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
175
-                $query  = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
173
+				date_default_timezone_set('UTC');
174
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
175
+				$query  = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
176 176
 
177 177
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
178 178
 
179
-                try {
180
-                        $sth = $this->db->prepare($query);
181
-                        $sth->execute(array(':id' => $id));
182
-                } catch(PDOException $e) {
183
-                        echo $e->getMessage();
184
-                        die;
185
-                }
186
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
187
-
188
-                return $spotter_array;
189
-        }
190
-
191
-        /**
192
-        * Gets coordinate & time spotter information based on a particular id
193
-        *
194
-        * @return Array the spotter information
195
-        *
196
-        */
197
-        public function getCoordArchiveMarineDataById($id)
198
-        {
199
-                date_default_timezone_set('UTC');
200
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
201
-                $query  = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
179
+				try {
180
+						$sth = $this->db->prepare($query);
181
+						$sth->execute(array(':id' => $id));
182
+				} catch(PDOException $e) {
183
+						echo $e->getMessage();
184
+						die;
185
+				}
186
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
187
+
188
+				return $spotter_array;
189
+		}
190
+
191
+		/**
192
+		 * Gets coordinate & time spotter information based on a particular id
193
+		 *
194
+		 * @return Array the spotter information
195
+		 *
196
+		 */
197
+		public function getCoordArchiveMarineDataById($id)
198
+		{
199
+				date_default_timezone_set('UTC');
200
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
201
+				$query  = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
202 202
 
203 203
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
204 204
 
205
-                try {
206
-                        $sth = $this->db->prepare($query);
207
-                        $sth->execute(array(':id' => $id));
208
-                } catch(PDOException $e) {
209
-                        echo $e->getMessage();
210
-                        die;
211
-                }
212
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
205
+				try {
206
+						$sth = $this->db->prepare($query);
207
+						$sth->execute(array(':id' => $id));
208
+				} catch(PDOException $e) {
209
+						echo $e->getMessage();
210
+						die;
211
+				}
212
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
213 213
 
214
-                return $spotter_array;
215
-        }
214
+				return $spotter_array;
215
+		}
216 216
 
217 217
 
218
-        /**
219
-        * Gets altitude information based on a particular callsign
220
-        *
221
-        * @return Array the spotter information
222
-        *
223
-        */
224
-        public function getAltitudeArchiveMarineDataByIdent($ident)
225
-        {
218
+		/**
219
+		 * Gets altitude information based on a particular callsign
220
+		 *
221
+		 * @return Array the spotter information
222
+		 *
223
+		 */
224
+		public function getAltitudeArchiveMarineDataByIdent($ident)
225
+		{
226 226
 
227
-                date_default_timezone_set('UTC');
227
+				date_default_timezone_set('UTC');
228 228
 
229
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
230
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
229
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
230
+				$query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
231 231
 
232
-                try {
233
-                        $sth = $this->db->prepare($query);
234
-                        $sth->execute(array(':ident' => $ident));
235
-                } catch(PDOException $e) {
236
-                        echo $e->getMessage();
237
-                        die;
238
-                }
239
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
232
+				try {
233
+						$sth = $this->db->prepare($query);
234
+						$sth->execute(array(':ident' => $ident));
235
+				} catch(PDOException $e) {
236
+						echo $e->getMessage();
237
+						die;
238
+				}
239
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
240 240
 
241
-                return $spotter_array;
242
-        }
241
+				return $spotter_array;
242
+		}
243 243
 
244
-        /**
245
-        * Gets altitude information based on a particular id
246
-        *
247
-        * @return Array the spotter information
248
-        *
249
-        */
250
-        public function getAltitudeArchiveMarineDataById($id)
251
-        {
244
+		/**
245
+		 * Gets altitude information based on a particular id
246
+		 *
247
+		 * @return Array the spotter information
248
+		 *
249
+		 */
250
+		public function getAltitudeArchiveMarineDataById($id)
251
+		{
252 252
 
253
-                date_default_timezone_set('UTC');
253
+				date_default_timezone_set('UTC');
254 254
 
255
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
256
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
255
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
256
+				$query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
257 257
 
258
-                try {
259
-                        $sth = $this->db->prepare($query);
260
-                        $sth->execute(array(':id' => $id));
261
-                } catch(PDOException $e) {
262
-                        echo $e->getMessage();
263
-                        die;
264
-                }
265
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
258
+				try {
259
+						$sth = $this->db->prepare($query);
260
+						$sth->execute(array(':id' => $id));
261
+				} catch(PDOException $e) {
262
+						echo $e->getMessage();
263
+						die;
264
+				}
265
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
266 266
 
267
-                return $spotter_array;
268
-        }
267
+				return $spotter_array;
268
+		}
269 269
 
270
-        /**
271
-        * Gets altitude & speed information based on a particular id
272
-        *
273
-        * @return Array the spotter information
274
-        *
275
-        */
276
-        public function getAltitudeSpeedArchiveMarineDataById($id)
277
-        {
270
+		/**
271
+		 * Gets altitude & speed information based on a particular id
272
+		 *
273
+		 * @return Array the spotter information
274
+		 *
275
+		 */
276
+		public function getAltitudeSpeedArchiveMarineDataById($id)
277
+		{
278 278
 
279
-                date_default_timezone_set('UTC');
279
+				date_default_timezone_set('UTC');
280 280
 
281
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
282
-                $query  = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
281
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
282
+				$query  = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
283 283
 
284
-                try {
285
-                        $sth = $this->db->prepare($query);
286
-                        $sth->execute(array(':id' => $id));
287
-                } catch(PDOException $e) {
288
-                        echo $e->getMessage();
289
-                        die;
290
-                }
291
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
284
+				try {
285
+						$sth = $this->db->prepare($query);
286
+						$sth->execute(array(':id' => $id));
287
+				} catch(PDOException $e) {
288
+						echo $e->getMessage();
289
+						die;
290
+				}
291
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
292 292
 
293
-                return $spotter_array;
294
-        }
293
+				return $spotter_array;
294
+		}
295 295
 
296 296
 
297
-        /**
298
-        * Gets altitude information based on a particular callsign
299
-        *
300
-        * @return Array the spotter information
301
-        *
302
-        */
303
-        public function getLastAltitudeArchiveMarineDataByIdent($ident)
304
-        {
297
+		/**
298
+		 * Gets altitude information based on a particular callsign
299
+		 *
300
+		 * @return Array the spotter information
301
+		 *
302
+		 */
303
+		public function getLastAltitudeArchiveMarineDataByIdent($ident)
304
+		{
305 305
 
306
-                date_default_timezone_set('UTC');
306
+				date_default_timezone_set('UTC');
307 307
 
308
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
309
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
308
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
309
+				$query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
310 310
 //                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident";
311 311
 
312
-                try {
313
-                        $sth = $this->db->prepare($query);
314
-                        $sth->execute(array(':ident' => $ident));
315
-                } catch(PDOException $e) {
316
-                        echo $e->getMessage();
317
-                        die;
318
-                }
319
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
312
+				try {
313
+						$sth = $this->db->prepare($query);
314
+						$sth->execute(array(':ident' => $ident));
315
+				} catch(PDOException $e) {
316
+						echo $e->getMessage();
317
+						die;
318
+				}
319
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
320 320
 
321
-                return $spotter_array;
322
-        }
321
+				return $spotter_array;
322
+		}
323 323
 
324 324
 
325 325
 
326
-       /**
327
-        * Gets all the archive spotter information
328
-        *
329
-        * @return Array the spotter information
330
-        *
331
-        */
326
+	   /**
327
+	    * Gets all the archive spotter information
328
+	    *
329
+	    * @return Array the spotter information
330
+	    *
331
+	    */
332 332
 	public function getMarineArchiveData($ident,$fammarine_id,$date)
333 333
 	{
334 334
 		$Marine = new Marine($this->db);
@@ -338,10 +338,10 @@  discard block
 block discarded – undo
338 338
 		return $spotter_array;
339 339
 	}
340 340
 
341
-       /**
342
-        * Delete all tracking data
343
-        *
344
-        */
341
+	   /**
342
+	    * Delete all tracking data
343
+	    *
344
+	    */
345 345
 	public function deleteMarineArchiveTrackData()
346 346
 	{
347 347
 		global $globalArchiveKeepTrackMonths, $globalDBdriver;
@@ -360,34 +360,34 @@  discard block
 block discarded – undo
360 360
 	}
361 361
 
362 362
 	/**
363
-        * Gets Minimal Live Marine data
364
-        *
365
-        * @return Array the spotter information
366
-        *
367
-        */
368
-        public function getMinLiveMarineData($begindate,$enddate,$filter = array())
369
-        {
370
-                global $globalDBdriver, $globalLiveInterval;
371
-                date_default_timezone_set('UTC');
372
-
373
-                $filter_query = '';
374
-                if (isset($filter['source']) && !empty($filter['source'])) {
375
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
376
-                }
377
-                // Use spotter_output also ?
378
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
379
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
380
-                }
381
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
382
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
383
-                }
384
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
385
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
386
-                }
363
+	 * Gets Minimal Live Marine data
364
+	 *
365
+	 * @return Array the spotter information
366
+	 *
367
+	 */
368
+		public function getMinLiveMarineData($begindate,$enddate,$filter = array())
369
+		{
370
+				global $globalDBdriver, $globalLiveInterval;
371
+				date_default_timezone_set('UTC');
387 372
 
388
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
389
-                if ($globalDBdriver == 'mysql') {
390
-                        /*
373
+				$filter_query = '';
374
+				if (isset($filter['source']) && !empty($filter['source'])) {
375
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
376
+				}
377
+				// Use spotter_output also ?
378
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
379
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
380
+				}
381
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
382
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
383
+				}
384
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
385
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
386
+				}
387
+
388
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
389
+				if ($globalDBdriver == 'mysql') {
390
+						/*
391 391
                         $query  = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk 
392 392
                     		    FROM marine_archive 
393 393
                     		    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
@@ -406,56 +406,56 @@  discard block
 block discarded – undo
406 406
 				    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
407 407
 				    WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
408 408
                         	    '.$filter_query.' ORDER BY fammarine_id';
409
-                } else {
410
-                        //$query  = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';
411
-                        $query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
409
+				} else {
410
+						//$query  = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';
411
+						$query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
412 412
                         	    FROM marine_archive 
413 413
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
414 414
                         	    WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".'
415 415
                         	    '.$filter_query.' ORDER BY fammarine_id';
416
-                }
417
-                //echo $query;
418
-                try {
419
-                        $sth = $this->db->prepare($query);
420
-                        $sth->execute();
421
-                } catch(PDOException $e) {
422
-                        echo $e->getMessage();
423
-                        die;
424
-                }
425
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
416
+				}
417
+				//echo $query;
418
+				try {
419
+						$sth = $this->db->prepare($query);
420
+						$sth->execute();
421
+				} catch(PDOException $e) {
422
+						echo $e->getMessage();
423
+						die;
424
+				}
425
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
426 426
 
427
-                return $spotter_array;
428
-        }
427
+				return $spotter_array;
428
+		}
429 429
 
430 430
 	/**
431
-        * Gets Minimal Live Marine data
432
-        *
433
-        * @return Array the spotter information
434
-        *
435
-        */
436
-        public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())
437
-        {
438
-                global $globalDBdriver, $globalLiveInterval;
439
-                date_default_timezone_set('UTC');
440
-
441
-                $filter_query = '';
442
-                if (isset($filter['source']) && !empty($filter['source'])) {
443
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
444
-                }
445
-                // Should use spotter_output also ?
446
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
447
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
448
-                }
449
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
450
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
451
-                }
452
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
453
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
454
-                }
431
+	 * Gets Minimal Live Marine data
432
+	 *
433
+	 * @return Array the spotter information
434
+	 *
435
+	 */
436
+		public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())
437
+		{
438
+				global $globalDBdriver, $globalLiveInterval;
439
+				date_default_timezone_set('UTC');
455 440
 
456
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
457
-                if ($globalDBdriver == 'mysql') {
458
-                        /*
441
+				$filter_query = '';
442
+				if (isset($filter['source']) && !empty($filter['source'])) {
443
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
444
+				}
445
+				// Should use spotter_output also ?
446
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
447
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
448
+				}
449
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
450
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
451
+				}
452
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
453
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
454
+				}
455
+
456
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
457
+				if ($globalDBdriver == 'mysql') {
458
+						/*
459 459
                         $query  = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk 
460 460
                     		    FROM marine_archive 
461 461
                     		    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
@@ -466,95 +466,95 @@  discard block
 block discarded – undo
466 466
 				    WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
467 467
                         	    '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';
468 468
 
469
-                } else {
470
-                        //$query  = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao';
471
-                       /*
469
+				} else {
470
+						//$query  = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao';
471
+					   /*
472 472
                         $query  = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
473 473
                         	    FROM marine_archive_output 
474 474
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao
475 475
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
476 476
                         	    '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';
477 477
                         */
478
-                        $query  = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
478
+						$query  = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
479 479
                         	    FROM marine_archive_output 
480 480
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao
481 481
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
482 482
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
483 483
 //                        	    .' GROUP BY spotter_output.fammarine_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';
484 484
                         	    
485
-                }
486
-                //echo $query;
487
-                try {
488
-                        $sth = $this->db->prepare($query);
489
-                        $sth->execute();
490
-                } catch(PDOException $e) {
491
-                        echo $e->getMessage();
492
-                        die;
493
-                }
494
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
485
+				}
486
+				//echo $query;
487
+				try {
488
+						$sth = $this->db->prepare($query);
489
+						$sth->execute();
490
+				} catch(PDOException $e) {
491
+						echo $e->getMessage();
492
+						die;
493
+				}
494
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
495 495
 
496
-                return $spotter_array;
497
-        }
496
+				return $spotter_array;
497
+		}
498 498
 
499 499
 	 /**
500
-        * Gets count Live Marine data
501
-        *
502
-        * @return Array the spotter information
503
-        *
504
-        */
505
-        public function getLiveMarineCount($begindate,$enddate,$filter = array())
506
-        {
507
-                global $globalDBdriver, $globalLiveInterval;
508
-                date_default_timezone_set('UTC');
509
-
510
-                $filter_query = '';
511
-                if (isset($filter['source']) && !empty($filter['source'])) {
512
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
513
-                }
514
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
515
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
516
-                }
517
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
518
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
519
-                }
520
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
521
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
522
-                }
500
+	  * Gets count Live Marine data
501
+	  *
502
+	  * @return Array the spotter information
503
+	  *
504
+	  */
505
+		public function getLiveMarineCount($begindate,$enddate,$filter = array())
506
+		{
507
+				global $globalDBdriver, $globalLiveInterval;
508
+				date_default_timezone_set('UTC');
523 509
 
524
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
525
-                if ($globalDBdriver == 'mysql') {
510
+				$filter_query = '';
511
+				if (isset($filter['source']) && !empty($filter['source'])) {
512
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
513
+				}
514
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
515
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
516
+				}
517
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
518
+						$filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
519
+				}
520
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
521
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
522
+				}
523
+
524
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
525
+				if ($globalDBdriver == 'mysql') {
526 526
 			$query = 'SELECT COUNT(DISTINCT fammarine_id) as nb 
527 527
 			FROM marine_archive l 
528 528
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
529
-                } else {
529
+				} else {
530 530
 			$query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
531
-                }
532
-                //echo $query;
533
-                try {
534
-                        $sth = $this->db->prepare($query);
535
-                        $sth->execute();
536
-                } catch(PDOException $e) {
537
-                        echo $e->getMessage();
538
-                        die;
539
-                }
531
+				}
532
+				//echo $query;
533
+				try {
534
+						$sth = $this->db->prepare($query);
535
+						$sth->execute();
536
+				} catch(PDOException $e) {
537
+						echo $e->getMessage();
538
+						die;
539
+				}
540 540
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
541 541
 		$sth->closeCursor();
542
-                return $result['nb'];
542
+				return $result['nb'];
543 543
 
544
-        }
544
+		}
545 545
 
546 546
 
547 547
 
548 548
 	// marine_archive_output
549 549
 	
550
-    /**
551
-    * Gets all the spotter information
552
-    *
553
-    * @return Array the spotter information
554
-    *
555
-    */
556
-    public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
557
-    {
550
+	/**
551
+	 * Gets all the spotter information
552
+	 *
553
+	 * @return Array the spotter information
554
+	 *
555
+	 */
556
+	public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
557
+	{
558 558
 	global $globalTimezone, $globalDBdriver;
559 559
 	require_once(dirname(__FILE__).'/class.Translation.php');
560 560
 	$Translation = new Translation($this->db);
@@ -568,159 +568,159 @@  discard block
 block discarded – undo
568 568
 	$filter_query = $this->getFilter($filters);
569 569
 	if ($q != "")
570 570
 	{
571
-	    if (!is_string($q))
572
-	    {
571
+		if (!is_string($q))
572
+		{
573 573
 		return false;
574
-	    } else {
574
+		} else {
575 575
 	        
576 576
 		$q_array = explode(" ", $q);
577 577
 		
578 578
 		foreach ($q_array as $q_item){
579
-		    $additional_query .= " AND (";
580
-		    $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";
581
-		    $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";
582
-		    $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR ";
583
-		    $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
584
-		    $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR ";
585
-		    $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR ";
586
-		    $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR ";
587
-		    $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
588
-		    $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR ";
589
-		    $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR ";
590
-		    $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR ";
591
-		    $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
592
-		    $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
593
-		    $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
594
-		    $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
595
-		    $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR ";
596
-		    $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR ";
597
-		    $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR ";
598
-		    $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
599
-		    $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
600
-		    $translate = $Translation->ident2icao($q_item);
601
-		    if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
602
-		    $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
603
-		    $additional_query .= ")";
579
+			$additional_query .= " AND (";
580
+			$additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";
581
+			$additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";
582
+			$additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR ";
583
+			$additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
584
+			$additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR ";
585
+			$additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR ";
586
+			$additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR ";
587
+			$additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
588
+			$additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR ";
589
+			$additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR ";
590
+			$additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR ";
591
+			$additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
592
+			$additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
593
+			$additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
594
+			$additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
595
+			$additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR ";
596
+			$additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR ";
597
+			$additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR ";
598
+			$additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
599
+			$additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
600
+			$translate = $Translation->ident2icao($q_item);
601
+			if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
602
+			$additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
603
+			$additional_query .= ")";
604
+		}
604 605
 		}
605
-	    }
606 606
 	}
607 607
 	
608 608
 	if ($registration != "")
609 609
 	{
610
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
611
-	    if (!is_string($registration))
612
-	    {
610
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
611
+		if (!is_string($registration))
612
+		{
613 613
 		return false;
614
-	    } else {
614
+		} else {
615 615
 		$additional_query .= " AND (marine_archive_output.registration = '".$registration."')";
616
-	    }
616
+		}
617 617
 	}
618 618
 	
619 619
 	if ($aircraft_icao != "")
620 620
 	{
621
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
622
-	    if (!is_string($aircraft_icao))
623
-	    {
621
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
622
+		if (!is_string($aircraft_icao))
623
+		{
624 624
 		return false;
625
-	    } else {
625
+		} else {
626 626
 		$additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')";
627
-	    }
627
+		}
628 628
 	}
629 629
 	
630 630
 	if ($aircraft_manufacturer != "")
631 631
 	{
632
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
633
-	    if (!is_string($aircraft_manufacturer))
634
-	    {
632
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
633
+		if (!is_string($aircraft_manufacturer))
634
+		{
635 635
 		return false;
636
-	    } else {
636
+		} else {
637 637
 		$additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
638
-	    }
638
+		}
639 639
 	}
640 640
 	
641 641
 	if ($highlights == "true")
642 642
 	{
643
-	    if (!is_string($highlights))
644
-	    {
643
+		if (!is_string($highlights))
644
+		{
645 645
 		return false;
646
-	    } else {
646
+		} else {
647 647
 		$additional_query .= " AND (marine_archive_output.highlight <> '')";
648
-	    }
648
+		}
649 649
 	}
650 650
 	
651 651
 	if ($airline_icao != "")
652 652
 	{
653
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
654
-	    if (!is_string($airline_icao))
655
-	    {
653
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
654
+		if (!is_string($airline_icao))
655
+		{
656 656
 		return false;
657
-	    } else {
657
+		} else {
658 658
 		$additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')";
659
-	    }
659
+		}
660 660
 	}
661 661
 	
662 662
 	if ($airline_country != "")
663 663
 	{
664
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
665
-	    if (!is_string($airline_country))
666
-	    {
664
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
665
+		if (!is_string($airline_country))
666
+		{
667 667
 		return false;
668
-	    } else {
668
+		} else {
669 669
 		$additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')";
670
-	    }
670
+		}
671 671
 	}
672 672
 	
673 673
 	if ($airline_type != "")
674 674
 	{
675
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
676
-	    if (!is_string($airline_type))
677
-	    {
675
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
676
+		if (!is_string($airline_type))
677
+		{
678 678
 		return false;
679
-	    } else {
679
+		} else {
680 680
 		if ($airline_type == "passenger")
681 681
 		{
682
-		    $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')";
682
+			$additional_query .= " AND (marine_archive_output.airline_type = 'passenger')";
683 683
 		}
684 684
 		if ($airline_type == "cargo")
685 685
 		{
686
-		    $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')";
686
+			$additional_query .= " AND (marine_archive_output.airline_type = 'cargo')";
687 687
 		}
688 688
 		if ($airline_type == "military")
689 689
 		{
690
-		    $additional_query .= " AND (marine_archive_output.airline_type = 'military')";
690
+			$additional_query .= " AND (marine_archive_output.airline_type = 'military')";
691
+		}
691 692
 		}
692
-	    }
693 693
 	}
694 694
 	
695 695
 	if ($airport != "")
696 696
 	{
697
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
698
-	    if (!is_string($airport))
699
-	    {
697
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
698
+		if (!is_string($airport))
699
+		{
700 700
 		return false;
701
-	    } else {
701
+		} else {
702 702
 		$additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))";
703
-	    }
703
+		}
704 704
 	}
705 705
 	
706 706
 	if ($airport_country != "")
707 707
 	{
708
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
709
-	    if (!is_string($airport_country))
710
-	    {
708
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
709
+		if (!is_string($airport_country))
710
+		{
711 711
 		return false;
712
-	    } else {
712
+		} else {
713 713
 		$additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))";
714
-	    }
714
+		}
715 715
 	}
716 716
     
717 717
 	if ($callsign != "")
718 718
 	{
719
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
720
-	    if (!is_string($callsign))
721
-	    {
719
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
720
+		if (!is_string($callsign))
721
+		{
722 722
 		return false;
723
-	    } else {
723
+		} else {
724 724
 		$translate = $Translation->ident2icao($callsign);
725 725
 		if ($translate != $callsign) {
726 726
 			$additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)";
@@ -728,99 +728,99 @@  discard block
 block discarded – undo
728 728
 		} else {
729 729
 			$additional_query .= " AND (marine_archive_output.ident = '".$callsign."')";
730 730
 		}
731
-	    }
731
+		}
732 732
 	}
733 733
 
734 734
 	if ($owner != "")
735 735
 	{
736
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
737
-	    if (!is_string($owner))
738
-	    {
736
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
737
+		if (!is_string($owner))
738
+		{
739 739
 		return false;
740
-	    } else {
740
+		} else {
741 741
 		$additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')";
742
-	    }
742
+		}
743 743
 	}
744 744
 
745 745
 	if ($pilot_name != "")
746 746
 	{
747
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
748
-	    if (!is_string($pilot_name))
749
-	    {
747
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
748
+		if (!is_string($pilot_name))
749
+		{
750 750
 		return false;
751
-	    } else {
751
+		} else {
752 752
 		$additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')";
753
-	    }
753
+		}
754 754
 	}
755 755
 	
756 756
 	if ($pilot_id != "")
757 757
 	{
758
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
759
-	    if (!is_string($pilot_id))
760
-	    {
758
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
759
+		if (!is_string($pilot_id))
760
+		{
761 761
 		return false;
762
-	    } else {
762
+		} else {
763 763
 		$additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')";
764
-	    }
764
+		}
765 765
 	}
766 766
 	
767 767
 	if ($departure_airport_route != "")
768 768
 	{
769
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
770
-	    if (!is_string($departure_airport_route))
771
-	    {
769
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
770
+		if (!is_string($departure_airport_route))
771
+		{
772 772
 		return false;
773
-	    } else {
773
+		} else {
774 774
 		$additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')";
775
-	    }
775
+		}
776 776
 	}
777 777
 	
778 778
 	if ($arrival_airport_route != "")
779 779
 	{
780
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
781
-	    if (!is_string($arrival_airport_route))
782
-	    {
780
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
781
+		if (!is_string($arrival_airport_route))
782
+		{
783 783
 		return false;
784
-	    } else {
784
+		} else {
785 785
 		$additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
786
-	    }
786
+		}
787 787
 	}
788 788
 	
789 789
 	if ($altitude != "")
790 790
 	{
791
-	    $altitude_array = explode(",", $altitude);
791
+		$altitude_array = explode(",", $altitude);
792 792
 	    
793
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
794
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
793
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
794
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
795 795
 	    
796 796
 
797
-	    if ($altitude_array[1] != "")
798
-	    {                
797
+		if ($altitude_array[1] != "")
798
+		{                
799 799
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
800 800
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
801 801
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
802
-	    } else {
802
+		} else {
803 803
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
804 804
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
805
-	    }
805
+		}
806 806
 	}
807 807
 	
808 808
 	if ($date_posted != "")
809 809
 	{
810
-	    $date_array = explode(",", $date_posted);
810
+		$date_array = explode(",", $date_posted);
811 811
 	    
812
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
813
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
812
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
813
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
814 814
 	    
815
-	    if ($globalTimezone != '') {
815
+		if ($globalTimezone != '') {
816 816
 		date_default_timezone_set($globalTimezone);
817 817
 		$datetime = new DateTime();
818 818
 		$offset = $datetime->format('P');
819
-	    } else $offset = '+00:00';
819
+		} else $offset = '+00:00';
820 820
 
821 821
 
822
-	    if ($date_array[1] != "")
823
-	    {                
822
+		if ($date_array[1] != "")
823
+		{                
824 824
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
825 825
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
826 826
 		if ($globalDBdriver == 'mysql') {
@@ -828,28 +828,28 @@  discard block
 block discarded – undo
828 828
 		} else {
829 829
 			$additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
830 830
 		}
831
-	    } else {
831
+		} else {
832 832
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
833
-                if ($globalDBdriver == 'mysql') {
833
+				if ($globalDBdriver == 'mysql') {
834 834
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
835 835
 		} else {
836 836
 			$additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
837 837
 		}
838
-	    }
838
+		}
839 839
 	}
840 840
 	
841 841
 	if ($limit != "")
842 842
 	{
843
-	    $limit_array = explode(",", $limit);
843
+		$limit_array = explode(",", $limit);
844 844
 	    
845
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
846
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
845
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
846
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
847 847
 	    
848
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
849
-	    {
848
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
849
+		{
850 850
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
851 851
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
852
-	    }
852
+		}
853 853
 	}
854 854
 	
855 855
 
@@ -880,33 +880,33 @@  discard block
 block discarded – undo
880 880
 	$spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query);
881 881
 
882 882
 	return $spotter_array;
883
-    }
883
+	}
884 884
 
885
-    public function deleteMarineArchiveData()
886
-    {
885
+	public function deleteMarineArchiveData()
886
+	{
887 887
 		global $globalArchiveKeepMonths, $globalDBdriver;
888
-                date_default_timezone_set('UTC');
889
-                if ($globalDBdriver == 'mysql') {
888
+				date_default_timezone_set('UTC');
889
+				if ($globalDBdriver == 'mysql') {
890 890
 			$query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
891 891
 		} else {
892 892
 			$query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
893 893
 		}
894
-                try {
895
-                        $sth = $this->db->prepare($query);
896
-                        $sth->execute();
897
-                } catch(PDOException $e) {
898
-                        return "error";
899
-                }
894
+				try {
895
+						$sth = $this->db->prepare($query);
896
+						$sth->execute();
897
+				} catch(PDOException $e) {
898
+						return "error";
899
+				}
900 900
 	}
901 901
 
902
-    /**
903
-    * Gets all the spotter information based on the callsign
904
-    *
905
-    * @return Array the spotter information
906
-    *
907
-    */
908
-    public function getMarineDataByIdent($ident = '', $limit = '', $sort = '')
909
-    {
902
+	/**
903
+	 * Gets all the spotter information based on the callsign
904
+	 *
905
+	 * @return Array the spotter information
906
+	 *
907
+	 */
908
+	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '')
909
+	{
910 910
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
911 911
 	
912 912
 	date_default_timezone_set('UTC');
@@ -918,35 +918,35 @@  discard block
 block discarded – undo
918 918
 	
919 919
 	if ($ident != "")
920 920
 	{
921
-	    if (!is_string($ident))
922
-	    {
921
+		if (!is_string($ident))
922
+		{
923 923
 		return false;
924
-	    } else {
924
+		} else {
925 925
 		$additional_query = " AND (marine_archive_output.ident = :ident)";
926 926
 		$query_values = array(':ident' => $ident);
927
-	    }
927
+		}
928 928
 	}
929 929
 	
930 930
 	if ($limit != "")
931 931
 	{
932
-	    $limit_array = explode(",", $limit);
932
+		$limit_array = explode(",", $limit);
933 933
 	    
934
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
935
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
934
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
935
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
936 936
 	    
937
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
938
-	    {
937
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
938
+		{
939 939
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
940 940
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
941
-	    }
941
+		}
942 942
 	}
943 943
 
944 944
 	if ($sort != "")
945 945
 	{
946
-	    $search_orderby_array = $Marine->getOrderBy();
947
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
946
+		$search_orderby_array = $Marine->getOrderBy();
947
+		$orderby_query = $search_orderby_array[$sort]['sql'];
948 948
 	} else {
949
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
949
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
950 950
 	}
951 951
 
952 952
 	$query = $global_query." WHERE marine_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -954,17 +954,17 @@  discard block
 block discarded – undo
954 954
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
955 955
 
956 956
 	return $spotter_array;
957
-    }
957
+	}
958 958
 
959 959
 
960
-    /**
961
-    * Gets all the spotter information based on the owner
962
-    *
963
-    * @return Array the spotter information
964
-    *
965
-    */
966
-    public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
967
-    {
960
+	/**
961
+	 * Gets all the spotter information based on the owner
962
+	 *
963
+	 * @return Array the spotter information
964
+	 *
965
+	 */
966
+	public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
967
+	{
968 968
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
969 969
 	
970 970
 	date_default_timezone_set('UTC');
@@ -977,35 +977,35 @@  discard block
 block discarded – undo
977 977
 	
978 978
 	if ($owner != "")
979 979
 	{
980
-	    if (!is_string($owner))
981
-	    {
980
+		if (!is_string($owner))
981
+		{
982 982
 		return false;
983
-	    } else {
983
+		} else {
984 984
 		$additional_query = " AND (marine_archive_output.owner_name = :owner)";
985 985
 		$query_values = array(':owner' => $owner);
986
-	    }
986
+		}
987 987
 	}
988 988
 	
989 989
 	if ($limit != "")
990 990
 	{
991
-	    $limit_array = explode(",", $limit);
991
+		$limit_array = explode(",", $limit);
992 992
 	    
993
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
994
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
993
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
994
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
995 995
 	    
996
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
997
-	    {
996
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
997
+		{
998 998
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
999 999
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1000
-	    }
1000
+		}
1001 1001
 	}
1002 1002
 
1003 1003
 	if ($sort != "")
1004 1004
 	{
1005
-	    $search_orderby_array = $Marine->getOrderBy();
1006
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1005
+		$search_orderby_array = $Marine->getOrderBy();
1006
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1007 1007
 	} else {
1008
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1008
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1009 1009
 	}
1010 1010
 
1011 1011
 	$query = $global_query.$filter_query." marine_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1013,16 +1013,16 @@  discard block
 block discarded – undo
1013 1013
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1014 1014
 
1015 1015
 	return $spotter_array;
1016
-    }
1017
-
1018
-    /**
1019
-    * Gets all the spotter information based on the pilot
1020
-    *
1021
-    * @return Array the spotter information
1022
-    *
1023
-    */
1024
-    public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1025
-    {
1016
+	}
1017
+
1018
+	/**
1019
+	 * Gets all the spotter information based on the pilot
1020
+	 *
1021
+	 * @return Array the spotter information
1022
+	 *
1023
+	 */
1024
+	public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1025
+	{
1026 1026
 	$global_query = "SELECT marine_archive_output.* FROM marine_archive_output";
1027 1027
 	
1028 1028
 	date_default_timezone_set('UTC');
@@ -1041,24 +1041,24 @@  discard block
 block discarded – undo
1041 1041
 	
1042 1042
 	if ($limit != "")
1043 1043
 	{
1044
-	    $limit_array = explode(",", $limit);
1044
+		$limit_array = explode(",", $limit);
1045 1045
 	    
1046
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1047
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1046
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1047
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1048 1048
 	    
1049
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1050
-	    {
1049
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1050
+		{
1051 1051
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1052 1052
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1053
-	    }
1053
+		}
1054 1054
 	}
1055 1055
 
1056 1056
 	if ($sort != "")
1057 1057
 	{
1058
-	    $search_orderby_array = $Marine->getOrderBy();
1059
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1058
+		$search_orderby_array = $Marine->getOrderBy();
1059
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1060 1060
 	} else {
1061
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1061
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1062 1062
 	}
1063 1063
 
1064 1064
 	$query = $global_query.$filter_query." marine_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1066,16 +1066,16 @@  discard block
 block discarded – undo
1066 1066
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1067 1067
 
1068 1068
 	return $spotter_array;
1069
-    }
1070
-
1071
-    /**
1072
-    * Gets all number of flight over countries
1073
-    *
1074
-    * @return Array the airline country list
1075
-    *
1076
-    */
1077
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1078
-    {
1069
+	}
1070
+
1071
+	/**
1072
+	 * Gets all number of flight over countries
1073
+	 *
1074
+	 * @return Array the airline country list
1075
+	 *
1076
+	 */
1077
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1078
+	{
1079 1079
 	global $globalDBdriver;
1080 1080
 	/*
1081 1081
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1085,14 +1085,14 @@  discard block
 block discarded – undo
1085 1085
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1086 1086
 		    FROM countries c, marine_archive s
1087 1087
 		    WHERE c.iso2 = s.over_country ";
1088
-                if ($olderthanmonths > 0) {
1089
-            		if ($globalDBdriver == 'mysql') {
1088
+				if ($olderthanmonths > 0) {
1089
+					if ($globalDBdriver == 'mysql') {
1090 1090
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1091 1091
 			} else {
1092 1092
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1093 1093
 			}
1094 1094
 		}
1095
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1095
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1096 1096
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1097 1097
 	if ($limit) $query .= " LIMIT 0,10";
1098 1098
       
@@ -1105,23 +1105,23 @@  discard block
 block discarded – undo
1105 1105
         
1106 1106
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1107 1107
 	{
1108
-	    $temp_array['flight_count'] = $row['nb'];
1109
-	    $temp_array['flight_country'] = $row['name'];
1110
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1111
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1112
-	    $flight_array[] = $temp_array;
1108
+		$temp_array['flight_count'] = $row['nb'];
1109
+		$temp_array['flight_country'] = $row['name'];
1110
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1111
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1112
+		$flight_array[] = $temp_array;
1113 1113
 	}
1114 1114
 	return $flight_array;
1115
-    }
1116
-
1117
-    /**
1118
-    * Gets all number of flight over countries
1119
-    *
1120
-    * @return Array the airline country list
1121
-    *
1122
-    */
1123
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1124
-    {
1115
+	}
1116
+
1117
+	/**
1118
+	 * Gets all number of flight over countries
1119
+	 *
1120
+	 * @return Array the airline country list
1121
+	 *
1122
+	 */
1123
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1124
+	{
1125 1125
 	global $globalDBdriver;
1126 1126
 	/*
1127 1127
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1131,14 +1131,14 @@  discard block
 block discarded – undo
1131 1131
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1132 1132
 		    FROM countries c, marine_archive s, spotter_output o
1133 1133
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.fammarine_id = s.fammarine_id ";
1134
-                if ($olderthanmonths > 0) {
1135
-            		if ($globalDBdriver == 'mysql') {
1134
+				if ($olderthanmonths > 0) {
1135
+					if ($globalDBdriver == 'mysql') {
1136 1136
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1137 1137
 			} else {
1138 1138
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1139 1139
 			}
1140 1140
 		}
1141
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1141
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1142 1142
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1143 1143
 	if ($limit) $query .= " LIMIT 0,10";
1144 1144
       
@@ -1151,24 +1151,24 @@  discard block
 block discarded – undo
1151 1151
         
1152 1152
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1153 1153
 	{
1154
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1155
-	    $temp_array['flight_count'] = $row['nb'];
1156
-	    $temp_array['flight_country'] = $row['name'];
1157
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1158
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1159
-	    $flight_array[] = $temp_array;
1154
+		$temp_array['airline_icao'] = $row['airline_icao'];
1155
+		$temp_array['flight_count'] = $row['nb'];
1156
+		$temp_array['flight_country'] = $row['name'];
1157
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1158
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1159
+		$flight_array[] = $temp_array;
1160 1160
 	}
1161 1161
 	return $flight_array;
1162
-    }
1163
-
1164
-    /**
1165
-    * Gets last spotter information based on a particular callsign
1166
-    *
1167
-    * @return Array the spotter information
1168
-    *
1169
-    */
1170
-    public function getDateArchiveMarineDataById($id,$date)
1171
-    {
1162
+	}
1163
+
1164
+	/**
1165
+	 * Gets last spotter information based on a particular callsign
1166
+	 *
1167
+	 * @return Array the spotter information
1168
+	 *
1169
+	 */
1170
+	public function getDateArchiveMarineDataById($id,$date)
1171
+	{
1172 1172
 	$Marine = new Marine($this->db);
1173 1173
 	date_default_timezone_set('UTC');
1174 1174
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1176,16 +1176,16 @@  discard block
 block discarded – undo
1176 1176
 	$date = date('c',$date);
1177 1177
 	$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date));
1178 1178
 	return $spotter_array;
1179
-    }
1180
-
1181
-    /**
1182
-    * Gets all the spotter information based on a particular callsign
1183
-    *
1184
-    * @return Array the spotter information
1185
-    *
1186
-    */
1187
-    public function getDateArchiveMarineDataByIdent($ident,$date)
1188
-    {
1179
+	}
1180
+
1181
+	/**
1182
+	 * Gets all the spotter information based on a particular callsign
1183
+	 *
1184
+	 * @return Array the spotter information
1185
+	 *
1186
+	 */
1187
+	public function getDateArchiveMarineDataByIdent($ident,$date)
1188
+	{
1189 1189
 	$Marine = new Marine($this->db);
1190 1190
 	date_default_timezone_set('UTC');
1191 1191
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1193,16 +1193,16 @@  discard block
 block discarded – undo
1193 1193
 	$date = date('c',$date);
1194 1194
 	$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1195 1195
 	return $spotter_array;
1196
-    }
1197
-
1198
-    /**
1199
-    * Gets all the spotter information based on the airport
1200
-    *
1201
-    * @return Array the spotter information
1202
-    *
1203
-    */
1204
-    public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1205
-    {
1196
+	}
1197
+
1198
+	/**
1199
+	 * Gets all the spotter information based on the airport
1200
+	 *
1201
+	 * @return Array the spotter information
1202
+	 *
1203
+	 */
1204
+	public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1205
+	{
1206 1206
 	global $global_query;
1207 1207
 	$Marine = new Marine($this->db);
1208 1208
 	date_default_timezone_set('UTC');
@@ -1213,35 +1213,35 @@  discard block
 block discarded – undo
1213 1213
 	
1214 1214
 	if ($airport != "")
1215 1215
 	{
1216
-	    if (!is_string($airport))
1217
-	    {
1216
+		if (!is_string($airport))
1217
+		{
1218 1218
 		return false;
1219
-	    } else {
1219
+		} else {
1220 1220
 		$additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))";
1221 1221
 		$query_values = array(':airport' => $airport);
1222
-	    }
1222
+		}
1223 1223
 	}
1224 1224
 	
1225 1225
 	if ($limit != "")
1226 1226
 	{
1227
-	    $limit_array = explode(",", $limit);
1227
+		$limit_array = explode(",", $limit);
1228 1228
 	    
1229
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1230
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1229
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1230
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1231 1231
 	    
1232
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1233
-	    {
1232
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1233
+		{
1234 1234
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1235 1235
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1236
-	    }
1236
+		}
1237 1237
 	}
1238 1238
 	
1239 1239
 	if ($sort != "")
1240 1240
 	{
1241
-	    $search_orderby_array = $Marine->getOrderBy();
1242
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1241
+		$search_orderby_array = $Marine->getOrderBy();
1242
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1243 1243
 	} else {
1244
-	    $orderby_query = " ORDER BY marine_archive_output.date DESC";
1244
+		$orderby_query = " ORDER BY marine_archive_output.date DESC";
1245 1245
 	}
1246 1246
 
1247 1247
 	$query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
@@ -1249,6 +1249,6 @@  discard block
 block discarded – undo
1249 1249
 	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
1250 1250
 
1251 1251
 	return $spotter_array;
1252
-    }
1252
+	}
1253 1253
 }
1254 1254
 ?>
1255 1255
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +37 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@  discard block
 block discarded – undo
6 6
 	public function __construct($dbc = null) {
7 7
 		$Connection = new Connection($dbc);
8 8
 		$this->db = $Connection->db;
9
-		if ($this->db === null) die('Error: No DB connection. (MarineArchive)');
9
+		if ($this->db === null) {
10
+			die('Error: No DB connection. (MarineArchive)');
11
+		}
10 12
 	}
11 13
 
12 14
 	/**
@@ -27,7 +29,9 @@  discard block
 block discarded – undo
27 29
 		if (isset($filter[0]['source'])) {
28 30
 			$filters = array_merge($filters,$filter);
29 31
 		}
30
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
31 35
 		$filter_query_join = '';
32 36
 		$filter_query_where = '';
33 37
 		foreach($filters as $flt) {
@@ -73,8 +77,11 @@  discard block
 block discarded – undo
73 77
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
74 78
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
75 79
 		}
76
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
77
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
80
+		if ($filter_query_where == '' && $where) {
81
+			$filter_query_where = ' WHERE';
82
+		} elseif ($filter_query_where != '' && $and) {
83
+			$filter_query_where .= ' AND';
84
+		}
78 85
 		if ($filter_query_where != '') {
79 86
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
80 87
 		}
@@ -88,9 +95,14 @@  discard block
 block discarded – undo
88 95
 		if ($over_country == '') {
89 96
 			$Marine = new Marine($this->db);
90 97
 			$data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude);
91
-			if (!empty($data_country)) $country = $data_country['iso2'];
92
-			else $country = '';
93
-		} else $country = $over_country;
98
+			if (!empty($data_country)) {
99
+				$country = $data_country['iso2'];
100
+			} else {
101
+				$country = '';
102
+			}
103
+		} else {
104
+			$country = $over_country;
105
+		}
94 106
 		
95 107
 		//$country = $over_country;
96 108
 		// Route is not added in marine_archive
@@ -598,7 +610,9 @@  discard block
 block discarded – undo
598 610
 		    $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
599 611
 		    $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
600 612
 		    $translate = $Translation->ident2icao($q_item);
601
-		    if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
613
+		    if ($translate != $q_item) {
614
+		    	$additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
615
+		    }
602 616
 		    $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
603 617
 		    $additional_query .= ")";
604 618
 		}
@@ -816,7 +830,9 @@  discard block
 block discarded – undo
816 830
 		date_default_timezone_set($globalTimezone);
817 831
 		$datetime = new DateTime();
818 832
 		$offset = $datetime->format('P');
819
-	    } else $offset = '+00:00';
833
+	    } else {
834
+	    	$offset = '+00:00';
835
+	    }
820 836
 
821 837
 
822 838
 	    if ($date_array[1] != "")
@@ -1092,9 +1108,13 @@  discard block
 block discarded – undo
1092 1108
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1093 1109
 			}
1094 1110
 		}
1095
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1111
+                if ($sincedate != '') {
1112
+                	$query .= "AND date > '".$sincedate."' ";
1113
+                }
1096 1114
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1097
-	if ($limit) $query .= " LIMIT 0,10";
1115
+	if ($limit) {
1116
+		$query .= " LIMIT 0,10";
1117
+	}
1098 1118
       
1099 1119
 	
1100 1120
 	$sth = $this->db->prepare($query);
@@ -1138,9 +1158,13 @@  discard block
 block discarded – undo
1138 1158
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1139 1159
 			}
1140 1160
 		}
1141
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1161
+                if ($sincedate != '') {
1162
+                	$query .= "AND s.date > '".$sincedate."' ";
1163
+                }
1142 1164
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1143
-	if ($limit) $query .= " LIMIT 0,10";
1165
+	if ($limit) {
1166
+		$query .= " LIMIT 0,10";
1167
+	}
1144 1168
       
1145 1169
 	
1146 1170
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -14,33 +14,33 @@  discard block
 block discarded – undo
14 14
 	* @param Array $filter the filter
15 15
 	* @return Array the SQL part
16 16
 	*/
17
-	public function getFilter($filter = array(),$where = false,$and = false) {
17
+	public function getFilter($filter = array(), $where = false, $and = false) {
18 18
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
19 19
 		$filters = array();
20 20
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 21
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22 22
 				$filters = $globalStatsFilters[$globalFilterName];
23 23
 			} else {
24
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
24
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
25 25
 			}
26 26
 		}
27 27
 		if (isset($filter[0]['source'])) {
28
-			$filters = array_merge($filters,$filter);
28
+			$filters = array_merge($filters, $filter);
29 29
 		}
30
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
30
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
31 31
 		$filter_query_join = '';
32 32
 		$filter_query_where = '';
33
-		foreach($filters as $flt) {
33
+		foreach ($filters as $flt) {
34 34
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
35 35
 				if (isset($flt['source'])) {
36
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
36
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
37 37
 				} else {
38
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
38
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id";
39 39
 				}
40 40
 			}
41 41
 		}
42 42
 		if (isset($filter['source']) && !empty($filter['source'])) {
43
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
43
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
44 44
 		}
45 45
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
46 46
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -68,40 +68,40 @@  discard block
 block discarded – undo
68 68
 					$filter_query_date .= " AND EXTRACT(DAY FROM marine_archive_output.date) = '".$filter['day']."'";
69 69
 				}
70 70
 			}
71
-			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id";
71
+			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id";
72 72
 		}
73 73
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
74
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
74
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
75 75
 		}
76 76
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
77 77
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
78 78
 		if ($filter_query_where != '') {
79
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
79
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
80 80
 		}
81 81
 		$filter_query = $filter_query_join.$filter_query_where;
82 82
 		return $filter_query;
83 83
 	}
84 84
 
85 85
 	// marine_archive
86
-	public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '',$captain_id = '',$captain_name = '',$race_id = '',$race_name = '',$distance = '',$race_rank = '', $race_time = '') {
86
+	public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '', $captain_id = '', $captain_name = '', $race_id = '', $race_name = '', $distance = '', $race_rank = '', $race_time = '') {
87 87
 		require_once(dirname(__FILE__).'/class.Marine.php');
88 88
 		if ($over_country == '') {
89 89
 			$Marine = new Marine($this->db);
90
-			$data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude);
90
+			$data_country = $Marine->getCountryFromLatitudeLongitude($latitude, $longitude);
91 91
 			if (!empty($data_country)) $country = $data_country['iso2'];
92 92
 			else $country = '';
93 93
 		} else $country = $over_country;
94 94
 		
95 95
 		//$country = $over_country;
96 96
 		// Route is not added in marine_archive
97
-		$query  = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) 
97
+		$query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) 
98 98
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name,:distance,:race_rank,:race_time)';
99
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country,':mmsi' => $mmsi,':type' => $type,':type_id' => $typeid,':status' => $status,':status_id' => $statusid,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date,':captain_id' => $captain_id,':captain_name' => $captain_name,':race_id' => $race_id,':race_name' => $race_name,':distance' => $distance,':race_rank' => $race_rank,':race_time' => $race_time);
99
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country, ':mmsi' => $mmsi, ':type' => $type, ':type_id' => $typeid, ':status' => $status, ':status_id' => $statusid, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date, ':captain_id' => $captain_id, ':captain_name' => $captain_name, ':race_id' => $race_id, ':race_name' => $race_name, ':distance' => $distance, ':race_rank' => $race_rank, ':race_time' => $race_time);
100 100
 		try {
101 101
 			$sth = $this->db->prepare($query);
102 102
 			$sth->execute($query_values);
103 103
 			$sth->closeCursor();
104
-		} catch(PDOException $e) {
104
+		} catch (PDOException $e) {
105 105
 			return "error : ".$e->getMessage();
106 106
 		}
107 107
 		return "success";
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 
122 122
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
123 123
                 //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
124
-                $query  = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
124
+                $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
125 125
 
126
-                $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident));
126
+                $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident));
127 127
 
128 128
                 return $spotter_array;
129 129
         }
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
143 143
                 //$query  = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id";
144 144
                 //$query  = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
145
-                $query  = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
145
+                $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1";
146 146
 
147 147
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
148 148
                   /*
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
                 }
156 156
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
157 157
                 */
158
-                $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id));
158
+                $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id));
159 159
 
160 160
                 return $spotter_array;
161 161
         }
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
 	{
171 171
                 date_default_timezone_set('UTC');
172 172
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
173
-                $query  = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
173
+                $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date";
174 174
 
175 175
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
176 176
 
177 177
                 try {
178 178
                         $sth = $this->db->prepare($query);
179 179
                         $sth->execute(array(':id' => $id));
180
-                } catch(PDOException $e) {
180
+                } catch (PDOException $e) {
181 181
                         echo $e->getMessage();
182 182
                         die;
183 183
                 }
@@ -196,14 +196,14 @@  discard block
 block discarded – undo
196 196
         {
197 197
                 date_default_timezone_set('UTC');
198 198
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
199
-                $query  = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
199
+                $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id";
200 200
 
201 201
 //              $spotter_array = Marine->getDataFromDB($query,array(':id' => $id));
202 202
 
203 203
                 try {
204 204
                         $sth = $this->db->prepare($query);
205 205
                         $sth->execute(array(':id' => $id));
206
-                } catch(PDOException $e) {
206
+                } catch (PDOException $e) {
207 207
                         echo $e->getMessage();
208 208
                         die;
209 209
                 }
@@ -225,12 +225,12 @@  discard block
 block discarded – undo
225 225
                 date_default_timezone_set('UTC');
226 226
 
227 227
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
228
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
228
+                $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
229 229
 
230 230
                 try {
231 231
                         $sth = $this->db->prepare($query);
232 232
                         $sth->execute(array(':ident' => $ident));
233
-                } catch(PDOException $e) {
233
+                } catch (PDOException $e) {
234 234
                         echo $e->getMessage();
235 235
                         die;
236 236
                 }
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
                 date_default_timezone_set('UTC');
252 252
 
253 253
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
254
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
254
+                $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date";
255 255
 
256 256
                 try {
257 257
                         $sth = $this->db->prepare($query);
258 258
                         $sth->execute(array(':id' => $id));
259
-                } catch(PDOException $e) {
259
+                } catch (PDOException $e) {
260 260
                         echo $e->getMessage();
261 261
                         die;
262 262
                 }
@@ -277,12 +277,12 @@  discard block
 block discarded – undo
277 277
                 date_default_timezone_set('UTC');
278 278
 
279 279
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
280
-                $query  = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
280
+                $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date";
281 281
 
282 282
                 try {
283 283
                         $sth = $this->db->prepare($query);
284 284
                         $sth->execute(array(':id' => $id));
285
-                } catch(PDOException $e) {
285
+                } catch (PDOException $e) {
286 286
                         echo $e->getMessage();
287 287
                         die;
288 288
                 }
@@ -304,13 +304,13 @@  discard block
 block discarded – undo
304 304
                 date_default_timezone_set('UTC');
305 305
 
306 306
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
307
-                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
307
+                $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1";
308 308
 //                $query  = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident";
309 309
 
310 310
                 try {
311 311
                         $sth = $this->db->prepare($query);
312 312
                         $sth->execute(array(':ident' => $ident));
313
-                } catch(PDOException $e) {
313
+                } catch (PDOException $e) {
314 314
                         echo $e->getMessage();
315 315
                         die;
316 316
                 }
@@ -327,12 +327,12 @@  discard block
 block discarded – undo
327 327
         * @return Array the spotter information
328 328
         *
329 329
         */
330
-	public function getMarineArchiveData($ident,$fammarine_id,$date)
330
+	public function getMarineArchiveData($ident, $fammarine_id, $date)
331 331
 	{
332 332
 		$Marine = new Marine($this->db);
333 333
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
334 334
 		$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate";
335
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%'));
335
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%'));
336 336
 		return $spotter_array;
337 337
 	}
338 338
 
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 		try {
352 352
 			$sth = $this->db->prepare($query);
353 353
 			$sth->execute();
354
-		} catch(PDOException $e) {
354
+		} catch (PDOException $e) {
355 355
 			echo $e->getMessage();
356 356
 			die;
357 357
 		}
@@ -363,24 +363,24 @@  discard block
 block discarded – undo
363 363
         * @return Array the spotter information
364 364
         *
365 365
         */
366
-        public function getMinLiveMarineData($begindate,$enddate,$filter = array())
366
+        public function getMinLiveMarineData($begindate, $enddate, $filter = array())
367 367
         {
368 368
                 global $globalDBdriver, $globalLiveInterval;
369 369
                 date_default_timezone_set('UTC');
370 370
 
371 371
                 $filter_query = '';
372 372
                 if (isset($filter['source']) && !empty($filter['source'])) {
373
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
373
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
374 374
                 }
375 375
                 // Use spotter_output also ?
376 376
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
377
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
377
+                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
378 378
                 }
379 379
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
380 380
                         $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
381 381
                 }
382 382
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
383
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
383
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
384 384
                 }
385 385
 
386 386
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -399,14 +399,14 @@  discard block
 block discarded – undo
399 399
 						GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id 
400 400
 				    AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
401 401
 */
402
-			$query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
402
+			$query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
403 403
 				    FROM marine_archive 
404 404
 				    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
405 405
 				    WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
406 406
                         	    '.$filter_query.' ORDER BY fammarine_id';
407 407
                 } else {
408 408
                         //$query  = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao';
409
-                        $query  = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
409
+                        $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
410 410
                         	    FROM marine_archive 
411 411
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao
412 412
                         	    WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".'
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
                 try {
417 417
                         $sth = $this->db->prepare($query);
418 418
                         $sth->execute();
419
-                } catch(PDOException $e) {
419
+                } catch (PDOException $e) {
420 420
                         echo $e->getMessage();
421 421
                         die;
422 422
                 }
@@ -431,24 +431,24 @@  discard block
 block discarded – undo
431 431
         * @return Array the spotter information
432 432
         *
433 433
         */
434
-        public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array())
434
+        public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array())
435 435
         {
436 436
                 global $globalDBdriver, $globalLiveInterval;
437 437
                 date_default_timezone_set('UTC');
438 438
 
439 439
                 $filter_query = '';
440 440
                 if (isset($filter['source']) && !empty($filter['source'])) {
441
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
441
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
442 442
                 }
443 443
                 // Should use spotter_output also ?
444 444
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
445
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
445
+                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
446 446
                 }
447 447
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
448 448
                         $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
449 449
                 }
450 450
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
451
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
451
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
452 452
                 }
453 453
 
454 454
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
                     		    FROM marine_archive 
459 459
                     		    INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao';
460 460
 			*/
461
-			$query  = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk 
461
+			$query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk 
462 462
 				    FROM marine_archive_output 
463 463
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao 
464 464
 				    WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
474 474
                         	    '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow';
475 475
                         */
476
-                        $query  = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
476
+                        $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow
477 477
                         	    FROM marine_archive_output 
478 478
                         	    INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao
479 479
                         	    WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".'
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
                 try {
486 486
                         $sth = $this->db->prepare($query);
487 487
                         $sth->execute();
488
-                } catch(PDOException $e) {
488
+                } catch (PDOException $e) {
489 489
                         echo $e->getMessage();
490 490
                         die;
491 491
                 }
@@ -500,23 +500,23 @@  discard block
 block discarded – undo
500 500
         * @return Array the spotter information
501 501
         *
502 502
         */
503
-        public function getLiveMarineCount($begindate,$enddate,$filter = array())
503
+        public function getLiveMarineCount($begindate, $enddate, $filter = array())
504 504
         {
505 505
                 global $globalDBdriver, $globalLiveInterval;
506 506
                 date_default_timezone_set('UTC');
507 507
 
508 508
                 $filter_query = '';
509 509
                 if (isset($filter['source']) && !empty($filter['source'])) {
510
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
510
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
511 511
                 }
512 512
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
513
-                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
513
+                        $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id ";
514 514
                 }
515 515
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
516 516
                         $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id ";
517 517
                 }
518 518
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
519
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
519
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
520 520
                 }
521 521
 
522 522
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
                 try {
532 532
                         $sth = $this->db->prepare($query);
533 533
                         $sth->execute();
534
-                } catch(PDOException $e) {
534
+                } catch (PDOException $e) {
535 535
                         echo $e->getMessage();
536 536
                         die;
537 537
                 }
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
     * @return Array the spotter information
552 552
     *
553 553
     */
554
-    public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
554
+    public function searchMarineData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
555 555
     {
556 556
 	global $globalTimezone, $globalDBdriver;
557 557
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 	        
574 574
 		$q_array = explode(" ", $q);
575 575
 		
576
-		foreach ($q_array as $q_item){
576
+		foreach ($q_array as $q_item) {
577 577
 		    $additional_query .= " AND (";
578 578
 		    $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR ";
579 579
 		    $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 	
606 606
 	if ($registration != "")
607 607
 	{
608
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
608
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
609 609
 	    if (!is_string($registration))
610 610
 	    {
611 611
 		return false;
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 	
617 617
 	if ($aircraft_icao != "")
618 618
 	{
619
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
619
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
620 620
 	    if (!is_string($aircraft_icao))
621 621
 	    {
622 622
 		return false;
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 	
628 628
 	if ($aircraft_manufacturer != "")
629 629
 	{
630
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
630
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
631 631
 	    if (!is_string($aircraft_manufacturer))
632 632
 	    {
633 633
 		return false;
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 	
649 649
 	if ($airline_icao != "")
650 650
 	{
651
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
651
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
652 652
 	    if (!is_string($airline_icao))
653 653
 	    {
654 654
 		return false;
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 	
660 660
 	if ($airline_country != "")
661 661
 	{
662
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
662
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
663 663
 	    if (!is_string($airline_country))
664 664
 	    {
665 665
 		return false;
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 	
671 671
 	if ($airline_type != "")
672 672
 	{
673
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
673
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
674 674
 	    if (!is_string($airline_type))
675 675
 	    {
676 676
 		return false;
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 	
693 693
 	if ($airport != "")
694 694
 	{
695
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
695
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
696 696
 	    if (!is_string($airport))
697 697
 	    {
698 698
 		return false;
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 	
704 704
 	if ($airport_country != "")
705 705
 	{
706
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
706
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
707 707
 	    if (!is_string($airport_country))
708 708
 	    {
709 709
 		return false;
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
     
715 715
 	if ($callsign != "")
716 716
 	{
717
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
717
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
718 718
 	    if (!is_string($callsign))
719 719
 	    {
720 720
 		return false;
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 		$translate = $Translation->ident2icao($callsign);
723 723
 		if ($translate != $callsign) {
724 724
 			$additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)";
725
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
725
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
726 726
 		} else {
727 727
 			$additional_query .= " AND (marine_archive_output.ident = '".$callsign."')";
728 728
 		}
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
 
732 732
 	if ($owner != "")
733 733
 	{
734
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
734
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
735 735
 	    if (!is_string($owner))
736 736
 	    {
737 737
 		return false;
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 
743 743
 	if ($pilot_name != "")
744 744
 	{
745
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
745
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
746 746
 	    if (!is_string($pilot_name))
747 747
 	    {
748 748
 		return false;
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 	
754 754
 	if ($pilot_id != "")
755 755
 	{
756
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
756
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
757 757
 	    if (!is_string($pilot_id))
758 758
 	    {
759 759
 		return false;
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 	
765 765
 	if ($departure_airport_route != "")
766 766
 	{
767
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
767
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
768 768
 	    if (!is_string($departure_airport_route))
769 769
 	    {
770 770
 		return false;
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
 	
776 776
 	if ($arrival_airport_route != "")
777 777
 	{
778
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
778
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
779 779
 	    if (!is_string($arrival_airport_route))
780 780
 	    {
781 781
 		return false;
@@ -788,8 +788,8 @@  discard block
 block discarded – undo
788 788
 	{
789 789
 	    $altitude_array = explode(",", $altitude);
790 790
 	    
791
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
792
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
791
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
792
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
793 793
 	    
794 794
 
795 795
 	    if ($altitude_array[1] != "")
@@ -807,8 +807,8 @@  discard block
 block discarded – undo
807 807
 	{
808 808
 	    $date_array = explode(",", $date_posted);
809 809
 	    
810
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
811
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
810
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
811
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
812 812
 	    
813 813
 	    if ($globalTimezone != '') {
814 814
 		date_default_timezone_set($globalTimezone);
@@ -840,8 +840,8 @@  discard block
 block discarded – undo
840 840
 	{
841 841
 	    $limit_array = explode(",", $limit);
842 842
 	    
843
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
844
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
843
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
844
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
845 845
 	    
846 846
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
847 847
 	    {
@@ -852,8 +852,8 @@  discard block
 block discarded – undo
852 852
 	
853 853
 
854 854
 	if ($origLat != "" && $origLon != "" && $dist != "") {
855
-		$dist = number_format($dist*0.621371,2,'.','');
856
-		$query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
855
+		$dist = number_format($dist*0.621371, 2, '.', '');
856
+		$query = "SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
857 857
                           FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
858 858
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
859 859
 	} else {
@@ -870,12 +870,12 @@  discard block
 block discarded – undo
870 870
 			$additional_query .= " AND (marine_archive_output.waypoints <> '')";
871 871
 		}
872 872
 
873
-		$query  = "SELECT marine_archive_output.* FROM marine_archive_output 
873
+		$query = "SELECT marine_archive_output.* FROM marine_archive_output 
874 874
 		    WHERE marine_archive_output.ident <> '' 
875 875
 		    ".$additional_query."
876 876
 		    ".$filter_query.$orderby_query;
877 877
 	}
878
-	$spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query);
878
+	$spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query);
879 879
 
880 880
 	return $spotter_array;
881 881
     }
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
                 try {
893 893
                         $sth = $this->db->prepare($query);
894 894
                         $sth->execute();
895
-                } catch(PDOException $e) {
895
+                } catch (PDOException $e) {
896 896
                         return "error";
897 897
                 }
898 898
 	}
@@ -929,8 +929,8 @@  discard block
 block discarded – undo
929 929
 	{
930 930
 	    $limit_array = explode(",", $limit);
931 931
 	    
932
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
933
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
932
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
933
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
934 934
 	    
935 935
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
936 936
 	    {
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
 	$query_values = array();
972 972
 	$limit_query = '';
973 973
 	$additional_query = '';
974
-	$filter_query = $this->getFilter($filter,true,true);
974
+	$filter_query = $this->getFilter($filter, true, true);
975 975
 	
976 976
 	if ($owner != "")
977 977
 	{
@@ -988,8 +988,8 @@  discard block
 block discarded – undo
988 988
 	{
989 989
 	    $limit_array = explode(",", $limit);
990 990
 	    
991
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
992
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
991
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
992
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
993 993
 	    
994 994
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
995 995
 	    {
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
 	$query_values = array();
1030 1030
 	$limit_query = '';
1031 1031
 	$additional_query = '';
1032
-	$filter_query = $this->getFilter($filter,true,true);
1032
+	$filter_query = $this->getFilter($filter, true, true);
1033 1033
 	
1034 1034
 	if ($pilot != "")
1035 1035
 	{
@@ -1041,8 +1041,8 @@  discard block
 block discarded – undo
1041 1041
 	{
1042 1042
 	    $limit_array = explode(",", $limit);
1043 1043
 	    
1044
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1045
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1044
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1045
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1046 1046
 	    
1047 1047
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1048 1048
 	    {
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
     * @return Array the airline country list
1073 1073
     *
1074 1074
     */
1075
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1075
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1076 1076
     {
1077 1077
 	global $globalDBdriver;
1078 1078
 	/*
@@ -1101,7 +1101,7 @@  discard block
 block discarded – undo
1101 1101
 	$flight_array = array();
1102 1102
 	$temp_array = array();
1103 1103
         
1104
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1104
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1105 1105
 	{
1106 1106
 	    $temp_array['flight_count'] = $row['nb'];
1107 1107
 	    $temp_array['flight_country'] = $row['name'];
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
     * @return Array the airline country list
1119 1119
     *
1120 1120
     */
1121
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1121
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1122 1122
     {
1123 1123
 	global $globalDBdriver;
1124 1124
 	/*
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
 	$flight_array = array();
1148 1148
 	$temp_array = array();
1149 1149
         
1150
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1150
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1151 1151
 	{
1152 1152
 	    $temp_array['airline_icao'] = $row['airline_icao'];
1153 1153
 	    $temp_array['flight_count'] = $row['nb'];
@@ -1165,14 +1165,14 @@  discard block
 block discarded – undo
1165 1165
     * @return Array the spotter information
1166 1166
     *
1167 1167
     */
1168
-    public function getDateArchiveMarineDataById($id,$date)
1168
+    public function getDateArchiveMarineDataById($id, $date)
1169 1169
     {
1170 1170
 	$Marine = new Marine($this->db);
1171 1171
 	date_default_timezone_set('UTC');
1172 1172
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1173 1173
 	$query  = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC';
1174
-	$date = date('c',$date);
1175
-	$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date));
1174
+	$date = date('c', $date);
1175
+	$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1176 1176
 	return $spotter_array;
1177 1177
     }
1178 1178
 
@@ -1182,14 +1182,14 @@  discard block
 block discarded – undo
1182 1182
     * @return Array the spotter information
1183 1183
     *
1184 1184
     */
1185
-    public function getDateArchiveMarineDataByIdent($ident,$date)
1185
+    public function getDateArchiveMarineDataByIdent($ident, $date)
1186 1186
     {
1187 1187
 	$Marine = new Marine($this->db);
1188 1188
 	date_default_timezone_set('UTC');
1189 1189
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1190 1190
 	$query  = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC';
1191
-	$date = date('c',$date);
1192
-	$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1191
+	$date = date('c', $date);
1192
+	$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1193 1193
 	return $spotter_array;
1194 1194
     }
1195 1195
 
@@ -1199,7 +1199,7 @@  discard block
 block discarded – undo
1199 1199
     * @return Array the spotter information
1200 1200
     *
1201 1201
     */
1202
-    public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1202
+    public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1203 1203
     {
1204 1204
 	global $global_query;
1205 1205
 	$Marine = new Marine($this->db);
@@ -1207,7 +1207,7 @@  discard block
 block discarded – undo
1207 1207
 	$query_values = array();
1208 1208
 	$limit_query = '';
1209 1209
 	$additional_query = '';
1210
-	$filter_query = $this->getFilter($filters,true,true);
1210
+	$filter_query = $this->getFilter($filters, true, true);
1211 1211
 	
1212 1212
 	if ($airport != "")
1213 1213
 	{
@@ -1224,8 +1224,8 @@  discard block
 block discarded – undo
1224 1224
 	{
1225 1225
 	    $limit_array = explode(",", $limit);
1226 1226
 	    
1227
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1228
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1227
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1228
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1229 1229
 	    
1230 1230
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1231 1231
 	    {
Please login to merge, or discard this patch.
ident.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $ident = '';
4
-if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING);
5
-if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
4
+if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST, 'ident', FILTER_SANITIZE_STRING);
5
+if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
6 6
 if ($ident != '')
7 7
 {
8 8
 	if (isset($_GET['marine'])) header('Location: '.$globalURL.'/marine/ident/'.$ident);
Please login to merge, or discard this patch.
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,13 +1,20 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $ident = '';
4
-if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING);
5
-if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
4
+if (isset($_POST['ident'])) {
5
+	$ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING);
6
+}
7
+if (isset($_GET['ident'])) {
8
+	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
9
+}
6 10
 if ($ident != '')
7 11
 {
8
-	if (isset($_GET['marine'])) header('Location: '.$globalURL.'/marine/ident/'.$ident);
9
-	else header('Location: '.$globalURL.'/ident/'.$ident);
10
-} else {
12
+	if (isset($_GET['marine'])) {
13
+		header('Location: '.$globalURL.'/marine/ident/'.$ident);
14
+	} else {
15
+		header('Location: '.$globalURL.'/ident/'.$ident);
16
+	}
17
+	} else {
11 18
 	if ($globalURL == '') {
12 19
 		header('Location: /');
13 20
 	} else {
Please login to merge, or discard this patch.
currently.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,21 +4,21 @@  discard block
 block discarded – undo
4 4
 
5 5
 $type = '';
6 6
 if (isset($_GET['marine'])) {
7
-	require_once('require/class.Marine.php');;
7
+	require_once('require/class.Marine.php'); ;
8 8
 	require_once('require/class.MarineLive.php');
9
-	$MarineLive=new MarineLive();
9
+	$MarineLive = new MarineLive();
10 10
 	$type = 'marine';
11 11
 	$page_url = $globalURL.'/marine/currently';
12 12
 } elseif (isset($_GET['tracker'])) {
13
-	require_once('require/class.Tracker.php');;
13
+	require_once('require/class.Tracker.php'); ;
14 14
 	require_once('require/class.TrackerLive.php');
15
-	$TrackerLive=new TrackerLive();
15
+	$TrackerLive = new TrackerLive();
16 16
 	$type = 'tracker';
17 17
 	$page_url = $globalURL.'/tracker/currently';
18 18
 } else {
19
-	require_once('require/class.Spotter.php');;
19
+	require_once('require/class.Spotter.php'); ;
20 20
 	require_once('require/class.SpotterLive.php');
21
-	$SpotterLive=new SpotterLive();
21
+	$SpotterLive = new SpotterLive();
22 22
 	$type = 'aircraft';
23 23
 	$page_url = $globalURL.'/currently';
24 24
 }
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
 $title = "Current Activity";
27 27
 require_once('header.php');
28 28
 //calculuation for the pagination
29
-if(!isset($_GET['limit']))
29
+if (!isset($_GET['limit']))
30 30
 {
31 31
 	$limit_start = 0;
32 32
 	$limit_end = 25;
33 33
 	$absolute_difference = 25;
34
-}  else {
34
+} else {
35 35
 	$limit_explode = explode(",", $_GET['limit']);
36 36
 	$limit_start = $limit_explode[0];
37 37
 	$limit_end = $limit_explode[1];
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 elseif ($type == 'marine') print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>';
55 55
 elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>';
56 56
 
57
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
57
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
58 58
 if ($sort != '') {
59 59
 	if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort);
60 60
 	elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort);
Please login to merge, or discard this patch.
Braces   +24 added lines, -12 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	$limit_start = 0;
32 32
 	$limit_end = 25;
33 33
 	$absolute_difference = 25;
34
-}  else {
34
+} else {
35 35
 	$limit_explode = explode(",", $_GET['limit']);
36 36
 	$limit_start = $limit_explode[0];
37 37
 	$limit_end = $limit_explode[1];
@@ -50,20 +50,32 @@  discard block
 block discarded – undo
50 50
 print '</div>';
51 51
 
52 52
 print '<div class="table column">';
53
-if ($type == 'aircraft') print '<p>'._("The table below shows the detailed information of all current flights.").'</p>';
54
-elseif ($type == 'marine') print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>';
55
-elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>';
53
+if ($type == 'aircraft') {
54
+	print '<p>'._("The table below shows the detailed information of all current flights.").'</p>';
55
+} elseif ($type == 'marine') {
56
+	print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>';
57
+} elseif ($type == 'tracker') {
58
+	print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>';
59
+}
56 60
 
57 61
 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
58 62
 if ($sort != '') {
59
-	if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort);
60
-	elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort);
61
-	elseif ($type == 'tracker') $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference, $sort);
62
-} else {
63
-	if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference);
64
-	elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference);
65
-	elseif ($type == 'tracker') $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference);
66
-}
63
+	if ($type == 'aircraft') {
64
+		$spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort);
65
+	} elseif ($type == 'marine') {
66
+		$spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort);
67
+	} elseif ($type == 'tracker') {
68
+		$spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference, $sort);
69
+	}
70
+	} else {
71
+	if ($type == 'aircraft') {
72
+		$spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference);
73
+	} elseif ($type == 'marine') {
74
+		$spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference);
75
+	} elseif ($type == 'tracker') {
76
+		$spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference);
77
+	}
78
+	}
67 79
 
68 80
 if (!empty($spotter_array))
69 81
 {
Please login to merge, or discard this patch.
date.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@
 block discarded – undo
3 3
 $type = 'aircraft';
4 4
 if (isset($_GET['marine'])) $type = 'marine';
5 5
 elseif (isset($_GET['tracker'])) $type = 'tracker';
6
-$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
6
+$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING);
7 7
 if ($date == '') $date = date('Y-m-d');
8 8
 if ($type == 'marine') header('Location: '.$globalURL.'/marine/date/'.$date);
9 9
 elseif ($type == 'tracker') header('Location: '.$globalURL.'/tracker/date/'.$date);
Please login to merge, or discard this patch.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,11 +1,20 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $type = 'aircraft';
4
-if (isset($_GET['marine'])) $type = 'marine';
5
-elseif (isset($_GET['tracker'])) $type = 'tracker';
4
+if (isset($_GET['marine'])) {
5
+	$type = 'marine';
6
+} elseif (isset($_GET['tracker'])) {
7
+	$type = 'tracker';
8
+}
6 9
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
7
-if ($date == '') $date = date('Y-m-d');
8
-if ($type == 'marine') header('Location: '.$globalURL.'/marine/date/'.$date);
9
-elseif ($type == 'tracker') header('Location: '.$globalURL.'/tracker/date/'.$date);
10
-else header('Location: '.$globalURL.'/date/'.$date);
10
+if ($date == '') {
11
+	$date = date('Y-m-d');
12
+}
13
+if ($type == 'marine') {
14
+	header('Location: '.$globalURL.'/marine/date/'.$date);
15
+} elseif ($type == 'tracker') {
16
+	header('Location: '.$globalURL.'/tracker/date/'.$date);
17
+} else {
18
+	header('Location: '.$globalURL.'/date/'.$date);
19
+}
11 20
 ?>
12 21
\ No newline at end of file
Please login to merge, or discard this patch.