Completed
Push — master ( e17801...597a61 )
by Yannick
25:55
created
registration-statistics-arrival-airport-country.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -3,17 +3,17 @@  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
-$registration = filter_input(INPUT_GET,'registration',FILTER_SANITIZE_STRING);
6
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
7
+$registration = filter_input(INPUT_GET, 'registration', FILTER_SANITIZE_STRING);
8 8
 if ($registration != '') {
9 9
 	$spotter_array = $Spotter->getSpotterDataByRegistration($registration, "0,1", $sort);
10 10
 	$aircraft_array = $Spotter->getAircraftInfoByRegistration($registration);
11
-} else $spotter_array=array();
11
+} else $spotter_array = array();
12 12
 
13 13
 
14 14
 if (!empty($spotter_array))
15 15
 {
16
-	$title = sprintf(_("Most Common Arrival Airports by Country of aircraft with registration %s"),$registration);
16
+	$title = sprintf(_("Most Common Arrival Airports by Country of aircraft with registration %s"), $registration);
17 17
 	require_once('header.php');
18 18
 	print '<div class="info column">';
19 19
 	print '<h1>'.$_GET['registration'].' - '.$aircraft_array[0]['aircraft_name'].' ('.$aircraft_array[0]['aircraft_icao'].')</h1>';
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	include('registration-sub-menu.php');
26 26
 	print '<div class="column">';
27 27
 	print '<h2>'._("Most Common Arrival Airports by Country").'</h2>';
28
-	print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights with aircraft registration <strong>%s</strong>."),$registration).'</p>';
28
+	print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights with aircraft registration <strong>%s</strong>."), $registration).'</p>';
29 29
 	$airport_country_array = $Spotter->countAllArrivalAirportCountriesByRegistration($registration);
30 30
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
31 31
 	print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
34 34
 	print 'var series = [';
35 35
 	$country_data = '';
36
-	foreach($airport_country_array as $airport_item)
36
+	foreach ($airport_country_array as $airport_item)
37 37
 	{
38 38
 		$country_data .= '[ "'.$airport_item['arrival_airport_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],';
39 39
 	}
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		print '</thead>';
82 82
 		print '<tbody>';
83 83
 		$i = 1;
84
-		foreach($airport_country_array as $airport_item)
84
+		foreach ($airport_country_array as $airport_item)
85 85
 		{
86 86
 			print '<tr>';
87 87
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
manufacturer-statistics-arrival-airport-country.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@  discard block
 block discarded – undo
9 9
 }
10 10
 
11 11
 $Spotter = new Spotter();
12
-$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING)));
13
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
14
-$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,"0,1", $sort);
12
+$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'aircraft_manufacturer', FILTER_SANITIZE_STRING)));
13
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
14
+$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, "0,1", $sort);
15 15
 
16 16
 if (!empty($spotter_array))
17 17
 {
18
-	$title = sprintf(_("Most Common Arrival Airports by Country from %s"),$manufacturer);
18
+	$title = sprintf(_("Most Common Arrival Airports by Country from %s"), $manufacturer);
19 19
 
20 20
 	require_once('header.php');
21 21
 	print '<div class="select-item">';
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
 	$Stats = new Stats();
25 25
 	$all_manufacturers = $Stats->getAllManufacturers();
26 26
 	if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers();
27
-	foreach($all_manufacturers as $all_manufacturer)
27
+	foreach ($all_manufacturers as $all_manufacturer)
28 28
 	{
29
-		if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
29
+		if ($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
30 30
 		{
31 31
 			print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>';
32 32
 		} else {
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	include('manufacturer-sub-menu.php');
46 46
 	print '<div class="column">';
47 47
 	print '<h2>'._("Most Common Arrival Airports by Country").'</h2>';
48
-	print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights from <strong>%s</strong>."),$manufacturer).'</p>';
48
+	print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights from <strong>%s</strong>."), $manufacturer).'</p>';
49 49
 	$airport_country_array = $Spotter->countAllArrivalAirportCountriesByManufacturer($manufacturer);
50 50
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
51 51
 	print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>'; 
54 54
 	print 'var series = [';
55 55
 	$country_data = '';
56
-	foreach($airport_country_array as $airport_item)
56
+	foreach ($airport_country_array as $airport_item)
57 57
 	{
58 58
 		$country_data .= '[ "'.$airport_item['arrival_airport_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],';
59 59
 	}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 		print '</thead>';
102 102
 		print '<tbody>';
103 103
 		$i = 1;
104
-		foreach($airport_country_array as $airport_item)
104
+		foreach ($airport_country_array as $airport_item)
105 105
 		{
106 106
 			print '<tr>';
107 107
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
registration-statistics-departure-airport-country.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3,16 +3,16 @@  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);
6
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
7 7
 if (isset($_GET['registration'])) {
8
-	$registration = filter_input(INPUT_GET,'registration',FILTER_SANITIZE_STRING);
8
+	$registration = filter_input(INPUT_GET, 'registration', FILTER_SANITIZE_STRING);
9 9
 	$spotter_array = $Spotter->getSpotterDataByRegistration($registration, "0,1", $sort);
10 10
 	$aircraft_array = $Spotter->getAircraftInfoByRegistration($registration);
11 11
 } else $spotter_array = array();
12 12
 
13 13
 if (!empty($spotter_array))
14 14
 {
15
-	$title = sprintf(_("Most Common Departure Airports by Country of aircraft with registration %s"),$registration);
15
+	$title = sprintf(_("Most Common Departure Airports by Country of aircraft with registration %s"), $registration);
16 16
 	require_once('header.php');
17 17
 	print '<div class="info column">';
18 18
 	print '<h1>'.$registration.' - '.$aircraft_array[0]['aircraft_name'].' ('.$aircraft_array[0]['aircraft_icao'].')</h1>';
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	include('registration-sub-menu.php');
25 25
 	print '<div class="column">';
26 26
 	print '<h2>'._("Most Common Departure Airports by Country").'</h2>';
27
-	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights with aircraft registration <strong>%s</strong>."),$registration).'</p>';
27
+	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights with aircraft registration <strong>%s</strong>."), $registration).'</p>';
28 28
 	$airport_country_array = $Spotter->countAllDepartureAirportCountriesByRegistration($registration);
29 29
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
30 30
 	print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
33 33
 	print 'var series = [';
34 34
 	$country_data = '';
35
-	foreach($airport_country_array as $airport_item)
35
+	foreach ($airport_country_array as $airport_item)
36 36
 	{
37 37
 		$country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],';
38 38
 	}
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		print '</thead>';
81 81
 		print '<tbody>';
82 82
 		$i = 1;
83
-		foreach($airport_country_array as $airport_item)
83
+		foreach ($airport_country_array as $airport_item)
84 84
 		{
85 85
 			print '<tr>';
86 86
 			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.
manufacturer-statistics-departure-airport-country.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -8,13 +8,13 @@  discard block
 block discarded – undo
8 8
         die();
9 9
 }
10 10
 $Spotter = new Spotter();
11
-$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING)));
12
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
13
-$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,"0,1", $sort);
11
+$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'aircraft_manufacturer', FILTER_SANITIZE_STRING)));
12
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
13
+$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, "0,1", $sort);
14 14
 
15 15
 if (!empty($spotter_array))
16 16
 {
17
-	$title = sprintf(_("'Most Common Departure Airports by Country from %s"),$manufacturer);
17
+	$title = sprintf(_("'Most Common Departure Airports by Country from %s"), $manufacturer);
18 18
 
19 19
 	require_once('header.php');
20 20
 	print '<div class="select-item">';
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
 	$Stats = new Stats();
24 24
 	$all_manufacturers = $Stats->getAllManufacturers();
25 25
 	if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers();
26
-	foreach($all_manufacturers as $all_manufacturer)
26
+	foreach ($all_manufacturers as $all_manufacturer)
27 27
 	{
28
-		if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
28
+		if ($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
29 29
 		{
30 30
 			print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>';
31 31
 		} else {
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 include('manufacturer-sub-menu.php');
45 45
 	print '<div class="column">';
46 46
 	print '<h2>'._("Most Common Departure Airports by Country").'</h2>';
47
-	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights from <strong>%s</strong>."),$manufacturer).'</p>';
47
+	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights from <strong>%s</strong>."), $manufacturer).'</p>';
48 48
 
49 49
 	$airport_country_array = $Spotter->countAllDepartureAirportCountriesByManufacturer($manufacturer);
50 50
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
54 54
 	print 'var series = [';
55 55
 	$country_data = '';
56
-	foreach($airport_country_array as $airport_item)
56
+	foreach ($airport_country_array as $airport_item)
57 57
 	{
58 58
 		$country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],';
59 59
 	}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 		print '</thead>';
102 102
 		print '<tbody>';
103 103
 		$i = 1;
104
-		foreach($airport_country_array as $airport_item)
104
+		foreach ($airport_country_array as $airport_item)
105 105
 		{
106 106
 			print '<tr>';
107 107
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
ident-statistics-departure-airport-country.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
         die();
8 8
 }
9 9
 $Spotter = new Spotter();
10
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
11
-$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
12
-$spotter_array = $Spotter->getSpotterDataByIdent($ident,"0,1", $sort);
10
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
11
+$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
12
+$spotter_array = $Spotter->getSpotterDataByIdent($ident, "0,1", $sort);
13 13
 
14 14
 if (!empty($spotter_array))
15 15
 {
16
-	$title = sprintf(_("Most Common Departure Airports by Country of %s"),$spotter_array[0]['ident']);
16
+	$title = sprintf(_("Most Common Departure Airports by Country of %s"), $spotter_array[0]['ident']);
17 17
 	require_once('header.php');
18 18
 	print '<div class="info column">';
19 19
 	print '<h1>'.$spotter_array[0]['ident'].'</h1>';
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	include('ident-sub-menu.php');
24 24
 	print '<div class="column">';
25 25
 	print '<h2>'._("Most Common Departure Airports by Country").'</h2>';
26
-	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights with the ident/callsign <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
26
+	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights with the ident/callsign <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>';
27 27
 
28 28
 	$airport_country_array = $Spotter->countAllDepartureAirportCountriesByIdent($ident);
29 29
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
33 33
 	print 'var series = [';
34 34
 	$country_data = '';
35
-	foreach($airport_country_array as $airport_item)
35
+	foreach ($airport_country_array as $airport_item)
36 36
 	{
37 37
 		$country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],';
38 38
 	}
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		print '</thead>';
81 81
 		print '<tbody>';
82 82
 		$i = 1;
83
-		foreach($airport_country_array as $airport_item)
83
+		foreach ($airport_country_array as $airport_item)
84 84
 		{
85 85
 			print '<tr>';
86 86
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
airport-geojson.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 if (isset($_GET['coord'])) 
13 13
 {
14
-	$coords = explode(',',$_GET['coord']);
14
+	$coords = explode(',', $_GET['coord']);
15 15
 	$spotter_array = $Spotter->getAllAirportInfobyCoord($coords);
16 16
 } else {
17 17
 	$spotter_array = $Spotter->getAllAirportInfo();
@@ -22,17 +22,17 @@  discard block
 block discarded – undo
22 22
             
23 23
 if (!empty($spotter_array))
24 24
 {	  
25
-	foreach($spotter_array as $spotter_item)
25
+	foreach ($spotter_array as $spotter_item)
26 26
 	{
27 27
 		date_default_timezone_set('UTC');
28 28
 		//waypoint plotting
29 29
 		$output .= '{"type": "Feature",';
30 30
 		    $output .= '"properties": {';
31
-			$output .= '"name": "'.str_replace('"',"'",$spotter_item['name']).'",';
32
-			$output .= '"city": "'.str_replace('"',"'",$spotter_item['city']).'",';
31
+			$output .= '"name": "'.str_replace('"', "'", $spotter_item['name']).'",';
32
+			$output .= '"city": "'.str_replace('"', "'", $spotter_item['city']).'",';
33 33
 			$output .= '"country": "'.$spotter_item['country'].'",';
34 34
 			$output .= '"altitude": "'.$spotter_item['altitude'].'",';
35
-			$output .= '"popupContent": "'.str_replace('"',"'",$spotter_item['name']).' : '.str_replace('"',"'",$spotter_item['city']).', '.$spotter_item['country'].'",';
35
+			$output .= '"popupContent": "'.str_replace('"', "'", $spotter_item['name']).' : '.str_replace('"', "'", $spotter_item['city']).', '.$spotter_item['country'].'",';
36 36
 			if ($spotter_item['type'] == 'large_airport') {
37 37
 				$output .= '"icon": "'.$globalURL.'/images/airport.png",';
38 38
 			} elseif ($spotter_item['type'] == 'heliport') {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		    $output .= '}';
60 60
 		$output .= '},';
61 61
 	}
62
-	$output  = substr($output, 0, -1);
62
+	$output = substr($output, 0, -1);
63 63
 }
64 64
 $output .= ']}';
65 65
 print $output;
Please login to merge, or discard this patch.
require/class.MarineLive.php 1 patch
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
 	* @param Array $filter the filter
17 17
 	* @return Array the SQL part
18 18
 	*/
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
37 37
 				if (isset($flt['source'])) {
38
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
38
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
39 39
 				} else {
40
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
40
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
41 41
 				}
42 42
 			}
43 43
 		}
44 44
 		if (isset($filter['source']) && !empty($filter['source'])) {
45
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
45
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
46 46
 		}
47 47
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
48 48
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
 					$filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
72 72
 				}
73 73
 			}
74
-			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
74
+			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
75 75
 		}
76 76
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
77
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
78 78
 		}
79 79
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80 80
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81 81
 		if ($filter_query_where != '') {
82
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
82
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
83 83
 		}
84 84
 		$filter_query = $filter_query_join.$filter_query_where;
85 85
 		return $filter_query;
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 		if ($limit != '')
103 103
 		{
104 104
 			$limit_array = explode(',', $limit);
105
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
106
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
105
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
106
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
107 107
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
108 108
 			{
109 109
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
119 119
 			}
120 120
 		}
121
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
121
+		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
122 122
 
123 123
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
124 124
 		if ($globalDBdriver == 'mysql') {
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		} else {
128 128
 			$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query;
129 129
 		}
130
-		$spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true);
130
+		$spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true);
131 131
 
132 132
 		return $spotter_array;
133 133
 	}
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		global $globalDBdriver, $globalLiveInterval;
144 144
 		date_default_timezone_set('UTC');
145 145
 
146
-		$filter_query = $this->getFilter($filter,true,true);
146
+		$filter_query = $this->getFilter($filter, true, true);
147 147
 
148 148
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
149 149
 		if ($globalDBdriver == 'mysql') {
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		try {
158 158
 			$sth = $this->db->prepare($query);
159 159
 			$sth->execute();
160
-		} catch(PDOException $e) {
160
+		} catch (PDOException $e) {
161 161
 			echo $e->getMessage();
162 162
 			die;
163 163
 		}
@@ -177,15 +177,15 @@  discard block
 block discarded – undo
177 177
 		global $globalDBdriver, $globalLiveInterval;
178 178
 		date_default_timezone_set('UTC');
179 179
 
180
-		$filter_query = $this->getFilter($filter,true,true);
180
+		$filter_query = $this->getFilter($filter, true, true);
181 181
 
182 182
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
183 183
 		if ($globalDBdriver == 'mysql') {
184
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
184
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
185 185
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
186 186
 			ORDER BY marine_live.fammarine_id, marine_live.date";
187 187
                 } else {
188
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
188
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
189 189
 			FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
190 190
 			ORDER BY marine_live.fammarine_id, marine_live.date";
191 191
 		}
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     		try {
194 194
 			$sth = $this->db->prepare($query);
195 195
 			$sth->execute();
196
-		} catch(PDOException $e) {
196
+		} catch (PDOException $e) {
197 197
 			echo $e->getMessage();
198 198
 			die;
199 199
 		}
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	public function getLiveMarineCount($filter = array())
211 211
 	{
212 212
 		global $globalDBdriver, $globalLiveInterval;
213
-		$filter_query = $this->getFilter($filter,true,true);
213
+		$filter_query = $this->getFilter($filter, true, true);
214 214
 
215 215
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
216 216
 		if ($globalDBdriver == 'mysql') {
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		try {
222 222
 			$sth = $this->db->prepare($query);
223 223
 			$sth->execute();
224
-		} catch(PDOException $e) {
224
+		} catch (PDOException $e) {
225 225
 			echo $e->getMessage();
226 226
 			die;
227 227
 		}
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
 		$filter_query = $this->getFilter($filter);
245 245
 
246 246
 		if (is_array($coord)) {
247
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
248
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
249
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
250
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
247
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
248
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
249
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
250
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
251 251
 		} else return array();
252 252
 		if ($globalDBdriver == 'mysql') {
253 253
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query;
@@ -272,17 +272,17 @@  discard block
 block discarded – undo
272 272
 		$filter_query = $this->getFilter($filter);
273 273
 
274 274
 		if (is_array($coord)) {
275
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
276
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
277
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
278
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
275
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
276
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
277
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
278
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
279 279
 		} else return array();
280 280
 		if ($globalDBdriver == 'mysql') {
281 281
 			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
282 282
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
283 283
 			ORDER BY marine_live.fammarine_id, marine_live.date";
284 284
 		} else {
285
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
285
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
286 286
 			FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong."
287 287
 			ORDER BY marine_live.fammarine_id, marine_live.date";
288 288
 		}
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
                 if ($interval == '1m')
332 332
                 {
333 333
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
334
-                } else if ($interval == '15m'){
334
+                } else if ($interval == '15m') {
335 335
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
336 336
                 } 
337 337
             }
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
340 340
         }
341 341
 
342
-                $query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
342
+                $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
343 343
                    WHERE marine_live.latitude <> '' 
344 344
                                    AND marine_live.longitude <> '' 
345 345
                    ".$additional_query."
346 346
                    HAVING distance < :radius  
347 347
                                    ORDER BY distance";
348 348
 
349
-                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
349
+                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
350 350
 
351 351
                 return $spotter_array;
352 352
         }
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
 		date_default_timezone_set('UTC');
365 365
 
366 366
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
367
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
367
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
368 368
 
369
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
369
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true);
370 370
 
371 371
 		return $spotter_array;
372 372
 	}
@@ -377,16 +377,16 @@  discard block
 block discarded – undo
377 377
 	* @return Array the spotter information
378 378
 	*
379 379
 	*/
380
-	public function getDateLiveMarineDataByIdent($ident,$date)
380
+	public function getDateLiveMarineDataByIdent($ident, $date)
381 381
 	{
382 382
 		$Marine = new Marine($this->db);
383 383
 		date_default_timezone_set('UTC');
384 384
 
385 385
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
386
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
386
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
387 387
 
388
-                $date = date('c',$date);
389
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
388
+                $date = date('c', $date);
389
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
390 390
 
391 391
 		return $spotter_array;
392 392
 	}
@@ -403,9 +403,9 @@  discard block
 block discarded – undo
403 403
 		date_default_timezone_set('UTC');
404 404
 
405 405
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
406
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
406
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
407 407
 
408
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
408
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true);
409 409
 
410 410
 		return $spotter_array;
411 411
 	}
@@ -416,15 +416,15 @@  discard block
 block discarded – undo
416 416
 	* @return Array the spotter information
417 417
 	*
418 418
 	*/
419
-	public function getDateLiveMarineDataById($id,$date)
419
+	public function getDateLiveMarineDataById($id, $date)
420 420
 	{
421 421
 		$Marine = new Marine($this->db);
422 422
 		date_default_timezone_set('UTC');
423 423
 
424 424
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
425
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
426
-                $date = date('c',$date);
427
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
425
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
426
+                $date = date('c', $date);
427
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
428 428
 
429 429
 		return $spotter_array;
430 430
 	}
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 	* @return Array the spotter information
437 437
 	*
438 438
 	*/
439
-	public function getAllLiveMarineDataById($id,$liveinterval = false)
439
+	public function getAllLiveMarineDataById($id, $liveinterval = false)
440 440
 	{
441 441
 		global $globalDBdriver, $globalLiveInterval;
442 442
 		date_default_timezone_set('UTC');
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 		try {
456 456
 			$sth = $this->db->prepare($query);
457 457
 			$sth->execute(array(':id' => $id));
458
-		} catch(PDOException $e) {
458
+		} catch (PDOException $e) {
459 459
 			echo $e->getMessage();
460 460
 			die;
461 461
 		}
@@ -473,12 +473,12 @@  discard block
 block discarded – undo
473 473
 	{
474 474
 		date_default_timezone_set('UTC');
475 475
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
476
-		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
476
+		$query = self::$global_query.' WHERE marine_live.ident = :ident';
477 477
     		try {
478 478
 			
479 479
 			$sth = $this->db->prepare($query);
480 480
 			$sth->execute(array(':ident' => $ident));
481
-		} catch(PDOException $e) {
481
+		} catch (PDOException $e) {
482 482
 			echo $e->getMessage();
483 483
 			die;
484 484
 		}
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 			
509 509
 			$sth = $this->db->prepare($query);
510 510
 			$sth->execute();
511
-		} catch(PDOException $e) {
511
+		} catch (PDOException $e) {
512 512
 			return "error";
513 513
 		}
514 514
 
@@ -531,14 +531,14 @@  discard block
 block discarded – undo
531 531
 				
532 532
 				$sth = $this->db->prepare($query);
533 533
 				$sth->execute();
534
-			} catch(PDOException $e) {
534
+			} catch (PDOException $e) {
535 535
 				return "error";
536 536
 			}
537 537
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
538 538
                         $i = 0;
539
-                        $j =0;
539
+                        $j = 0;
540 540
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
541
-			foreach($all as $row)
541
+			foreach ($all as $row)
542 542
 			{
543 543
 				$i++;
544 544
 				$j++;
@@ -546,9 +546,9 @@  discard block
 block discarded – undo
546 546
 					if ($globalDebug) echo ".";
547 547
 				    	try {
548 548
 						
549
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
549
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
550 550
 						$sth->execute();
551
-					} catch(PDOException $e) {
551
+					} catch (PDOException $e) {
552 552
 						return "error";
553 553
 					}
554 554
                                 	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
@@ -559,9 +559,9 @@  discard block
 block discarded – undo
559 559
 			if ($i > 0) {
560 560
     				try {
561 561
 					
562
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
562
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
563 563
 					$sth->execute();
564
-				} catch(PDOException $e) {
564
+				} catch (PDOException $e) {
565 565
 					return "error";
566 566
 				}
567 567
 			}
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 				
575 575
 				$sth = $this->db->prepare($query);
576 576
 				$sth->execute();
577
-			} catch(PDOException $e) {
577
+			} catch (PDOException $e) {
578 578
 				return "error";
579 579
 			}
580 580
 /*			$query_delete = "DELETE FROM marine_live WHERE fammarine_id IN (";
@@ -622,13 +622,13 @@  discard block
 block discarded – undo
622 622
 	public function deleteLiveMarineDataByIdent($ident)
623 623
 	{
624 624
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
625
-		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
625
+		$query = 'DELETE FROM marine_live WHERE ident = :ident';
626 626
         
627 627
     		try {
628 628
 			
629 629
 			$sth = $this->db->prepare($query);
630 630
 			$sth->execute(array(':ident' => $ident));
631
-		} catch(PDOException $e) {
631
+		} catch (PDOException $e) {
632 632
 			return "error";
633 633
 		}
634 634
 
@@ -644,13 +644,13 @@  discard block
 block discarded – undo
644 644
 	public function deleteLiveMarineDataById($id)
645 645
 	{
646 646
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
647
-		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
647
+		$query = 'DELETE FROM marine_live WHERE fammarine_id = :id';
648 648
         
649 649
     		try {
650 650
 			
651 651
 			$sth = $this->db->prepare($query);
652 652
 			$sth->execute(array(':id' => $id));
653
-		} catch(PDOException $e) {
653
+		} catch (PDOException $e) {
654 654
 			return "error";
655 655
 		}
656 656
 
@@ -668,13 +668,13 @@  discard block
 block discarded – undo
668 668
 	{
669 669
 		global $globalDBdriver, $globalTimezone;
670 670
 		if ($globalDBdriver == 'mysql') {
671
-			$query  = 'SELECT marine_live.ident FROM marine_live 
671
+			$query = 'SELECT marine_live.ident FROM marine_live 
672 672
 				WHERE marine_live.ident = :ident 
673 673
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
674 674
 				AND marine_live.date < UTC_TIMESTAMP()';
675 675
 			$query_data = array(':ident' => $ident);
676 676
 		} else {
677
-			$query  = "SELECT marine_live.ident FROM marine_live 
677
+			$query = "SELECT marine_live.ident FROM marine_live 
678 678
 				WHERE marine_live.ident = :ident 
679 679
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
680 680
 				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -683,8 +683,8 @@  discard block
 block discarded – undo
683 683
 		
684 684
 		$sth = $this->db->prepare($query);
685 685
 		$sth->execute($query_data);
686
-		$ident_result='';
687
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
686
+		$ident_result = '';
687
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
688 688
 		{
689 689
 			$ident_result = $row['ident'];
690 690
 		}
@@ -701,13 +701,13 @@  discard block
 block discarded – undo
701 701
 	{
702 702
 		global $globalDBdriver, $globalTimezone;
703 703
 		if ($globalDBdriver == 'mysql') {
704
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
704
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
705 705
 				WHERE marine_live.ident = :ident 
706 706
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
707 707
 //				AND marine_live.date < UTC_TIMESTAMP()";
708 708
 			$query_data = array(':ident' => $ident);
709 709
 		} else {
710
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
710
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
711 711
 				WHERE marine_live.ident = :ident 
712 712
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
713 713
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -716,8 +716,8 @@  discard block
 block discarded – undo
716 716
 		
717 717
 		$sth = $this->db->prepare($query);
718 718
 		$sth->execute($query_data);
719
-		$ident_result='';
720
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
719
+		$ident_result = '';
720
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
721 721
 		{
722 722
 			$ident_result = $row['fammarine_id'];
723 723
 		}
@@ -734,13 +734,13 @@  discard block
 block discarded – undo
734 734
 	{
735 735
 		global $globalDBdriver, $globalTimezone;
736 736
 		if ($globalDBdriver == 'mysql') {
737
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
737
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
738 738
 				WHERE marine_live.fammarine_id = :id 
739 739
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
740 740
 //				AND marine_live.date < UTC_TIMESTAMP()";
741 741
 			$query_data = array(':id' => $id);
742 742
 		} else {
743
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
743
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
744 744
 				WHERE marine_live.fammarine_id = :id 
745 745
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
746 746
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -749,8 +749,8 @@  discard block
 block discarded – undo
749 749
 		
750 750
 		$sth = $this->db->prepare($query);
751 751
 		$sth->execute($query_data);
752
-		$ident_result='';
753
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
752
+		$ident_result = '';
753
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
754 754
 		{
755 755
 			$ident_result = $row['fammarine_id'];
756 756
 		}
@@ -767,13 +767,13 @@  discard block
 block discarded – undo
767 767
 	{
768 768
 		global $globalDBdriver, $globalTimezone;
769 769
 		if ($globalDBdriver == 'mysql') {
770
-			$query  = 'SELECT marine_live.fammarine_id FROM marine_live 
770
+			$query = 'SELECT marine_live.fammarine_id FROM marine_live 
771 771
 				WHERE marine_live.mmsi = :mmsi 
772 772
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
773 773
 //				AND marine_live.date < UTC_TIMESTAMP()";
774 774
 			$query_data = array(':mmsi' => $mmsi);
775 775
 		} else {
776
-			$query  = "SELECT marine_live.fammarine_id FROM marine_live 
776
+			$query = "SELECT marine_live.fammarine_id FROM marine_live 
777 777
 				WHERE marine_live.mmsi = :mmsi 
778 778
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
779 779
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -782,8 +782,8 @@  discard block
 block discarded – undo
782 782
 		
783 783
 		$sth = $this->db->prepare($query);
784 784
 		$sth->execute($query_data);
785
-		$ident_result='';
786
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
785
+		$ident_result = '';
786
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
787 787
 		{
788 788
 			$ident_result = $row['fammarine_id'];
789 789
 		}
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
 	* @return String success or false
802 802
 	*
803 803
 	*/
804
-	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
804
+	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '')
805 805
 	{
806 806
 		global $globalURL, $globalArchive, $globalDebug;
807 807
 		$Common = new Common();
@@ -853,26 +853,26 @@  discard block
 block discarded – undo
853 853
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
854 854
 
855 855
         
856
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
857
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
858
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
859
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
860
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
861
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
862
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
863
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
864
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
865
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
866
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
867
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
868
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
869
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
870
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
871
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
856
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
857
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
858
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
859
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
860
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
861
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
862
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
863
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
864
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
865
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
866
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
867
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
868
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
869
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
870
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
871
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
872 872
 		
873 873
 
874
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
875
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
874
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
875
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
876 876
             	if ($arrival_date == '') $arrival_date = NULL;
877 877
             	$query = '';
878 878
 		if ($globalArchive) {
@@ -882,18 +882,18 @@  discard block
 block discarded – undo
882 882
 		$query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
883 883
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)';
884 884
 
885
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date);
885
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date);
886 886
 		try {
887 887
 			$sth = $this->db->prepare($query);
888 888
 			$sth->execute($query_values);
889
-		} catch(PDOException $e) {
889
+		} catch (PDOException $e) {
890 890
 			return "error : ".$e->getMessage();
891 891
 		}
892 892
 		
893 893
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
894 894
 			if ($globalDebug) echo '(Add to Marine archive : ';
895 895
 			$MarineArchive = new MarineArchive($this->db);
896
-			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country);
896
+			$result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $noarchive, $format_source, $source_name, $over_country);
897 897
 			if ($globalDebug) echo $result.')';
898 898
 		}
899 899
 		return "success";
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 
902 902
 	public function getOrderBy()
903 903
 	{
904
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
904
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
905 905
 		return $orderby;
906 906
 	}
907 907
 
Please login to merge, or discard this patch.
require/class.Image.php 1 patch
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -17,22 +17,22 @@  discard block
 block discarded – undo
17 17
 	* @return Array the images list
18 18
 	*
19 19
 	*/
20
-	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
20
+	public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
21 21
 	{
22
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
23
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
22
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
23
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
24
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
25 25
 		$reg = $registration;
26 26
 		if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao;
27 27
 		$reg = trim($reg);
28
-		$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 
28
+		$query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
29 29
 			FROM spotter_image 
30 30
 			WHERE spotter_image.registration = :registration LIMIT 1";
31 31
 		$sth = $this->db->prepare($query);
32 32
 		$sth->execute(array(':registration' => $reg));
33 33
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
34 34
 		if (!empty($result)) return $result;
35
-		elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
35
+		elseif ($registration != '') return $this->getSpotterImage('', $aircraft_icao, $airline_icao);
36 36
 		else return array();
37 37
 	}
38 38
 
@@ -42,23 +42,23 @@  discard block
 block discarded – undo
42 42
 	* @return Array the images list
43 43
 	*
44 44
 	*/
45
-	public function getMarineImage($mmsi,$imo = '',$name = '')
45
+	public function getMarineImage($mmsi, $imo = '', $name = '')
46 46
 	{
47
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
48
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
49
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
47
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
48
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
49
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
50 50
 		$name = trim($name);
51
-		$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 
51
+		$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 
52 52
 			FROM marine_image 
53 53
 			WHERE marine_image.mmsi = :mmsi";
54 54
 		$query_data = array(':mmsi' => $mmsi);
55 55
 		if ($imo != '') {
56 56
 			$query .= " AND marine_image.imo = :imo";
57
-			$query_data = array_merge($query_data,array(':imo' => $imo));
57
+			$query_data = array_merge($query_data, array(':imo' => $imo));
58 58
 		}
59 59
 		if ($name != '') {
60 60
 			$query .= " AND marine_image.name = :name";
61
-			$query_data = array_merge($query_data,array(':name' => $name));
61
+			$query_data = array_merge($query_data, array(':name' => $name));
62 62
 		}
63 63
 		$query .= " LIMIT 1";
64 64
 		$sth = $this->db->prepare($query);
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
80 80
 		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
81 81
 		if ($copyright != '') {
82
-			$copyright = str_replace('Copyright ','',$copyright);
83
-			$copyright = str_replace('© ','',$copyright);
84
-			$copyright = str_replace('(c) ','',$copyright);
82
+			$copyright = str_replace('Copyright ', '', $copyright);
83
+			$copyright = str_replace('© ', '', $copyright);
84
+			$copyright = str_replace('(c) ', '', $copyright);
85 85
 		}
86 86
 		return $copyright;
87 87
 	}
@@ -92,25 +92,25 @@  discard block
 block discarded – undo
92 92
 	* @return String either success or error
93 93
 	*
94 94
 	*/
95
-	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
95
+	public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
96 96
 	{
97
-		global $globalDebug,$globalAircraftImageFetch;
97
+		global $globalDebug, $globalAircraftImageFetch;
98 98
 		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
99
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
99
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
100 100
 		$registration = trim($registration);
101 101
 		//getting the aircraft image
102 102
 		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
103 103
 		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
104 104
 		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
105
-		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
105
+		$image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao);
106 106
 		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
107 107
 		if ($image_url['original'] != '') {
108 108
 			if ($globalDebug) echo 'Found !'."\n";
109
-			$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)";
109
+			$query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
110 110
 			try {
111 111
 				$sth = $this->db->prepare($query);
112
-				$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']));
113
-			} catch(PDOException $e) {
112
+				$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']));
113
+			} catch (PDOException $e) {
114 114
 				echo $e->getMessage()."\n";
115 115
 				return "error";
116 116
 			}
@@ -124,13 +124,13 @@  discard block
 block discarded – undo
124 124
 	* @return String either success or error
125 125
 	*
126 126
 	*/
127
-	public function addMarineImage($mmsi,$imo = '',$name = '')
127
+	public function addMarineImage($mmsi, $imo = '', $name = '')
128 128
 	{
129
-		global $globalDebug,$globalMarineImageFetch;
129
+		global $globalDebug, $globalMarineImageFetch;
130 130
 		if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return '';
131
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
132
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
133
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
131
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
132
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
133
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
134 134
 		$name = trim($name);
135 135
 		$Marine = new Marine($this->db);
136 136
 		if ($imo == '' || $name == '') {
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
 
145 145
 		//getting the aircraft image
146 146
 		if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...';
147
-		$image_url = $this->findMarineImage($mmsi,$imo,$name);
147
+		$image_url = $this->findMarineImage($mmsi, $imo, $name);
148 148
 		if ($image_url['original'] != '') {
149 149
 			if ($globalDebug) echo 'Found !'."\n";
150
-			$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)";
150
+			$query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)";
151 151
 			try {
152 152
 				$sth = $this->db->prepare($query);
153
-				$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']));
154
-			} catch(PDOException $e) {
153
+				$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']));
154
+			} catch (PDOException $e) {
155 155
 				echo $e->getMessage()."\n";
156 156
 				return "error";
157 157
 			}
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
172 172
 		$Spotter = new Spotter($this->db);
173 173
 		if (!isset($globalIVAO)) $globalIVAO = FALSE;
174
-		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
174
+		$aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING);
175 175
 		if ($aircraft_registration != '' && (!isset($globalVA) || $globalVA !== TRUE)) {
176
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
176
+			if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
177 177
 			$aircraft_registration = urlencode(trim($aircraft_registration));
178 178
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
179 179
 			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
@@ -187,25 +187,25 @@  discard block
 block discarded – undo
187 187
 			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
188 188
 			else $aircraft_name = '';
189 189
 			$aircraft_registration = $aircraft_icao;
190
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
190
+		} else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
191 191
 		unset($Spotter);
192
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
192
+		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
193 193
 		foreach ($globalAircraftImageSources as $source) {
194 194
 			$source = strtolower($source);
195
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
196
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
197
-			if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
198
-			if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
199
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
200
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
201
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
202
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
203
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
204
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
195
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft', $aircraft_icao, $airline_icao);
196
+			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft', $aircraft_registration, $aircraft_name);
197
+			if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft', $aircraft_registration, $aircraft_name);
198
+			if ($source == 'bing') $images_array = $this->fromBing('aircraft', $aircraft_registration, $aircraft_name);
199
+			if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft', $aircraft_registration, $aircraft_name);
200
+			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft', $aircraft_registration, $aircraft_name);
201
+			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft', $aircraft_registration, $aircraft_name);
202
+			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft', $aircraft_registration, $aircraft_name);
203
+			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft', $aircraft_registration, $aircraft_name);
204
+			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft', $aircraft_registration, $aircraft_name);
205 205
 			if (isset($images_array) && $images_array['original'] != '') return $images_array;
206 206
 		}
207 207
 		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
208
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
208
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
209 209
 	}
210 210
 
211 211
 	/**
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
 	* @return Array the aircraft thumbnail, orignal url and copyright
218 218
 	*
219 219
 	*/
220
-	public function findMarineImage($mmsi,$imo = '',$name = '')
220
+	public function findMarineImage($mmsi, $imo = '', $name = '')
221 221
 	{
222 222
 		global $globalMarineImageSources;
223
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
223
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
224 224
 		//$imo = filter_var($imo,FILTER_SANITIZE_STRING);
225
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
225
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
226 226
 		$name = trim($name);
227
-		if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
227
+		if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
228 228
 		/*
229 229
 		$Marine = new Marine($this->db);
230 230
 		if ($imo == '' || $name == '') {
@@ -236,17 +236,17 @@  discard block
 block discarded – undo
236 236
 		}
237 237
 		unset($Marine);
238 238
 		*/
239
-		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
239
+		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing');
240 240
 		foreach ($globalMarineImageSources as $source) {
241 241
 			$source = strtolower($source);
242
-			if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name);
243
-			if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name);
244
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name);
245
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name);
246
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name);
242
+			if ($source == 'flickr') $images_array = $this->fromFlickr('marine', $mmsi, $name);
243
+			if ($source == 'bing') $images_array = $this->fromBing('marine', $mmsi, $name);
244
+			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine', $mmsi, $name);
245
+			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine', $mmsi, $name);
246
+			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine', $mmsi, $name);
247 247
 			if (isset($images_array) && $images_array['original'] != '') return $images_array;
248 248
 		}
249
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
249
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
250 250
 	}
251 251
 
252 252
 	/**
@@ -257,24 +257,24 @@  discard block
 block discarded – undo
257 257
 	* @return Array the aircraft thumbnail, orignal url and copyright
258 258
 	*
259 259
 	*/
260
-	public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') {
260
+	public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') {
261 261
 		$Common = new Common();
262 262
 		// If aircraft registration is only number, also check with aircraft model
263
-		if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') {
264
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
263
+		if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') {
264
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
265 265
 		} else {
266 266
 			//$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss';
267
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
267
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
268 268
 		}
269 269
 		$data = $Common->getData($url);
270 270
 		if ($xml = simplexml_load_string($data)) {
271 271
 			if (isset($xml->channel->item)) {
272 272
 				$image_url = array();
273
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
273
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
274 274
 				$image_url['thumbnail'] = $thumbnail_url;
275
-				$image_url['original'] = str_replace('thumbnail','original',$thumbnail_url);
276
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
277
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
275
+				$image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url);
276
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
277
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
278 278
 				$image_url['source'] = 'planespotters';
279 279
 				return $image_url;
280 280
 			}
@@ -290,29 +290,29 @@  discard block
 block discarded – undo
290 290
 	* @return Array the aircraft thumbnail, orignal url and copyright
291 291
 	*
292 292
 	*/
293
-	public function fromDeviantart($type,$registration, $name='') {
293
+	public function fromDeviantart($type, $registration, $name = '') {
294 294
 		$Common = new Common();
295 295
 		if ($type == 'aircraft') {
296 296
 			// If aircraft registration is only number, also check with aircraft model
297
-			if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') {
298
-				$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name);
297
+			if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') {
298
+				$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name);
299 299
 			} else {
300
-				$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration;
300
+				$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration;
301 301
 			}
302 302
 		} elseif ($type == 'marine') {
303
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"';
303
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"';
304 304
 		}
305 305
 
306 306
 		$data = $Common->getData($url);
307 307
 		if ($xml = simplexml_load_string($data)) {
308 308
 			if (isset($xml->channel->item->link)) {
309 309
 				$image_url = array();
310
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
310
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
311 311
 				$image_url['thumbnail'] = $thumbnail_url;
312
-				$original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
312
+				$original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
313 313
 				$image_url['original'] = $original_url;
314
-				$image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
315
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
314
+				$image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
315
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
316 316
 				$image_url['source'] = 'deviantart';
317 317
 				return $image_url;
318 318
 			}
@@ -328,32 +328,32 @@  discard block
 block discarded – undo
328 328
 	* @return Array the aircraft thumbnail, orignal url and copyright
329 329
 	*
330 330
 	*/
331
-	public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') {
331
+	public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') {
332 332
 		$Common = new Common();
333
-		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
333
+		$url = 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
334 334
 		$data = $Common->getData($url);
335 335
 		$dom = new DOMDocument();
336 336
 		@$dom->loadHTML($data);
337 337
 		$all_pics = array();
338
-		foreach($dom->getElementsByTagName('img') as $image) {
338
+		foreach ($dom->getElementsByTagName('img') as $image) {
339 339
 			if ($image->getAttribute('itemprop') == "http://schema.org/image") {
340 340
 				$all_pics[] = $image->getAttribute('src');
341 341
 			}
342 342
 		}
343 343
 		$all_authors = array();
344
-		foreach($dom->getElementsByTagName('meta') as $author) {
344
+		foreach ($dom->getElementsByTagName('meta') as $author) {
345 345
 			if ($author->getAttribute('itemprop') == "http://schema.org/author") {
346 346
 				$all_authors[] = $author->getAttribute('content');
347 347
 			}
348 348
 		}
349 349
 		$all_ref = array();
350
-		foreach($dom->getElementsByTagName('a') as $link) {
350
+		foreach ($dom->getElementsByTagName('a') as $link) {
351 351
 			$all_ref[] = $link->getAttribute('href');
352 352
 		}
353 353
 		if (isset($all_pics[0])) {
354 354
 			$image_url = array();
355 355
 			$image_url['thumbnail'] = $all_pics[0];
356
-			$image_url['original'] = str_replace('_tb','',$all_pics[0]);
356
+			$image_url['original'] = str_replace('_tb', '', $all_pics[0]);
357 357
 			$image_url['copyright'] = $all_authors[0];
358 358
 			$image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8];
359 359
 			$image_url['source'] = 'JetPhotos';
@@ -370,24 +370,24 @@  discard block
 block discarded – undo
370 370
 	* @return Array the aircraft thumbnail, orignal url and copyright
371 371
 	*
372 372
 	*/
373
-	public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') {
373
+	public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') {
374 374
 		$Common = new Common();
375
-		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
375
+		$url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
376 376
 		$data = $Common->getData($url);
377 377
 		$dom = new DOMDocument();
378 378
 		@$dom->loadHTML($data);
379 379
 		$all_pics = array();
380
-		foreach($dom->getElementsByTagName('img') as $image) {
380
+		foreach ($dom->getElementsByTagName('img') as $image) {
381 381
 			$all_pics[] = $image->getAttribute('src');
382 382
 		}
383 383
 		$all_links = array();
384
-		foreach($dom->getElementsByTagName('a') as $link) {
385
-			$all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href'));
384
+		foreach ($dom->getElementsByTagName('a') as $link) {
385
+			$all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href'));
386 386
 		}
387
-		if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) {
387
+		if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) {
388 388
 			$image_url = array();
389 389
 			$image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1];
390
-			$image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]);
390
+			$image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]);
391 391
 			$image_url['copyright'] = $all_links[6]['text'];
392 392
 			$image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href'];
393 393
 			$image_url['source'] = 'PlanePictures';
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 	* @return Array the aircraft thumbnail, orignal url and copyright
405 405
 	*
406 406
 	*/
407
-	public function fromFlickr($type,$registration,$name='') {
407
+	public function fromFlickr($type, $registration, $name = '') {
408 408
 		$Common = new Common();
409 409
 		if ($type == 'aircraft') {
410 410
 			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
@@ -416,12 +416,12 @@  discard block
 block discarded – undo
416 416
 		$data = $Common->getData($url);
417 417
 		if ($xml = simplexml_load_string($data)) {
418 418
 			if (isset($xml->channel->item)) {
419
-				$original_url = trim((string)$xml->channel->item->enclosure->attributes()->url);
419
+				$original_url = trim((string) $xml->channel->item->enclosure->attributes()->url);
420 420
 				$image_url = array();
421 421
 				$image_url['thumbnail'] = $original_url;
422 422
 				$image_url['original'] = $original_url;
423
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
424
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
423
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
424
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
425 425
 				$image_url['source'] = 'flickr';
426 426
 				return $image_url;
427 427
 			}
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		return false;
430 430
 	}
431 431
 
432
-	public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) {
432
+	public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) {
433 433
 		$Common = new Common();
434 434
 		//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
435 435
 		if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) {
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 	* @return Array the aircraft thumbnail, orignal url and copyright
454 454
 	*
455 455
 	*/
456
-	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
456
+	public function fromBing($type, $aircraft_registration, $aircraft_name = '') {
457 457
 		global $globalImageBingKey;
458 458
 		$Common = new Common();
459 459
 		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
@@ -464,8 +464,8 @@  discard block
 block discarded – undo
464 464
 			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';
465 465
 			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';
466 466
 		}
467
-		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
468
-		$data = $Common->getData($url,'get','',$headers);
467
+		$headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey));
468
+		$data = $Common->getData($url, 'get', '', $headers);
469 469
 		$result = json_decode($data);
470 470
 		if (isset($result->d->results[0]->MediaUrl)) {
471 471
 			$image_url = array();
@@ -490,14 +490,14 @@  discard block
 block discarded – undo
490 490
 	* @return Array the aircraft thumbnail, orignal url and copyright
491 491
 	*
492 492
 	*/
493
-	public function fromAirportData($type,$aircraft_registration,$aircraft_name='') {
493
+	public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') {
494 494
 		$Common = new Common();
495 495
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
496 496
 		$data = $Common->getData($url);
497 497
 		$result = json_decode($data);
498 498
 		if (isset($result->count) && $result->count > 0) {
499 499
 			$image_url = array();
500
-			$image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image);
500
+			$image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image);
501 501
 			$image_url['source_website'] = $result->data[0]->link;
502 502
 			$image_url['thumbnail'] = $result->data[0]->image;
503 503
 			$image_url['copyright'] = $result->data[0]->photographer;
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 	* @return Array the aircraft thumbnail, orignal url and copyright
516 516
 	*
517 517
 	*/
518
-	public function fromWikimedia($type,$registration,$name='') {
518
+	public function fromWikimedia($type, $registration, $name = '') {
519 519
 		$Common = new Common();
520 520
 		if ($type == 'aircraft') {
521 521
 			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);
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 		$result = json_decode($data);
529 529
 		if (isset($result->query->search[0]->title)) {
530 530
 			$fileo = $result->query->search[0]->title;
531
-			if (substr($fileo,-3) == 'pdf') return false;
531
+			if (substr($fileo, -3) == 'pdf') return false;
532 532
 			$file = urlencode($fileo);
533 533
 			$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;
534 534
 			$data2 = $Common->getData($url2);
@@ -553,11 +553,11 @@  discard block
 block discarded – undo
553 553
 				if (isset($result2->query->pages)) {
554 554
 					foreach ($result2->query->pages as $page) {
555 555
 						if (isset($page->imageinfo[0]->extmetadata->Artist)) {
556
-							$image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
556
+							$image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
557 557
 							if (isset($page->imageinfo[0]->extmetadata->License->value)) {
558 558
 								$image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')';
559 559
 							}
560
-							$image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright']));
560
+							$image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright']));
561 561
 							return $image_url;
562 562
 						}
563 563
 					}
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 	* @return Array the aircraft thumbnail, orignal url and copyright
577 577
 	*
578 578
 	*/
579
-	public function fromCustomSource($type,$registration,$name='') {
579
+	public function fromCustomSource($type, $registration, $name = '') {
580 580
 		global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug;
581 581
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
582 582
 		if (!empty($globalAircraftImageCustomSources) && $type == 'aircraft') {
@@ -593,15 +593,15 @@  discard block
 block discarded – undo
593 593
 					print_r($source);
594 594
 					print_r($customsources);
595 595
 				}
596
-				$url = str_replace('{registration}',$registration,$source['original']);
597
-				$url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']);
596
+				$url = str_replace('{registration}', $registration, $source['original']);
597
+				$url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']);
598 598
 				if ($Common->urlexist($url)) {
599 599
 					$image_url = array();
600 600
 					$image_url['thumbnail'] = $url_thumbnail;
601 601
 					$image_url['original'] = $url;
602 602
 					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
603 603
 					else $exifCopyright = '';
604
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
604
+					if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright;
605 605
 					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
606 606
 					else $image_url['copyright'] = $source['source_website'];
607 607
 					$image_url['source_website'] = $source['source_website'];
@@ -625,19 +625,19 @@  discard block
 block discarded – undo
625 625
 					print_r($source);
626 626
 					print_r($customsources);
627 627
 				}
628
-				$url = str_replace('{registration}',$registration,$source['original']);
629
-				$url = str_replace('{mmsi}',$registration,$url);
630
-				$url = str_replace('{name}',$name,$url);
631
-				$url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']);
632
-				$url_thumbnail = str_replace('{mmsi}',$registration,$url_thumbnail);
633
-				$url_thumbnail = str_replace('{name}',$name,$url_thumbnail);
628
+				$url = str_replace('{registration}', $registration, $source['original']);
629
+				$url = str_replace('{mmsi}', $registration, $url);
630
+				$url = str_replace('{name}', $name, $url);
631
+				$url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']);
632
+				$url_thumbnail = str_replace('{mmsi}', $registration, $url_thumbnail);
633
+				$url_thumbnail = str_replace('{name}', $name, $url_thumbnail);
634 634
 				if ($Common->urlexist($url)) {
635 635
 					$image_url = array();
636 636
 					$image_url['thumbnail'] = $url_thumbnail;
637 637
 					$image_url['original'] = $url;
638 638
 					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
639 639
 					else $exifCopyright = '';
640
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
640
+					if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright;
641 641
 					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
642 642
 					else $image_url['copyright'] = $source['source_website'];
643 643
 					$image_url['source_website'] = $source['source_website'];
Please login to merge, or discard this patch.