Completed
Push — master ( 2f98db...871605 )
by Yannick
21s queued 10s
created
owner-statistics-aircraft.php 3 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -9,23 +9,23 @@  discard block
 block discarded – undo
9 9
 }
10 10
 $Spotter = new Spotter();
11 11
 $SpotterArchive = new SpotterArchive();
12
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
13
-$owner = urldecode(filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING));
14
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
12
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
13
+$owner = urldecode(filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING));
14
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
15
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
16 16
 $filter = array();
17
-if ($year != '') $filter = array_merge($filter,array('year' => $year));
18
-if ($month != '') $filter = array_merge($filter,array('month' => $month));
17
+if ($year != '') $filter = array_merge($filter, array('year' => $year));
18
+if ($month != '') $filter = array_merge($filter, array('month' => $month));
19 19
 $archive = false;
20
-$spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
20
+$spotter_array = $Spotter->getSpotterDataByOwner($owner, "0,1", $sort, $filter);
21 21
 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
22 22
 	$archive = true;
23
-	$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
23
+	$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, "0,1", $sort, $filter);
24 24
 }
25 25
 
26 26
 if (!empty($spotter_array))
27 27
 {
28
-	$title = sprintf(_("Most Common Aircraft of %s"),$spotter_array[0]['aircraft_owner']);
28
+	$title = sprintf(_("Most Common Aircraft of %s"), $spotter_array[0]['aircraft_owner']);
29 29
 	require_once('header.php');
30 30
 	print '<div class="info column">';
31 31
 	print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 	include('owner-sub-menu.php');
37 37
 	print '<div class="column">';
38 38
 	print '<h2>'._("Most Common Aircraft").'</h2>';
39
-	print '<p>'.sprintf(_("The statistic below shows the most common aircraft of flights owned by <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
39
+	print '<p>'.sprintf(_("The statistic below shows the most common aircraft of flights owned by <strong>%s</strong>."), $spotter_array[0]['aircraft_owner']).'</p>';
40 40
 
41 41
 	if ($archive === false) {
42
-		$aircraft_array = $Spotter->countAllAircraftTypesByOwner($owner,$filter);
42
+		$aircraft_array = $Spotter->countAllAircraftTypesByOwner($owner, $filter);
43 43
 	} else {
44
-		$aircraft_array = $SpotterArchive->countAllAircraftTypesByOwner($owner,$filter);
44
+		$aircraft_array = $SpotterArchive->countAllAircraftTypesByOwner($owner, $filter);
45 45
 	}
46 46
 	if (!empty($aircraft_array))
47 47
 	{
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		print '</thead>';
55 55
 		print '<tbody>';
56 56
 		$i = 1;
57
-		foreach($aircraft_array as $aircraft_item)
57
+		foreach ($aircraft_array as $aircraft_item)
58 58
 		{
59 59
 			print '<tr>';
60 60
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 require_once('require/class.SpotterArchive.php');
5 5
 require_once('require/class.Language.php');
6 6
 if (!isset($_GET['owner'])) {
7
-        header('Location: '.$globalURL.'/owner');
8
-        die();
7
+		header('Location: '.$globalURL.'/owner');
8
+		die();
9 9
 }
10 10
 $Spotter = new Spotter();
11 11
 $SpotterArchive = new SpotterArchive();
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,12 @@
 block discarded – undo
14 14
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15 15
 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
16 16
 $filter = array();
17
-if ($year != '') $filter = array_merge($filter,array('year' => $year));
18
-if ($month != '') $filter = array_merge($filter,array('month' => $month));
17
+if ($year != '') {
18
+	$filter = array_merge($filter,array('year' => $year));
19
+}
20
+if ($month != '') {
21
+	$filter = array_merge($filter,array('month' => $month));
22
+}
19 23
 $archive = false;
20 24
 $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
21 25
 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
Please login to merge, or discard this patch.
owner-detailed.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@  discard block
 block discarded – undo
7 7
 //require_once('require/class.SpotterLive.php');
8 8
 require_once('require/class.SpotterArchive.php');
9 9
 
10
-if (!isset($_GET['owner'])){
10
+if (!isset($_GET['owner'])) {
11 11
 	header('Location: '.$globalURL.'');
12 12
 } else {
13 13
 	$Spotter = new Spotter();
14 14
 	$SpotterArchive = new SpotterArchive();
15 15
 	//$Translation = new Translation();
16 16
 	//calculuation for the pagination
17
-	if(!isset($_GET['limit']))
17
+	if (!isset($_GET['limit']))
18 18
 	{
19 19
 		$limit_start = 0;
20 20
 		$limit_end = 25;
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 	} else {
23 23
 		$limit_explode = explode(",", $_GET['limit']);
24 24
 		if (isset($limit_explode[1])) {
25
-			$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
26
-			$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
25
+			$limit_start = filter_var($limit_explode[0], FILTER_SANITIZE_NUMBER_INT);
26
+			$limit_end = filter_var($limit_explode[1], FILTER_SANITIZE_NUMBER_INT);
27 27
 		} else {
28 28
 			$limit_start = 0;
29 29
 			$limit_end = 25;
@@ -40,21 +40,21 @@  discard block
 block discarded – undo
40 40
 	
41 41
 	$page_url = $globalURL.'/owner/'.$_GET['owner'];
42 42
 	
43
-	$owner = urldecode(filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING));
44
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
45
-	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
46
-	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
43
+	$owner = urldecode(filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING));
44
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
45
+	$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
46
+	$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
47 47
 	$filter = array();
48
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
49
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
50
-	$spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
48
+	if ($year != '') $filter = array_merge($filter, array('year' => $year));
49
+	if ($month != '') $filter = array_merge($filter, array('month' => $month));
50
+	$spotter_array = $Spotter->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, $sort, $filter);
51 51
 	if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
52
-		$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
52
+		$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, $limit_start.",".$absolute_difference, $sort, $filter);
53 53
 	}
54 54
 
55 55
 	if (!empty($spotter_array))
56 56
 	{
57
-		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['aircraft_owner']);
57
+		$title = sprintf(_("Detailed View for %s"), $spotter_array[0]['aircraft_owner']);
58 58
 		//$ident = $spotter_array[0]['ident'];
59 59
 		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
60 60
 		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
@@ -65,23 +65,23 @@  discard block
 block discarded – undo
65 65
 		$Stats = new Stats();
66 66
 		if ($year == '' && $month == '') $flights = $Stats->getStatsOwner($owner);
67 67
 		else $flights = 0;
68
-		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner,$filter);
68
+		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner, $filter);
69 69
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
70
-		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner,$filter));
70
+		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner, $filter));
71 71
 		print '<div><span class="label">'._("Aircraft type").'</span>'.$aircraft_type.'</div>';
72
-		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByOwner($owner,$filter));
72
+		$aircraft_registration = count($Spotter->countAllAircraftRegistrationByOwner($owner, $filter));
73 73
 		print '<div><span class="label">'._("Aircraft").'</span>'.$aircraft_registration.'</div>';
74
-		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByOwner($owner,$filter));
74
+		$aircraft_manufacturer = count($Spotter->countAllAircraftManufacturerByOwner($owner, $filter));
75 75
 		print '<div><span class="label">'._("Manufacturers").'</span>'.$aircraft_manufacturer.'</div>';
76
-		$airlines = count($Spotter->countAllAirlinesByOwner($owner,$filter));
76
+		$airlines = count($Spotter->countAllAirlinesByOwner($owner, $filter));
77 77
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
78
-		$duration = $Spotter->getFlightDurationByOwner($owner,$filter);
78
+		$duration = $Spotter->getFlightDurationByOwner($owner, $filter);
79 79
 		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
80 80
 		print '</div>';
81 81
 	
82 82
 		include('owner-sub-menu.php');
83 83
 		print '<div class="table column">';
84
-		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the owner <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
84
+		print '<p>'.sprintf(_("The table below shows the detailed information of all flights with the owner <strong>%s</strong>."), $spotter_array[0]['aircraft_owner']).'</p>';
85 85
 
86 86
 		include('table-output.php'); 
87 87
 		print '<div class="pagination">';
Please login to merge, or discard this patch.
Braces   +23 added lines, -8 removed lines patch added patch discarded remove patch
@@ -45,8 +45,12 @@  discard block
 block discarded – undo
45 45
 	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
46 46
 	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
47 47
 	$filter = array();
48
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
49
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
48
+	if ($year != '') {
49
+		$filter = array_merge($filter,array('year' => $year));
50
+	}
51
+	if ($month != '') {
52
+		$filter = array_merge($filter,array('month' => $month));
53
+	}
50 54
 	$spotter_array = $Spotter->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
51 55
 	if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
52 56
 		$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,$limit_start.",".$absolute_difference, $sort,$filter);
@@ -56,16 +60,25 @@  discard block
 block discarded – undo
56 60
 	{
57 61
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['aircraft_owner']);
58 62
 		//$ident = $spotter_array[0]['ident'];
59
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
60
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
63
+		if (isset($spotter_array[0]['latitude'])) {
64
+			$latitude = $spotter_array[0]['latitude'];
65
+		}
66
+		if (isset($spotter_array[0]['longitude'])) {
67
+			$longitude = $spotter_array[0]['longitude'];
68
+		}
61 69
 		require_once('header.php');
62 70
 		print '<div class="info column">';
63 71
 		print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
64 72
 		//print '<div><span class="label">'._("Owner").'</span>'.$spotter_array[0]['aircraft_owner'].'</div>';
65 73
 		$Stats = new Stats();
66
-		if ($year == '' && $month == '') $flights = $Stats->getStatsOwner($owner);
67
-		else $flights = 0;
68
-		if ($flights == 0) $flights = $Spotter->countFlightsByOwner($owner,$filter);
74
+		if ($year == '' && $month == '') {
75
+			$flights = $Stats->getStatsOwner($owner);
76
+		} else {
77
+			$flights = 0;
78
+		}
79
+		if ($flights == 0) {
80
+			$flights = $Spotter->countFlightsByOwner($owner,$filter);
81
+		}
69 82
 		print '<div><span class="label">'._("Flights").'</span>'.$flights.'</div>';
70 83
 		$aircraft_type = count($Spotter->countAllAircraftTypesByOwner($owner,$filter));
71 84
 		print '<div><span class="label">'._("Aircraft type").'</span>'.$aircraft_type.'</div>';
@@ -76,7 +89,9 @@  discard block
 block discarded – undo
76 89
 		$airlines = count($Spotter->countAllAirlinesByOwner($owner,$filter));
77 90
 		print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
78 91
 		$duration = $Spotter->getFlightDurationByOwner($owner,$filter);
79
-		if ($duration != '0') print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
92
+		if ($duration != '0') {
93
+			print '<div><span class="label">'._("Total flights spotted duration").'</span>'.$duration.'</div>';
94
+		}
80 95
 		print '</div>';
81 96
 	
82 97
 		include('owner-sub-menu.php');
Please login to merge, or discard this patch.
owner-statistics-arrival-airport.php 3 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -9,22 +9,22 @@  discard block
 block discarded – undo
9 9
 }
10 10
 $Spotter = new Spotter();
11 11
 $SpotterArchive = new SpotterArchive();
12
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
13
-$owner = urldecode(filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING));
14
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
12
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
13
+$owner = urldecode(filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING));
14
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
15
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
16 16
 $filter = array();
17
-if ($year != '') $filter = array_merge($filter,array('year' => $year));
18
-if ($month != '') $filter = array_merge($filter,array('month' => $month));
17
+if ($year != '') $filter = array_merge($filter, array('year' => $year));
18
+if ($month != '') $filter = array_merge($filter, array('month' => $month));
19 19
 $archive = false;
20
-$spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
20
+$spotter_array = $Spotter->getSpotterDataByOwner($owner, "0,1", $sort, $filter);
21 21
 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
22 22
 	$archive = true;
23
-	$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
23
+	$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, "0,1", $sort, $filter);
24 24
 }
25 25
 if (!empty($spotter_array))
26 26
 {
27
-	$title = sprintf(_("Most Common Arrival Airports of %s"),$spotter_array[0]['aircraft_owner']);
27
+	$title = sprintf(_("Most Common Arrival Airports of %s"), $spotter_array[0]['aircraft_owner']);
28 28
 	require_once('header.php');
29 29
 	print '<div class="info column">';
30 30
 	print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
 	include('owner-sub-menu.php');
36 36
 	print '<div class="column">';
37 37
 	print '<h2>'._("Most Common Arrival Airports").'</h2>';
38
-	print '<p>'.sprintf(_("The statistic below shows all arrival airports of flights owned by <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
38
+	print '<p>'.sprintf(_("The statistic below shows all arrival airports of flights owned by <strong>%s</strong>."), $spotter_array[0]['aircraft_owner']).'</p>';
39 39
 	if ($archive === false) {
40
-		$airport_airport_array = $Spotter->countAllArrivalAirportsByOwner($owner,$filter);
40
+		$airport_airport_array = $Spotter->countAllArrivalAirportsByOwner($owner, $filter);
41 41
 	} else {
42
-		$airport_airport_array = $SpotterArchive->countAllArrivalAirportsByOwner($owner,$filter);
42
+		$airport_airport_array = $SpotterArchive->countAllArrivalAirportsByOwner($owner, $filter);
43 43
 	}
44 44
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
45 45
 	print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	print '<script>';
49 49
 	print 'var series = [';
50 50
 	$airport_data = '';
51
-	foreach($airport_airport_array as $airport_item)
51
+	foreach ($airport_airport_array as $airport_item)
52 52
 	{
53 53
 		$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_name'].' ('.$airport_item['airport_arrival_icao'].')",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
54 54
 	}
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	print '</thead>';
104 104
 	print '<tbody>';
105 105
 	$i = 1;
106
-	foreach($airport_airport_array as $airport_item)
106
+	foreach ($airport_airport_array as $airport_item)
107 107
 	{
108 108
 		print '<tr>';
109 109
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 require_once('require/class.SpotterArchive.php');
5 5
 require_once('require/class.Language.php');
6 6
 if (!isset($_GET['owner'])) {
7
-        header('Location: '.$globalURL.'/owner');
8
-        die();
7
+		header('Location: '.$globalURL.'/owner');
8
+		die();
9 9
 }
10 10
 $Spotter = new Spotter();
11 11
 $SpotterArchive = new SpotterArchive();
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,12 @@
 block discarded – undo
14 14
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15 15
 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
16 16
 $filter = array();
17
-if ($year != '') $filter = array_merge($filter,array('year' => $year));
18
-if ($month != '') $filter = array_merge($filter,array('month' => $month));
17
+if ($year != '') {
18
+	$filter = array_merge($filter,array('year' => $year));
19
+}
20
+if ($month != '') {
21
+	$filter = array_merge($filter,array('month' => $month));
22
+}
19 23
 $archive = false;
20 24
 $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
21 25
 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
Please login to merge, or discard this patch.
owner-statistics-route.php 3 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -9,22 +9,22 @@  discard block
 block discarded – undo
9 9
 }
10 10
 $Spotter = new Spotter();
11 11
 $SpotterArchive = new SpotterArchive();
12
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
13
-$owner = urldecode(filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING));
14
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
12
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
13
+$owner = urldecode(filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING));
14
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
15
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
16 16
 $filter = array();
17
-if ($year != '') $filter = array_merge($filter,array('year' => $year));
18
-if ($month != '') $filter = array_merge($filter,array('month' => $month));
17
+if ($year != '') $filter = array_merge($filter, array('year' => $year));
18
+if ($month != '') $filter = array_merge($filter, array('month' => $month));
19 19
 $archive = false;
20
-$spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
20
+$spotter_array = $Spotter->getSpotterDataByOwner($owner, "0,1", $sort, $filter);
21 21
 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
22 22
 	$archive = true;
23
-	$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
23
+	$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, "0,1", $sort, $filter);
24 24
 }
25 25
 if (!empty($spotter_array))
26 26
 {
27
-	$title = sprintf(_("Most Common Routes of %s"),$spotter_array[0]['aircraft_owner']);
27
+	$title = sprintf(_("Most Common Routes of %s"), $spotter_array[0]['aircraft_owner']);
28 28
 	require_once('header.php');
29 29
 	print '<div class="info column">';
30 30
 	print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
 	include('owner-sub-menu.php');
36 36
 	print '<div class="column">';
37 37
 	print '<h2>'._("Most Common Routes").'</h2>';
38
-	print '<p>'.sprintf(_("The statistic below shows the most common routes from flights owner by <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
38
+	print '<p>'.sprintf(_("The statistic below shows the most common routes from flights owner by <strong>%s</strong>."), $spotter_array[0]['aircraft_owner']).'</p>';
39 39
 	if ($archive === false) {
40
-		$route_array = $Spotter->countAllRoutesByOwner($owner,$filter);
40
+		$route_array = $Spotter->countAllRoutesByOwner($owner, $filter);
41 41
 	} else {
42
-		$route_array = $SpotterArchive->countAllRoutesByOwner($owner,$filter);
42
+		$route_array = $SpotterArchive->countAllRoutesByOwner($owner, $filter);
43 43
 	}
44 44
 	if (!empty($route_array))
45 45
 	{
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		print '</thead>';
56 56
 		print '<tbody>';
57 57
 		$i = 1;
58
-		foreach($route_array as $route_item)
58
+		foreach ($route_array as $route_item)
59 59
 		{
60 60
 			print '<tr>';
61 61
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 require_once('require/class.SpotterArchive.php');
5 5
 require_once('require/class.Language.php');
6 6
 if (!isset($_GET['owner'])) {
7
-        header('Location: '.$globalURL.'/owner');
8
-        die();
7
+		header('Location: '.$globalURL.'/owner');
8
+		die();
9 9
 }
10 10
 $Spotter = new Spotter();
11 11
 $SpotterArchive = new SpotterArchive();
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,12 @@
 block discarded – undo
14 14
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15 15
 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
16 16
 $filter = array();
17
-if ($year != '') $filter = array_merge($filter,array('year' => $year));
18
-if ($month != '') $filter = array_merge($filter,array('month' => $month));
17
+if ($year != '') {
18
+	$filter = array_merge($filter,array('year' => $year));
19
+}
20
+if ($month != '') {
21
+	$filter = array_merge($filter,array('month' => $month));
22
+}
19 23
 $archive = false;
20 24
 $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
21 25
 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
Please login to merge, or discard this patch.
owner-statistics-manufacturer.php 3 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -9,21 +9,21 @@  discard block
 block discarded – undo
9 9
 }
10 10
 $Spotter = new Spotter();
11 11
 $SpotterArchive = new SpotterArchive();
12
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
13
-$owner = urldecode(filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING));
14
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
12
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
13
+$owner = urldecode(filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING));
14
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
15
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
16 16
 $filter = array();
17
-if ($year != '') $filter = array_merge($filter,array('year' => $year));
18
-if ($month != '') $filter = array_merge($filter,array('month' => $month));
17
+if ($year != '') $filter = array_merge($filter, array('year' => $year));
18
+if ($month != '') $filter = array_merge($filter, array('month' => $month));
19 19
 $archive = false;
20
-$spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
20
+$spotter_array = $Spotter->getSpotterDataByOwner($owner, "0,1", $sort, $filter);
21 21
 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
22
-	$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
22
+	$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, "0,1", $sort, $filter);
23 23
 }
24 24
 if (!empty($spotter_array))
25 25
 {
26
-	$title = sprintf(_("Most Common Aircraft Manufacturer of %s"),$spotter_array[0]['aircraft_owner']);
26
+	$title = sprintf(_("Most Common Aircraft Manufacturer of %s"), $spotter_array[0]['aircraft_owner']);
27 27
 	require_once('header.php');
28 28
 	print '<div class="info column">';
29 29
 	print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 	include('owner-sub-menu.php');
35 35
 	print '<div class="column">';
36 36
 	print '<h2>'._("Most Common Aircraft Manufacturer").'</h2>';
37
-	print '<p>'.sprintf(_("The statistic below shows the most common Aircraft Manufacturer of flights owned by <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
37
+	print '<p>'.sprintf(_("The statistic below shows the most common Aircraft Manufacturer of flights owned by <strong>%s</strong>."), $spotter_array[0]['aircraft_owner']).'</p>';
38 38
 
39 39
 	if ($archive === false) {
40
-		$manufacturers_array = $Spotter->countAllAircraftManufacturerByOwner($owner,$filter);
40
+		$manufacturers_array = $Spotter->countAllAircraftManufacturerByOwner($owner, $filter);
41 41
 	} else {
42
-		$manufacturers_array = $SpotterArchive->countAllAircraftManufacturerByOwner($owner,$filter);
42
+		$manufacturers_array = $SpotterArchive->countAllAircraftManufacturerByOwner($owner, $filter);
43 43
 	}
44 44
 	if (!empty($manufacturers_array))
45 45
 	{
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		print '</thead>';
54 54
 		print '<tbody>';
55 55
 		$i = 1;
56
-		foreach($manufacturers_array as $manufacturer_item)
56
+		foreach ($manufacturers_array as $manufacturer_item)
57 57
 		{
58 58
 			print '<tr>';
59 59
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 require_once('require/class.SpotterArchive.php');
5 5
 require_once('require/class.Language.php');
6 6
 if (!isset($_GET['owner'])) {
7
-        header('Location: '.$globalURL.'/owner');
8
-        die();
7
+		header('Location: '.$globalURL.'/owner');
8
+		die();
9 9
 }
10 10
 $Spotter = new Spotter();
11 11
 $SpotterArchive = new SpotterArchive();
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,12 @@
 block discarded – undo
14 14
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15 15
 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
16 16
 $filter = array();
17
-if ($year != '') $filter = array_merge($filter,array('year' => $year));
18
-if ($month != '') $filter = array_merge($filter,array('month' => $month));
17
+if ($year != '') {
18
+	$filter = array_merge($filter,array('year' => $year));
19
+}
20
+if ($month != '') {
21
+	$filter = array_merge($filter,array('month' => $month));
22
+}
19 23
 $archive = false;
20 24
 $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
21 25
 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
Please login to merge, or discard this patch.
owner-statistics-departure-airport-country.php 3 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -9,22 +9,22 @@  discard block
 block discarded – undo
9 9
 }
10 10
 $Spotter = new Spotter();
11 11
 $SpotterArchive = new SpotterArchive();
12
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
13
-$owner = urldecode(filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING));
14
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
12
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
13
+$owner = urldecode(filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING));
14
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
15
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
16 16
 $filter = array();
17
-if ($year != '') $filter = array_merge($filter,array('year' => $year));
18
-if ($month != '') $filter = array_merge($filter,array('month' => $month));
17
+if ($year != '') $filter = array_merge($filter, array('year' => $year));
18
+if ($month != '') $filter = array_merge($filter, array('month' => $month));
19 19
 $archive = false;
20
-$spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
20
+$spotter_array = $Spotter->getSpotterDataByOwner($owner, "0,1", $sort, $filter);
21 21
 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
22 22
 	$archive = true;
23
-	$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
23
+	$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, "0,1", $sort, $filter);
24 24
 }
25 25
 if (!empty($spotter_array))
26 26
 {
27
-	$title = sprintf(_("Most Common Departure Airports by Owner of %s"),$spotter_array[0]['aircraft_owner']);
27
+	$title = sprintf(_("Most Common Departure Airports by Owner of %s"), $spotter_array[0]['aircraft_owner']);
28 28
 	require_once('header.php');
29 29
 	print '<div class="info column">';
30 30
 	print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
 	include('owner-sub-menu.php');
35 35
 	print '<div class="column">';
36 36
 	print '<h2>'._("Most Common Departure Airports by Country").'</h2>';
37
-	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights owned by <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
37
+	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights owned by <strong>%s</strong>."), $spotter_array[0]['aircraft_owner']).'</p>';
38 38
 	if ($archive === false) {
39
-		$airport_country_array = $Spotter->countAllDepartureAirportCountriesByOwner($owner,$filter);
39
+		$airport_country_array = $Spotter->countAllDepartureAirportCountriesByOwner($owner, $filter);
40 40
 	} else {
41
-		$airport_country_array = $SpotterArchive->countAllDepartureAirportCountriesByOwner($owner,$filter);
41
+		$airport_country_array = $SpotterArchive->countAllDepartureAirportCountriesByOwner($owner, $filter);
42 42
 	}
43 43
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
44 44
 	print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
47 47
 	print 'var series = [';
48 48
 	$country_data = '';
49
-	foreach($airport_country_array as $airport_item)
49
+	foreach ($airport_country_array as $airport_item)
50 50
 	{
51 51
 		$country_data .= '[ "'.$airport_item['airport_departure_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],';
52 52
 	}
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 		print '</thead>';
94 94
 		print '<tbody>';
95 95
 		$i = 1;
96
-		foreach($airport_country_array as $airport_item)
96
+		foreach ($airport_country_array as $airport_item)
97 97
 		{
98 98
 			print '<tr>';
99 99
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 require_once('require/class.SpotterArchive.php');
5 5
 require_once('require/class.Language.php');
6 6
 if (!isset($_GET['owner'])) {
7
-        header('Location: '.$globalURL.'/owner');
8
-        die();
7
+		header('Location: '.$globalURL.'/owner');
8
+		die();
9 9
 }
10 10
 $Spotter = new Spotter();
11 11
 $SpotterArchive = new SpotterArchive();
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,12 @@
 block discarded – undo
14 14
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15 15
 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
16 16
 $filter = array();
17
-if ($year != '') $filter = array_merge($filter,array('year' => $year));
18
-if ($month != '') $filter = array_merge($filter,array('month' => $month));
17
+if ($year != '') {
18
+	$filter = array_merge($filter,array('year' => $year));
19
+}
20
+if ($month != '') {
21
+	$filter = array_merge($filter,array('month' => $month));
22
+}
19 23
 $archive = false;
20 24
 $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
21 25
 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
Please login to merge, or discard this patch.
owner-statistics-airline.php 3 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -9,22 +9,22 @@  discard block
 block discarded – undo
9 9
 }
10 10
 $Spotter = new Spotter();
11 11
 $SpotterArchive = new SpotterArchive();
12
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
13
-$owner = urldecode(filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING));
14
-$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15
-$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
12
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
13
+$owner = urldecode(filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING));
14
+$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT);
15
+$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT);
16 16
 $filter = array();
17
-if ($year != '') $filter = array_merge($filter,array('year' => $year));
18
-if ($month != '') $filter = array_merge($filter,array('month' => $month));
17
+if ($year != '') $filter = array_merge($filter, array('year' => $year));
18
+if ($month != '') $filter = array_merge($filter, array('month' => $month));
19 19
 $archive = false;
20
-$spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
20
+$spotter_array = $Spotter->getSpotterDataByOwner($owner, "0,1", $sort, $filter);
21 21
 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
22 22
 	$archive = true;
23
-	$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
23
+	$spotter_array = $SpotterArchive->getSpotterDataByOwner($owner, "0,1", $sort, $filter);
24 24
 }
25 25
 if (!empty($spotter_array))
26 26
 {
27
-	$title = sprintf(_("Most Common Airlines of %s"),$spotter_array[0]['aircraft_owner']);
27
+	$title = sprintf(_("Most Common Airlines of %s"), $spotter_array[0]['aircraft_owner']);
28 28
 	require_once('header.php');
29 29
 	print '<div class="info column">';
30 30
 	print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>';
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
 	include('owner-sub-menu.php');
36 36
 	print '<div class="column">';
37 37
 	print '<h2>'._("Most Common Airlines").'</h2>';
38
-	print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights owned by <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>';
38
+	print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights owned by <strong>%s</strong>."), $spotter_array[0]['aircraft_owner']).'</p>';
39 39
 
40 40
 	if ($archive === false) {
41
-		$airline_array = $Spotter->countAllAirlinesByOwner($owner,$filter);
41
+		$airline_array = $Spotter->countAllAirlinesByOwner($owner, $filter);
42 42
 	} else {
43
-		$airline_array = $SpotterArchive->countAllAirlinesByOwner($owner,$filter);
43
+		$airline_array = $SpotterArchive->countAllAirlinesByOwner($owner, $filter);
44 44
 	}
45 45
 	if (!empty($airline_array))
46 46
 	{
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		print '</thead>';
57 57
 		print '<tbody>';
58 58
 		$i = 1;
59
-		foreach($airline_array as $airline_item)
59
+		foreach ($airline_array as $airline_item)
60 60
 		{
61 61
 			print '<tr>';
62 62
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 require_once('require/class.SpotterArchive.php');
5 5
 require_once('require/class.Language.php');
6 6
 if (!isset($_GET['owner'])) {
7
-        header('Location: '.$globalURL.'/owner');
8
-        die();
7
+		header('Location: '.$globalURL.'/owner');
8
+		die();
9 9
 }
10 10
 $Spotter = new Spotter();
11 11
 $SpotterArchive = new SpotterArchive();
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,12 @@
 block discarded – undo
14 14
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
15 15
 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
16 16
 $filter = array();
17
-if ($year != '') $filter = array_merge($filter,array('year' => $year));
18
-if ($month != '') $filter = array_merge($filter,array('month' => $month));
17
+if ($year != '') {
18
+	$filter = array_merge($filter,array('year' => $year));
19
+}
20
+if ($month != '') {
21
+	$filter = array_merge($filter,array('month' => $month));
22
+}
19 23
 $archive = false;
20 24
 $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter);
21 25
 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
Please login to merge, or discard this patch.
require/class.Common.php 4 patches
Doc Comments   +14 added lines, -1 removed lines patch added patch discarded remove patch
@@ -133,6 +133,9 @@  discard block
 block discarded – undo
133 133
 		fclose($fp);
134 134
 	}
135 135
 
136
+	/**
137
+	 * @param string $in_file
138
+	 */
136 139
 	public static function gunzip($in_file,$out_file_name = '') {
137 140
 		//echo $in_file.' -> '.$out_file_name."\n";
138 141
 		$buffer_size = 4096; // read 4kb at a time
@@ -318,6 +321,9 @@  discard block
 block discarded – undo
318 321
 	}
319 322
 
320 323
 
324
+	/**
325
+	 * @param string $latlong
326
+	 */
321 327
 	public function convertDec($dms,$latlong) {
322 328
 		if ($latlong == 'latitude') {
323 329
 			$deg = substr($dms, 0, 2);
@@ -352,6 +358,9 @@  discard block
 block discarded – undo
352 358
 		return array('latitude' => round($latitude,5),'longitude' => round($longitude,5));
353 359
 	}
354 360
 	
361
+	/**
362
+	 * @param string $latlong
363
+	 */
355 364
 	public function convertDM($coord,$latlong) {
356 365
 		if ($latlong == 'latitude') {
357 366
 			if ($coord < 0) $NSEW = 'S';
@@ -504,7 +513,7 @@  discard block
 block discarded – undo
504 513
 	/**
505 514
 	* Returns list of available locales
506 515
 	*
507
-	* @return array
516
+	* @return string[]
508 517
 	 */
509 518
 	public function listLocaleDir()
510 519
 	{
@@ -765,6 +774,10 @@  discard block
 block discarded – undo
765 774
 	}
766 775
 
767 776
 	// Come from comment : http://php.net/manual/fr/function.is-writable.php#73596
777
+
778
+	/**
779
+	 * @param string $path
780
+	 */
768 781
 	public function is__writable($path) {
769 782
 		//will work in despite of Windows ACLs bug
770 783
 		//NOTE: use a trailing slash for folders!!!
Please login to merge, or discard this patch.
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
 	//protected $cookies = array();
15 15
 	
16 16
 	/**
17
-	* Get data from form result
18
-	* @param String $url form URL
19
-	* @param String $type type of submit form method (get or post)
20
-	* @param String|array $data values form post method
21
-	* @param array $headers header to submit with the form
22
-	* @return String the result
23
-	*/
17
+	 * Get data from form result
18
+	 * @param String $url form URL
19
+	 * @param String $type type of submit form method (get or post)
20
+	 * @param String|array $data values form post method
21
+	 * @param array $headers header to submit with the form
22
+	 * @return String the result
23
+	 */
24 24
 	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '', $sizelimit = false, $async = false, $getheaders = false) {
25 25
 		global $globalProxy, $globalForceIPv4;
26 26
 		$ch = curl_init();
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 	}
176 176
 
177 177
 	/**
178
-	* Convert a HTML table to an array
179
-	* @param String $data HTML page
180
-	* @return array array of the tables in HTML page
181
-	*/
178
+	 * Convert a HTML table to an array
179
+	 * @param String $data HTML page
180
+	 * @return array array of the tables in HTML page
181
+	 */
182 182
 	public function table2array($data) {
183 183
 		if (!is_string($data)) return array();
184 184
 		if ($data == '') return array();
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
 	}
213 213
 	
214 214
 	/**
215
-	* Convert <p> part of a HTML page to an array
216
-	* @param String $data HTML page
217
-	* @return array array of the <p> in HTML page
218
-	*/
215
+	 * Convert <p> part of a HTML page to an array
216
+	 * @param String $data HTML page
217
+	 * @return array array of the <p> in HTML page
218
+	 */
219 219
 	public function text2array($data) {
220 220
 		$html = str_get_html($data);
221 221
 		if ($html === false) return array();
@@ -230,14 +230,14 @@  discard block
 block discarded – undo
230 230
 	}
231 231
 
232 232
 	/**
233
-	* Give distance between 2 coordonnates
234
-	* @param Float $lat latitude of first point
235
-	* @param Float $lon longitude of first point
236
-	* @param Float $latc latitude of second point
237
-	* @param Float $lonc longitude of second point
238
-	* @param String $unit km else no unit used
239
-	* @return Float Distance in $unit
240
-	*/
233
+	 * Give distance between 2 coordonnates
234
+	 * @param Float $lat latitude of first point
235
+	 * @param Float $lon longitude of first point
236
+	 * @param Float $latc latitude of second point
237
+	 * @param Float $lonc longitude of second point
238
+	 * @param String $unit km else no unit used
239
+	 * @return Float Distance in $unit
240
+	 */
241 241
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
242 242
 		if ($lat == $latc && $lon == $lonc) return 0;
243 243
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
@@ -255,12 +255,12 @@  discard block
 block discarded – undo
255 255
 	}
256 256
 
257 257
 	/**
258
-	* Give plunge between 2 altitudes and distance
259
-	* @param Float $initial_altitude altitude of first point in m
260
-	* @param Float $final_altitude altitude of second point in m
261
-	* @param String $distance distance between two points in m
262
-	* @return Float plunge
263
-	*/
258
+	 * Give plunge between 2 altitudes and distance
259
+	 * @param Float $initial_altitude altitude of first point in m
260
+	 * @param Float $final_altitude altitude of second point in m
261
+	 * @param String $distance distance between two points in m
262
+	 * @return Float plunge
263
+	 */
264 264
 	public function plunge($initial_altitude,$final_altitude,$distance) {
265 265
 		$plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance));
266 266
 		/*
@@ -274,13 +274,13 @@  discard block
 block discarded – undo
274 274
 	}
275 275
 
276 276
 	/**
277
-	* Give azimuth between 2 coordonnates
278
-	* @param Float $lat latitude of first point
279
-	* @param Float $lon longitude of first point
280
-	* @param Float $latc latitude of second point
281
-	* @param Float $lonc longitude of second point
282
-	* @return Float Azimuth
283
-	*/
277
+	 * Give azimuth between 2 coordonnates
278
+	 * @param Float $lat latitude of first point
279
+	 * @param Float $lon longitude of first point
280
+	 * @param Float $latc latitude of second point
281
+	 * @param Float $lonc longitude of second point
282
+	 * @return Float Azimuth
283
+	 */
284 284
 	public function azimuth($lat, $lon, $latc, $lonc) {
285 285
 		$dX = $latc - $lat;
286 286
 		$dY = $lonc - $lon;
@@ -291,11 +291,11 @@  discard block
 block discarded – undo
291 291
 	
292 292
 	
293 293
 	/**
294
-	* Check is distance realistic
295
-	* @param int $timeDifference the time between the reception of both messages
296
-	* @param float $distance distance covered
297
-	* @return bool whether distance is realistic
298
-	*/
294
+	 * Check is distance realistic
295
+	 * @param int $timeDifference the time between the reception of both messages
296
+	 * @param float $distance distance covered
297
+	 * @return bool whether distance is realistic
298
+	 */
299 299
 	public function withinThreshold ($timeDifference, $distance) {
300 300
 		$x = abs($timeDifference);
301 301
 		$d = abs($distance);
@@ -383,11 +383,11 @@  discard block
 block discarded – undo
383 383
 	}
384 384
 	
385 385
 	/**
386
-	* Copy folder contents
387
-	* @param       string   $source    Source path
388
-	* @param       string   $dest      Destination path
389
-	* @return      bool     Returns true on success, false on failure
390
-	*/
386
+	 * Copy folder contents
387
+	 * @param       string   $source    Source path
388
+	 * @param       string   $dest      Destination path
389
+	 * @return      bool     Returns true on success, false on failure
390
+	 */
391 391
 	public function xcopy($source, $dest)
392 392
 	{
393 393
 		$files = glob($source.'*.*');
@@ -399,20 +399,20 @@  discard block
 block discarded – undo
399 399
 	}
400 400
 	
401 401
 	/**
402
-	* Check if an url exist
403
-	* @param	String $url url to check
404
-	* @return	bool Return true on succes false on failure
405
-	*/
402
+	 * Check if an url exist
403
+	 * @param	String $url url to check
404
+	 * @return	bool Return true on succes false on failure
405
+	 */
406 406
 	public function urlexist($url){
407 407
 		$headers=get_headers($url);
408 408
 		return stripos($headers[0],"200 OK")?true:false;
409 409
 	}
410 410
 	
411 411
 	/**
412
-	* Convert hexa to string
413
-	* @param	String $hex data in hexa
414
-	* @return	String Return result
415
-	*/
412
+	 * Convert hexa to string
413
+	 * @param	String $hex data in hexa
414
+	 * @return	String Return result
415
+	 */
416 416
 	public function hex2str($hex) {
417 417
 		$str = '';
418 418
 		$hexln = strlen($hex);
@@ -421,10 +421,10 @@  discard block
 block discarded – undo
421 421
 	}
422 422
 	
423 423
 	/**
424
-	* Convert hexa color to rgb
425
-	* @param	String $hex data in hexa
426
-	* @return	String Return result
427
-	*/
424
+	 * Convert hexa color to rgb
425
+	 * @param	String $hex data in hexa
426
+	 * @return	String Return result
427
+	 */
428 428
 	public function hex2rgb($hex) {
429 429
 		$hex = str_replace('#','',$hex);
430 430
 		return sscanf($hex, "%02x%02x%02x"); 
@@ -502,9 +502,9 @@  discard block
 block discarded – undo
502 502
 	}
503 503
 	
504 504
 	/**
505
-	* Returns list of available locales
506
-	*
507
-	* @return array
505
+	 * Returns list of available locales
506
+	 *
507
+	 * @return array
508 508
 	 */
509 509
 	public function listLocaleDir()
510 510
 	{
@@ -603,100 +603,100 @@  discard block
 block discarded – undo
603 603
 	public function remove_accents($string) {
604 604
 		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
605 605
 		$chars = array(
606
-		    // Decompositions for Latin-1 Supplement
607
-		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
608
-		    chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
609
-		    chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
610
-		    chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
611
-		    chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
612
-		    chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
613
-		    chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
614
-		    chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
615
-		    chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
616
-		    chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
617
-		    chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
618
-		    chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
619
-		    chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
620
-		    chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
621
-		    chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
622
-		    chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
623
-		    chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
624
-		    chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
625
-		    chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
626
-		    chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
627
-		    chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
628
-		    chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
629
-		    chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
630
-		    chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
631
-		    chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
632
-		    chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
633
-		    chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
634
-		    chr(195).chr(191) => 'y',
635
-		    // Decompositions for Latin Extended-A
636
-		    chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
637
-		    chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
638
-		    chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
639
-		    chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
640
-		    chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
641
-		    chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
642
-		    chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
643
-		    chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
644
-		    chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
645
-		    chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
646
-		    chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
647
-		    chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
648
-		    chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
649
-		    chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
650
-		    chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
651
-		    chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
652
-		    chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
653
-		    chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
654
-		    chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
655
-		    chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
656
-		    chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
657
-		    chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
658
-		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
659
-		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
660
-		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
661
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
662
-		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
663
-		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
664
-		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
665
-		    chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
666
-		    chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
667
-		    chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
668
-		    chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
669
-		    chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
670
-		    chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
671
-		    chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
672
-		    chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
673
-		    chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
674
-		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
675
-		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
676
-		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
677
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
678
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
679
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
680
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
681
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
682
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
683
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
684
-		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
685
-		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
686
-		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
687
-		    chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
688
-		    chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
689
-		    chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
690
-		    chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
691
-		    chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
692
-		    chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
693
-		    chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
694
-		    chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
695
-		    chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
696
-		    chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
697
-		    chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
698
-		    chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
699
-		    chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
606
+			// Decompositions for Latin-1 Supplement
607
+			chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
608
+			chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
609
+			chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
610
+			chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
611
+			chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
612
+			chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
613
+			chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
614
+			chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
615
+			chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
616
+			chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
617
+			chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
618
+			chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
619
+			chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
620
+			chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
621
+			chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
622
+			chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
623
+			chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
624
+			chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
625
+			chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
626
+			chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
627
+			chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
628
+			chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
629
+			chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
630
+			chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
631
+			chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
632
+			chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
633
+			chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
634
+			chr(195).chr(191) => 'y',
635
+			// Decompositions for Latin Extended-A
636
+			chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
637
+			chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
638
+			chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
639
+			chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
640
+			chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
641
+			chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
642
+			chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
643
+			chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
644
+			chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
645
+			chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
646
+			chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
647
+			chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
648
+			chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
649
+			chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
650
+			chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
651
+			chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
652
+			chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
653
+			chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
654
+			chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
655
+			chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
656
+			chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
657
+			chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
658
+			chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
659
+			chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
660
+			chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
661
+			chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
662
+			chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
663
+			chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
664
+			chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
665
+			chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
666
+			chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
667
+			chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
668
+			chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
669
+			chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
670
+			chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
671
+			chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
672
+			chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
673
+			chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
674
+			chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
675
+			chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
676
+			chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
677
+			chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
678
+			chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
679
+			chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
680
+			chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
681
+			chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
682
+			chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
683
+			chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
684
+			chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
685
+			chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
686
+			chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
687
+			chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
688
+			chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
689
+			chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
690
+			chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
691
+			chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
692
+			chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
693
+			chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
694
+			chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
695
+			chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
696
+			chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
697
+			chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
698
+			chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
699
+			chr(197).chr(190) => 'z', chr(197).chr(191) => 's'
700 700
 		);
701 701
 		$string = strtr($string, $chars);
702 702
 		return $string;
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
 			$dfX = $first_pass[$j][0];
838 838
 			$dfDiffLong = abs($dfX - $dfPrevX);
839 839
 			if ($dfDiffLong > $dfDiffSpace &&
840
-			    (($dfX > $dfLeftBorderX && $dfPrevX < $dfRightBorderX) || ($dfPrevX > $dfLeftBorderX && $dfX < $dfRightBorderX))) 
840
+				(($dfX > $dfLeftBorderX && $dfPrevX < $dfRightBorderX) || ($dfPrevX > $dfLeftBorderX && $dfX < $dfRightBorderX))) 
841 841
 			{
842 842
 				$bHasBigDiff = true;
843 843
 			} else if ($dfDiffLong > $dfMaxSmallDiffLong) {
@@ -857,8 +857,8 @@  discard block
 block discarded – undo
857 857
 					$dfX2 = floatval($first_pass[$k][0]);
858 858
 					$dfY2 = floatval($first_pass[$k][1]);
859 859
 					if ($dfX1 > -180 && $dfX1 < $dfRightBorderX && $dfX2 == 180 &&
860
-					    $k+1 < count($first_pass) &&
861
-					    $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
860
+						$k+1 < count($first_pass) &&
861
+						$first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
862 862
 					{
863 863
 						$poNewLS[] = array(-180, $first_pass[$k][1]);
864 864
 						$k++;
@@ -866,8 +866,8 @@  discard block
 block discarded – undo
866 866
 						$poNewLS[] = array($first_pass[$k][0], $first_pass[$k][1]);
867 867
 						continue;
868 868
 					} else if ($dfX1 > $dfLeftBorderX && $dfX1 < 180 && $dfX2 == -180 &&
869
-					    $k+1 < $first_pass_ln &&
870
-					    $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
869
+						$k+1 < $first_pass_ln &&
870
+						$first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
871 871
 					{
872 872
 						$poNewLS[] = array(180, $first_pass[$k][1]);
873 873
 						$k++;
Please login to merge, or discard this patch.
Spacing   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
 	* @param array $headers header to submit with the form
22 22
 	* @return String the result
23 23
 	*/
24
-	public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '', $sizelimit = false, $async = false, $getheaders = false) {
24
+	public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '', $sizelimit = false, $async = false, $getheaders = false) {
25 25
 		global $globalProxy, $globalForceIPv4;
26 26
 		$ch = curl_init();
27 27
 		curl_setopt($ch, CURLOPT_URL, $url);
28 28
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
29
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
29
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
30 30
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
31 31
 			}
32 32
 		}
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
38 38
 		curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
39 39
 		if ($getheaders) curl_setopt($ch, CURLOPT_HEADER, 1); 
40
-		curl_setopt($ch,CURLOPT_ENCODING , "gzip");
40
+		curl_setopt($ch, CURLOPT_ENCODING, "gzip");
41 41
 		//curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
42 42
 //		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0');
43 43
 		if ($useragent == '') {
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 			if (is_array($data)) {
54 54
 				curl_setopt($ch, CURLOPT_POST, count($data));
55 55
 				$data_string = '';
56
-				foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
56
+				foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; }
57 57
 				rtrim($data_string, '&');
58 58
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
59 59
 			} else {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 		}
66 66
 		if ($cookie != '') {
67 67
 			if (is_array($cookie)) {
68
-				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';'));
68
+				curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';'));
69 69
 			} else {
70 70
 				curl_setopt($ch, CURLOPT_COOKIE, $cookie);
71 71
 			}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		if ($sizelimit === true) {
77 77
 			curl_setopt($ch, CURLOPT_BUFFERSIZE, 128);
78 78
 			curl_setopt($ch, CURLOPT_NOPROGRESS, false);
79
-			curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr,$downloadsize, $downloaded, $uploadsize, $uploaded){
79
+			curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curlr, $downloadsize, $downloaded, $uploadsize, $uploaded) {
80 80
 				return ($downloaded > (3*1024)) ? 1 : 0;
81 81
 			});
82 82
 		}
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
 		$info = curl_getinfo($ch);
89 89
 		//var_dump($info);
90 90
 		curl_close($ch);
91
-		if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) {
91
+		if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) {
92 92
 			echo "Cloudflare Detected\n";
93 93
 			require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php');
94 94
 			$useragent = UAgent::random();
95 95
 			cloudflare::useUserAgent($useragent);
96 96
 			if ($clearanceCookie = cloudflare::bypass($url)) {
97
-				return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent);
97
+				return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent);
98 98
 			}
99 99
 		} else {
100 100
 			return $result;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		curl_setopt($ch, CURLOPT_COOKIEFILE, '');
121 121
 		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
122 122
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
123
-			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
123
+			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')) {
124 124
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
125 125
 			}
126 126
 		}
@@ -138,20 +138,20 @@  discard block
 block discarded – undo
138 138
 		fclose($fp);
139 139
 	}
140 140
 
141
-	public static function gunzip($in_file,$out_file_name = '') {
141
+	public static function gunzip($in_file, $out_file_name = '') {
142 142
 		//echo $in_file.' -> '.$out_file_name."\n";
143 143
 		$buffer_size = 4096; // read 4kb at a time
144 144
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
145 145
 		if ($in_file != '' && file_exists($in_file)) {
146 146
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
147
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
148
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
147
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
148
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
149 149
 			else {
150 150
 				echo 'gzopen not available';
151 151
 				die;
152 152
 			}
153 153
 			$out_file = fopen($out_file_name, 'wb'); 
154
-			while(!gzeof($file)) {
154
+			while (!gzeof($file)) {
155 155
 				fwrite($out_file, gzread($file, $buffer_size));
156 156
 			}  
157 157
 			fclose($out_file);
@@ -159,19 +159,19 @@  discard block
 block discarded – undo
159 159
 		}
160 160
 	}
161 161
 
162
-	public static function bunzip2($in_file,$out_file_name = '') {
162
+	public static function bunzip2($in_file, $out_file_name = '') {
163 163
 		//echo $in_file.' -> '.$out_file_name."\n";
164 164
 		$buffer_size = 4096; // read 4kb at a time
165 165
 		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
166 166
 		if ($in_file != '' && file_exists($in_file)) {
167 167
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
168
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
168
+			if (function_exists('bzopen')) $file = bzopen($in_file, 'rb');
169 169
 			else {
170 170
 				echo 'bzopen not available';
171 171
 				die;
172 172
 			}
173 173
 			$out_file = fopen($out_file_name, 'wb'); 
174
-			while(!feof($file)) {
174
+			while (!feof($file)) {
175 175
 				fwrite($out_file, bzread($file, $buffer_size));
176 176
 			}  
177 177
 			fclose($out_file);
@@ -189,27 +189,27 @@  discard block
 block discarded – undo
189 189
 		if ($data == '') return array();
190 190
 		$html = str_get_html($data);
191 191
 		if ($html === false) return array();
192
-		$tabledata=array();
193
-		foreach($html->find('tr') as $element)
192
+		$tabledata = array();
193
+		foreach ($html->find('tr') as $element)
194 194
 		{
195 195
 			$td = array();
196
-			foreach( $element->find('th') as $row)
196
+			foreach ($element->find('th') as $row)
197 197
 			{
198 198
 				$td [] = trim($row->plaintext);
199 199
 			}
200
-			$td=array_filter($td);
200
+			$td = array_filter($td);
201 201
 			$tabledata[] = $td;
202 202
 
203 203
 			$td = array();
204 204
 			$tdi = array();
205
-			foreach( $element->find('td') as $row)
205
+			foreach ($element->find('td') as $row)
206 206
 			{
207 207
 				$td [] = trim($row->plaintext);
208 208
 				$tdi [] = trim($row->innertext);
209 209
 			}
210
-			$td=array_filter($td);
211
-			$tdi=array_filter($tdi);
212
-			$tabledata[]=array_merge($td,$tdi);
210
+			$td = array_filter($td);
211
+			$tdi = array_filter($tdi);
212
+			$tabledata[] = array_merge($td, $tdi);
213 213
 		}
214 214
 		$html->clear();
215 215
 		unset($html);
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
 	public function text2array($data) {
225 225
 		$html = str_get_html($data);
226 226
 		if ($html === false) return array();
227
-		$tabledata=array();
228
-		foreach($html->find('p') as $element)
227
+		$tabledata = array();
228
+		foreach ($html->find('p') as $element)
229 229
 		{
230 230
 			$tabledata [] = trim($element->plaintext);
231 231
 		}
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
 	*/
246 246
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
247 247
 		if ($lat == $latc && $lon == $lonc) return 0;
248
-		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
248
+		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc))) + cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon) - floatval($lonc)))))*60*1.1515;
249 249
 		if ($unit == "km") {
250
-			return round($dist * 1.609344);
250
+			return round($dist*1.609344);
251 251
 		} elseif ($unit == "m") {
252
-			return round($dist * 1.609344 * 1000);
252
+			return round($dist*1.609344*1000);
253 253
 		} elseif ($unit == "mile" || $unit == "mi") {
254 254
 			return round($dist);
255 255
 		} elseif ($unit == "nm") {
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 	* @param String $distance distance between two points in m
267 267
 	* @return Float plunge
268 268
 	*/
269
-	public function plunge($initial_altitude,$final_altitude,$distance) {
270
-		$plunge = rad2deg(asin(($final_altitude-$initial_altitude)/$distance));
269
+	public function plunge($initial_altitude, $final_altitude, $distance) {
270
+		$plunge = rad2deg(asin(($final_altitude - $initial_altitude)/$distance));
271 271
 		/*
272 272
 		$siter = 6378137.0 + $initial_altitude;
273 273
 		$planer = 6378137.0 + $final_altitude;
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 	public function azimuth($lat, $lon, $latc, $lonc) {
290 290
 		$dX = $latc - $lat;
291 291
 		$dY = $lonc - $lon;
292
-		$azimuth = rad2deg(atan2($dY,$dX));
293
-		if ($azimuth < 0) return $azimuth+360;
292
+		$azimuth = rad2deg(atan2($dY, $dX));
293
+		if ($azimuth < 0) return $azimuth + 360;
294 294
 		return $azimuth;
295 295
 	}
296 296
 	
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	* @param float $distance distance covered
302 302
 	* @return bool whether distance is realistic
303 303
 	*/
304
-	public function withinThreshold ($timeDifference, $distance) {
304
+	public function withinThreshold($timeDifference, $distance) {
305 305
 		$x = abs($timeDifference);
306 306
 		$d = abs($distance);
307 307
 		if ($x == 0 || $d == 0) return true;
@@ -317,13 +317,13 @@  discard block
 block discarded – undo
317 317
 		return ($array !== array_values($array));
318 318
 	}
319 319
 
320
-	public function isInteger($input){
320
+	public function isInteger($input) {
321 321
 		//return(ctype_digit(strval($input)));
322
-		return preg_match('/^-?[0-9]+$/', (string)$input) ? true : false;
322
+		return preg_match('/^-?[0-9]+$/', (string) $input) ? true : false;
323 323
 	}
324 324
 
325 325
 
326
-	public function convertDec($dms,$latlong) {
326
+	public function convertDec($dms, $latlong) {
327 327
 		if ($latlong == 'latitude') {
328 328
 			$deg = substr($dms, 0, 2);
329 329
 			$min = substr($dms, 2, 4);
@@ -331,33 +331,33 @@  discard block
 block discarded – undo
331 331
 			$deg = substr($dms, 0, 3);
332 332
 			$min = substr($dms, 3, 5);
333 333
 		}
334
-		return $deg+(($min*60)/3600);
334
+		return $deg + (($min*60)/3600);
335 335
 	}
336 336
 	
337 337
 	public function convertDecLatLong($coord) {
338 338
 		//N43°36.763' W5°46.845'
339
-		$coords = explode(' ',$coord);
339
+		$coords = explode(' ', $coord);
340 340
 		$latitude = '';
341 341
 		$longitude = '';
342 342
 		foreach ($coords as $latlong) {
343
-			$type = substr($latlong,0,1);
344
-			$degmin = explode('°',substr($latlong,1,-1));
343
+			$type = substr($latlong, 0, 1);
344
+			$degmin = explode('°', substr($latlong, 1, -1));
345 345
 			$deg = $degmin[0];
346 346
 			$min = $degmin[1];
347 347
 			if ($type == 'N') {
348
-				$latitude = $deg+(($min*60)/3600);
348
+				$latitude = $deg + (($min*60)/3600);
349 349
 			} elseif ($type == 'S') {
350
-				$latitude = -($deg+(($min*60)/3600));
350
+				$latitude = -($deg + (($min*60)/3600));
351 351
 			} elseif ($type == 'E') {
352
-				$longitude = ($deg+(($min*60)/3600));
352
+				$longitude = ($deg + (($min*60)/3600));
353 353
 			} elseif ($type == 'W') {
354
-				$longitude = -($deg+(($min*60)/3600));
354
+				$longitude = -($deg + (($min*60)/3600));
355 355
 			}
356 356
 		}
357
-		return array('latitude' => round($latitude,5),'longitude' => round($longitude,5));
357
+		return array('latitude' => round($latitude, 5), 'longitude' => round($longitude, 5));
358 358
 	}
359 359
 	
360
-	public function convertDM($coord,$latlong) {
360
+	public function convertDM($coord, $latlong) {
361 361
 		if ($latlong == 'latitude') {
362 362
 			if ($coord < 0) $NSEW = 'S';
363 363
 			else $NSEW = 'N';
@@ -367,11 +367,11 @@  discard block
 block discarded – undo
367 367
 		}
368 368
 		$coord = abs($coord);
369 369
 		$deg = floor($coord);
370
-		$coord = ($coord-$deg)*60;
370
+		$coord = ($coord - $deg)*60;
371 371
 		$min = $coord;
372
-		return array('deg' => $deg,'min' => $min,'NSEW' => $NSEW);
372
+		return array('deg' => $deg, 'min' => $min, 'NSEW' => $NSEW);
373 373
 	}
374
-	public function convertDMS($coord,$latlong) {
374
+	public function convertDMS($coord, $latlong) {
375 375
 		if ($latlong == 'latitude') {
376 376
 			if ($coord < 0) $NSEW = 'S';
377 377
 			else $NSEW = 'N';
@@ -381,10 +381,10 @@  discard block
 block discarded – undo
381 381
 		}
382 382
 		$coord = abs($coord);
383 383
 		$deg = floor($coord);
384
-		$coord = ($coord-$deg)*60;
384
+		$coord = ($coord - $deg)*60;
385 385
 		$min = floor($coord);
386
-		$sec = round(($coord-$min)*60);
387
-		return array('deg' => $deg,'min' => $min,'sec' => $sec,'NSEW' => $NSEW);
386
+		$sec = round(($coord - $min)*60);
387
+		return array('deg' => $deg, 'min' => $min, 'sec' => $sec, 'NSEW' => $NSEW);
388 388
 	}
389 389
 	
390 390
 	/**
@@ -396,8 +396,8 @@  discard block
 block discarded – undo
396 396
 	public function xcopy($source, $dest)
397 397
 	{
398 398
 		$files = glob($source.'*.*');
399
-		foreach($files as $file){
400
-			$file_to_go = str_replace($source,$dest,$file);
399
+		foreach ($files as $file) {
400
+			$file_to_go = str_replace($source, $dest, $file);
401 401
 			copy($file, $file_to_go);
402 402
 		}
403 403
 		return true;
@@ -408,9 +408,9 @@  discard block
 block discarded – undo
408 408
 	* @param	String $url url to check
409 409
 	* @return	bool Return true on succes false on failure
410 410
 	*/
411
-	public function urlexist($url){
412
-		$headers=get_headers($url);
413
-		return stripos($headers[0],"200 OK")?true:false;
411
+	public function urlexist($url) {
412
+		$headers = get_headers($url);
413
+		return stripos($headers[0], "200 OK") ?true:false;
414 414
 	}
415 415
 	
416 416
 	/**
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 	public function hex2str($hex) {
422 422
 		$str = '';
423 423
 		$hexln = strlen($hex);
424
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
424
+		for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2)));
425 425
 		return $str;
426 426
 	}
427 427
 	
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 	* @return	String Return result
432 432
 	*/
433 433
 	public function hex2rgb($hex) {
434
-		$hex = str_replace('#','',$hex);
434
+		$hex = str_replace('#', '', $hex);
435 435
 		return sscanf($hex, "%02x%02x%02x"); 
436 436
 	}
437 437
 	
@@ -439,33 +439,33 @@  discard block
 block discarded – undo
439 439
 		//difference in longitudinal coordinates
440 440
 		$dLon = deg2rad($lon2) - deg2rad($lon1);
441 441
 		//difference in the phi of latitudinal coordinates
442
-		$dPhi = log(tan(deg2rad($lat2) / 2 + M_PI / 4) / tan(deg2rad($lat1) / 2 + M_PI / 4));
442
+		$dPhi = log(tan(deg2rad($lat2)/2 + M_PI/4)/tan(deg2rad($lat1)/2 + M_PI/4));
443 443
 		//we need to recalculate $dLon if it is greater than pi
444
-		if(abs($dLon) > M_PI) {
445
-			if($dLon > 0) {
446
-				$dLon = (2 * M_PI - $dLon) * -1;
444
+		if (abs($dLon) > M_PI) {
445
+			if ($dLon > 0) {
446
+				$dLon = (2*M_PI - $dLon)*-1;
447 447
 			} else {
448
-				$dLon = 2 * M_PI + $dLon;
448
+				$dLon = 2*M_PI + $dLon;
449 449
 			}
450 450
 		}
451 451
 		//return the angle, normalized
452
-		return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360;
452
+		return (rad2deg(atan2($dLon, $dPhi)) + 360)%360;
453 453
 	}
454 454
 
455
-	public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.15) {
455
+	public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.15) {
456 456
 		//$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1);
457
-		$a = -($lon2-$lon1);
457
+		$a = -($lon2 - $lon1);
458 458
 		$b = $lat2 - $lat1;
459
-		$c = -($a*$lat1+$b*$lon1);
460
-		$d = $a*$lat3+$b*$lon3+$c;
459
+		$c = -($a*$lat1 + $b*$lon1);
460
+		$d = $a*$lat3 + $b*$lon3 + $c;
461 461
 		if ($d > -$approx && $d < $approx) return true;
462 462
 		else return false;
463 463
 	}
464 464
 	
465 465
 	public function array_merge_noappend() {
466 466
 		$output = array();
467
-		foreach(func_get_args() as $array) {
468
-			foreach($array as $key => $value) {
467
+		foreach (func_get_args() as $array) {
468
+			foreach ($array as $key => $value) {
469 469
 				$output[$key] = isset($output[$key]) ?
470 470
 				array_merge($output[$key], $value) : $value;
471 471
 			}
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 		return $result;
530 530
 	}
531 531
 
532
-	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = ''){
532
+	public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1, $seconds = '') {
533 533
 		global $globalMapRefresh;
534 534
 		if ($seconds == '') {
535 535
 			$distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000;
@@ -540,27 +540,27 @@  discard block
 block discarded – undo
540 540
 		$latitude = deg2rad($latitude);
541 541
 		$longitude = deg2rad($longitude);
542 542
 		$bearing = deg2rad($heading); 
543
-		$latitude2 =  asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) );
544
-		$longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) );
545
-		return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.',''));
543
+		$latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing)));
544
+		$longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2)));
545
+		return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', ''));
546 546
 	}
547 547
 	
548
-	public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) {
548
+	public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) {
549 549
 		// distance in meter
550 550
 		$R = 6378.14;
551
-		$latitude1 = $latitude * (M_PI/180);
552
-		$longitude1 = $longitude * (M_PI/180);
553
-		$brng = $bearing * (M_PI/180);
551
+		$latitude1 = $latitude*(M_PI/180);
552
+		$longitude1 = $longitude*(M_PI/180);
553
+		$brng = $bearing*(M_PI/180);
554 554
 		$d = $distance;
555 555
 
556 556
 		$latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng));
557
-		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2));
557
+		$longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2));
558 558
 
559
-		$latitude2 = $latitude2 * (180/M_PI);
560
-		$longitude2 = $longitude2 * (180/M_PI);
559
+		$latitude2 = $latitude2*(180/M_PI);
560
+		$longitude2 = $longitude2*(180/M_PI);
561 561
 
562
-		$flat = round ($latitude2,6);
563
-		$flong = round ($longitude2,6);
562
+		$flat = round($latitude2, 6);
563
+		$flong = round($longitude2, 6);
564 564
 /*
565 565
 		$dx = $distance*cos($bearing);
566 566
 		$dy = $distance*sin($bearing);
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 		$flong = $longitude + $dlong;
570 570
 		$flat = $latitude + $dlat;
571 571
 */
572
-		return array('latitude' => $flat,'longitude' => $flong);
572
+		return array('latitude' => $flat, 'longitude' => $flong);
573 573
 	}
574 574
 
575 575
 	/**
@@ -583,14 +583,14 @@  discard block
 block discarded – undo
583 583
 	 * @param integer $level GZIP compression level (default: 9)
584 584
 	 * @return string New filename (with .gz appended) if success, or false if operation fails
585 585
 	 */
586
-	public function gzCompressFile($source, $level = 9){ 
587
-		$dest = $source . '.gz'; 
588
-		$mode = 'wb' . $level; 
586
+	public function gzCompressFile($source, $level = 9) { 
587
+		$dest = $source.'.gz'; 
588
+		$mode = 'wb'.$level; 
589 589
 		$error = false; 
590 590
 		if ($fp_out = gzopen($dest, $mode)) { 
591
-			if ($fp_in = fopen($source,'rb')) { 
591
+			if ($fp_in = fopen($source, 'rb')) { 
592 592
 				while (!feof($fp_in)) 
593
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
593
+					gzwrite($fp_out, fread($fp_in, 1024*512)); 
594 594
 				fclose($fp_in); 
595 595
 			} else {
596 596
 				$error = true; 
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 	} 
607 607
 	
608 608
 	public function remove_accents($string) {
609
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
609
+		if (!preg_match('/[\x80-\xff]/', $string)) return $string;
610 610
 		$chars = array(
611 611
 		    // Decompositions for Latin-1 Supplement
612 612
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 		    chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
664 664
 		    chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
665 665
 		    chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
666
-		    chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
666
+		    chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij',
667 667
 		    chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
668 668
 		    chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
669 669
 		    chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
@@ -679,13 +679,13 @@  discard block
 block discarded – undo
679 679
 		    chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
680 680
 		    chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
681 681
 		    chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
682
-		    chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
683
-		    chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
684
-		    chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
685
-		    chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
686
-		    chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
687
-		    chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
688
-		    chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
682
+		    chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
683
+		    chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
684
+		    chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
685
+		    chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
686
+		    chr(197).chr(154) => 'S', chr(197).chr(155) => 's',
687
+		    chr(197).chr(156) => 'S', chr(197).chr(157) => 's',
688
+		    chr(197).chr(158) => 'S', chr(197).chr(159) => 's',
689 689
 		    chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
690 690
 		    chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
691 691
 		    chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 		for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) {
720 720
 			if (is_numeric($string[$i]) && $concat_flag) {
721 721
 				$int .= $string[$i];
722
-			} elseif(!$concat && $concat_flag && strlen($int) > 0) {
722
+			} elseif (!$concat && $concat_flag && strlen($int) > 0) {
723 723
 				$concat_flag = false;
724 724
 			}
725 725
 		}
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
 			$slice = array_slice($arr, $offset + 1, $length);
766 766
 			return implode("", $slice);
767 767
 		} else {
768
-			return mb_substr($string,$offset,$length,'UTF-8');
768
+			return mb_substr($string, $offset, $length, 'UTF-8');
769 769
 		}
770 770
 	}
771 771
 
@@ -775,14 +775,14 @@  discard block
 block discarded – undo
775 775
 		//NOTE: use a trailing slash for folders!!!
776 776
 		//see http://bugs.php.net/bug.php?id=27609
777 777
 		//see http://bugs.php.net/bug.php?id=30931
778
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
778
+		if ($path{strlen($path) - 1} == '/') // recursively return a temporary file path
779 779
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
780 780
 		else if (is_dir($path))
781 781
 			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
782 782
 		// check tmp file for read/write capabilities
783 783
 		$rm = file_exists($path);
784 784
 		$f = @fopen($path, 'a');
785
-		if ($f===false)
785
+		if ($f === false)
786 786
 			return false;
787 787
 		fclose($f);
788 788
 		if (!$rm)
@@ -801,29 +801,29 @@  discard block
 block discarded – undo
801 801
 	 * @param Integer $offset Controls the likelyhood that lines will be split which cross the dateline
802 802
 	 * @return Array Coordinate of the route
803 803
 	*/
804
-	public function greatcircle($begin_lat,$begin_lon,$end_lat,$end_lon,$nbpts = 20, $offset = 10) {
805
-		if ($nbpts <= 2) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
804
+	public function greatcircle($begin_lat, $begin_lon, $end_lat, $end_lon, $nbpts = 20, $offset = 10) {
805
+		if ($nbpts <= 2) return array(array($begin_lon, $begin_lat), array($end_lon, $end_lat));
806 806
 		$sx = deg2rad($begin_lon);
807 807
 		$sy = deg2rad($begin_lat);
808 808
 		$ex = deg2rad($end_lon);
809 809
 		$ey = deg2rad($end_lat);
810 810
 		$w = $sx - $ex;
811 811
 		$h = $sy - $ey;
812
-		$z = pow(sin($h/2.0),2) + cos($sy)*cos($ey)*pow(sin($w/2.0),2);
812
+		$z = pow(sin($h/2.0), 2) + cos($sy)*cos($ey)*pow(sin($w/2.0), 2);
813 813
 		$g = 2.0*asin(sqrt($z));
814
-		if ($g == M_PI || is_nan($g)) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
814
+		if ($g == M_PI || is_nan($g)) return array(array($begin_lon, $begin_lat), array($end_lon, $end_lat));
815 815
 		$first_pass = array();
816
-		$delta = 1.0/($nbpts-1);
817
-		for ($i =0; $i < $nbpts; ++$i) {
816
+		$delta = 1.0/($nbpts - 1);
817
+		for ($i = 0; $i < $nbpts; ++$i) {
818 818
 			$step = $delta*$i;
819
-			$A = sin((1 - $step) * $g) / sin($g);
820
-			$B = sin($step * $g) / sin($g);
821
-			$x = $A * cos($sy) * cos($sx) + $B * cos($ey) * cos($ex);
822
-			$y = $A * cos($sy) * sin($sx) + $B * cos($ey) * sin($ex);
823
-			$z = $A * sin($sy) + $B * sin($ey);
819
+			$A = sin((1 - $step)*$g)/sin($g);
820
+			$B = sin($step*$g)/sin($g);
821
+			$x = $A*cos($sy)*cos($sx) + $B*cos($ey)*cos($ex);
822
+			$y = $A*cos($sy)*sin($sx) + $B*cos($ey)*sin($ex);
823
+			$z = $A*sin($sy) + $B*sin($ey);
824 824
 			$lat = rad2deg(atan2($z, sqrt(pow($x, 2) + pow($y, 2))));
825 825
 			$lon = rad2deg(atan2($y, $x));
826
-			$first_pass[] = array($lon,$lat);
826
+			$first_pass[] = array($lon, $lat);
827 827
 		}
828 828
 		$bHasBigDiff = false;
829 829
 		$dfMaxSmallDiffLong = 0;
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 		// https://github.com/OSGeo/gdal/blob/7bfb9c452a59aac958bff0c8386b891edf8154ca/gdal/ogr/ogrgeometryfactory.cpp#L2342
839 839
 		$first_pass_ln = count($first_pass);
840 840
 		for ($j = 1; $j < $first_pass_ln; ++$j) {
841
-			$dfPrevX = $first_pass[$j-1][0];
841
+			$dfPrevX = $first_pass[$j - 1][0];
842 842
 			$dfX = $first_pass[$j][0];
843 843
 			$dfDiffLong = abs($dfX - $dfPrevX);
844 844
 			if ($dfDiffLong > $dfDiffSpace &&
@@ -856,14 +856,14 @@  discard block
 block discarded – undo
856 856
 			//$poMulti[] = $poNewLS;
857 857
 			for ($k = 0; $k < $first_pass_ln; ++$k) {
858 858
 				$dfX0 = floatval($first_pass[$k][0]);
859
-				if ($k > 0 &&  abs($dfX0 - $first_pass[$k-1][0]) > $dfDiffSpace) {
860
-					$dfX1 = floatval($first_pass[$k-1][0]);
861
-					$dfY1 = floatval($first_pass[$k-1][1]);
859
+				if ($k > 0 && abs($dfX0 - $first_pass[$k - 1][0]) > $dfDiffSpace) {
860
+					$dfX1 = floatval($first_pass[$k - 1][0]);
861
+					$dfY1 = floatval($first_pass[$k - 1][1]);
862 862
 					$dfX2 = floatval($first_pass[$k][0]);
863 863
 					$dfY2 = floatval($first_pass[$k][1]);
864 864
 					if ($dfX1 > -180 && $dfX1 < $dfRightBorderX && $dfX2 == 180 &&
865
-					    $k+1 < count($first_pass) &&
866
-					    $first_pass[$k-1][0] > -180 && $first_pass[$k-1][0] < $dfRightBorderX)
865
+					    $k + 1 < count($first_pass) &&
866
+					    $first_pass[$k - 1][0] > -180 && $first_pass[$k - 1][0] < $dfRightBorderX)
867 867
 					{
868 868
 						$poNewLS[] = array(-180, $first_pass[$k][1]);
869 869
 						$k++;
@@ -871,8 +871,8 @@  discard block
 block discarded – undo
871 871
 						$poNewLS[] = array($first_pass[$k][0], $first_pass[$k][1]);
872 872
 						continue;
873 873
 					} else if ($dfX1 > $dfLeftBorderX && $dfX1 < 180 && $dfX2 == -180 &&
874
-					    $k+1 < $first_pass_ln &&
875
-					    $first_pass[$k-1][0] > $dfLeftBorderX && $first_pass[$k-1][0] < 180)
874
+					    $k + 1 < $first_pass_ln &&
875
+					    $first_pass[$k - 1][0] > $dfLeftBorderX && $first_pass[$k - 1][0] < 180)
876 876
 					{
877 877
 						$poNewLS[] = array(180, $first_pass[$k][1]);
878 878
 						$k++;
@@ -895,12 +895,12 @@  discard block
 block discarded – undo
895 895
 					}
896 896
 					if ($dfX1 <= 180 && $dfX2 >= 180 && $dfX1 < $dfX2)
897 897
 					{
898
-						$dfRatio = (180 - $dfX1) / ($dfX2 - $dfX1);
899
-						$dfY = $dfRatio * $dfY2 + (1 - $dfRatio) * $dfY1;
900
-						$poNewLS[] = array($first_pass[$k-1][0] > $dfLeftBorderX ? 180 : -180, $dfY);
898
+						$dfRatio = (180 - $dfX1)/($dfX2 - $dfX1);
899
+						$dfY = $dfRatio*$dfY2 + (1 - $dfRatio)*$dfY1;
900
+						$poNewLS[] = array($first_pass[$k - 1][0] > $dfLeftBorderX ? 180 : -180, $dfY);
901 901
 						$poMulti[] = $poNewLS;
902 902
 						$poNewLS = array();
903
-						$poNewLS[] = array($first_pass[$k-1][0] > $dfLeftBorderX ? -180 : 180, $dfY);
903
+						$poNewLS[] = array($first_pass[$k - 1][0] > $dfLeftBorderX ? -180 : 180, $dfY);
904 904
 						//$poMulti[] = $poNewLS;
905 905
 					} else {
906 906
 						//$poNewLS[] = array();
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
 			$poNewLS0 = array();
919 919
 			//$poMulti[] = $poNewLS0;
920 920
 			for ($l = 0; $l < $first_pass_ln; ++$l) {
921
-				$poNewLS0[] = array($first_pass[$l][0],$first_pass[$l][1]);
921
+				$poNewLS0[] = array($first_pass[$l][0], $first_pass[$l][1]);
922 922
 			}
923 923
 			$poMulti[] = $poNewLS0;
924 924
 		}
Please login to merge, or discard this patch.
Braces   +123 added lines, -53 removed lines patch added patch discarded remove patch
@@ -36,7 +36,9 @@  discard block
 block discarded – undo
36 36
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
37 37
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
38 38
 		curl_setopt($ch, CURLINFO_HEADER_OUT, true); 
39
-		if ($getheaders) curl_setopt($ch, CURLOPT_HEADER, 1); 
39
+		if ($getheaders) {
40
+			curl_setopt($ch, CURLOPT_HEADER, 1);
41
+		}
40 42
 		curl_setopt($ch,CURLOPT_ENCODING , "gzip");
41 43
 		//curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
42 44
 //		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0');
@@ -45,8 +47,11 @@  discard block
 block discarded – undo
45 47
 		} else {
46 48
 			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
47 49
 		}
48
-		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
49
-		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
50
+		if ($timeout == '') {
51
+			curl_setopt($ch, CURLOPT_TIMEOUT, 10);
52
+		} else {
53
+			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
54
+		}
50 55
 		//curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
51 56
 		if ($type == 'post') {
52 57
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@@ -59,7 +64,9 @@  discard block
 block discarded – undo
59 64
 			} else {
60 65
 				curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
61 66
 			}
62
-		} elseif ($type != 'get' && $type != '') curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
67
+		} elseif ($type != 'get' && $type != '') {
68
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
69
+		}
63 70
 		if ($headers != '') {
64 71
 			curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
65 72
 		}
@@ -104,8 +111,9 @@  discard block
 block discarded – undo
104 111
 	private function curlResponseHeaderCallback($ch, $headerLine) {
105 112
 		global $curl_cookies;
106 113
 		$curl_cookies = array();
107
-		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
108
-			$curl_cookies[] = $cookie;
114
+		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
115
+					$curl_cookies[] = $cookie;
116
+		}
109 117
 		return strlen($headerLine); // Needed by curl
110 118
 	}
111 119
 
@@ -118,7 +126,9 @@  discard block
 block discarded – undo
118 126
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
119 127
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
120 128
 		curl_setopt($ch, CURLOPT_COOKIEFILE, '');
121
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
129
+		if ($referer != '') {
130
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
131
+		}
122 132
 		if (isset($globalForceIPv4) && $globalForceIPv4) {
123 133
 			if (defined('CURLOPT_IPRESOLVE') && defined('CURL_IPRESOLVE_V4')){
124 134
 				curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
@@ -133,7 +143,9 @@  discard block
 block discarded – undo
133 143
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
134 144
 		curl_setopt($ch, CURLOPT_FILE, $fp);
135 145
 		curl_exec($ch);
136
-		if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch);
146
+		if (curl_errno($ch) && $globalDebug) {
147
+			echo 'Download error: '.curl_error($ch);
148
+		}
137 149
 		curl_close($ch);
138 150
 		fclose($fp);
139 151
 	}
@@ -141,12 +153,16 @@  discard block
 block discarded – undo
141 153
 	public static function gunzip($in_file,$out_file_name = '') {
142 154
 		//echo $in_file.' -> '.$out_file_name."\n";
143 155
 		$buffer_size = 4096; // read 4kb at a time
144
-		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
156
+		if ($out_file_name == '') {
157
+			$out_file_name = str_replace('.gz', '', $in_file);
158
+		}
145 159
 		if ($in_file != '' && file_exists($in_file)) {
146 160
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
147
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
148
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
149
-			else {
161
+			if (function_exists('gzopen')) {
162
+				$file = gzopen($in_file,'rb');
163
+			} elseif (function_exists('gzopen64')) {
164
+				$file = gzopen64($in_file,'rb');
165
+			} else {
150 166
 				echo 'gzopen not available';
151 167
 				die;
152 168
 			}
@@ -162,11 +178,14 @@  discard block
 block discarded – undo
162 178
 	public static function bunzip2($in_file,$out_file_name = '') {
163 179
 		//echo $in_file.' -> '.$out_file_name."\n";
164 180
 		$buffer_size = 4096; // read 4kb at a time
165
-		if ($out_file_name == '') $out_file_name = str_replace('.bz2', '', $in_file); 
181
+		if ($out_file_name == '') {
182
+			$out_file_name = str_replace('.bz2', '', $in_file);
183
+		}
166 184
 		if ($in_file != '' && file_exists($in_file)) {
167 185
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
168
-			if (function_exists('bzopen')) $file = bzopen($in_file,'rb');
169
-			else {
186
+			if (function_exists('bzopen')) {
187
+				$file = bzopen($in_file,'rb');
188
+			} else {
170 189
 				echo 'bzopen not available';
171 190
 				die;
172 191
 			}
@@ -185,10 +204,16 @@  discard block
 block discarded – undo
185 204
 	* @return array array of the tables in HTML page
186 205
 	*/
187 206
 	public function table2array($data) {
188
-		if (!is_string($data)) return array();
189
-		if ($data == '') return array();
207
+		if (!is_string($data)) {
208
+			return array();
209
+		}
210
+		if ($data == '') {
211
+			return array();
212
+		}
190 213
 		$html = str_get_html($data);
191
-		if ($html === false) return array();
214
+		if ($html === false) {
215
+			return array();
216
+		}
192 217
 		$tabledata=array();
193 218
 		foreach($html->find('tr') as $element)
194 219
 		{
@@ -223,7 +248,9 @@  discard block
 block discarded – undo
223 248
 	*/
224 249
 	public function text2array($data) {
225 250
 		$html = str_get_html($data);
226
-		if ($html === false) return array();
251
+		if ($html === false) {
252
+			return array();
253
+		}
227 254
 		$tabledata=array();
228 255
 		foreach($html->find('p') as $element)
229 256
 		{
@@ -244,7 +271,9 @@  discard block
 block discarded – undo
244 271
 	* @return Float Distance in $unit
245 272
 	*/
246 273
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
247
-		if ($lat == $latc && $lon == $lonc) return 0;
274
+		if ($lat == $latc && $lon == $lonc) {
275
+			return 0;
276
+		}
248 277
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
249 278
 		if ($unit == "km") {
250 279
 			return round($dist * 1.609344);
@@ -290,7 +319,9 @@  discard block
 block discarded – undo
290 319
 		$dX = $latc - $lat;
291 320
 		$dY = $lonc - $lon;
292 321
 		$azimuth = rad2deg(atan2($dY,$dX));
293
-		if ($azimuth < 0) return $azimuth+360;
322
+		if ($azimuth < 0) {
323
+			return $azimuth+360;
324
+		}
294 325
 		return $azimuth;
295 326
 	}
296 327
 	
@@ -304,10 +335,16 @@  discard block
 block discarded – undo
304 335
 	public function withinThreshold ($timeDifference, $distance) {
305 336
 		$x = abs($timeDifference);
306 337
 		$d = abs($distance);
307
-		if ($x == 0 || $d == 0) return true;
338
+		if ($x == 0 || $d == 0) {
339
+			return true;
340
+		}
308 341
 		// may be due to Internet jitter; distance is realistic
309
-		if ($x < 0.7 && $d < 2000) return true;
310
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
342
+		if ($x < 0.7 && $d < 2000) {
343
+			return true;
344
+		} else {
345
+			return $d/$x < 1500*0.27778;
346
+		}
347
+		// 1500 km/h max
311 348
 	}
312 349
 
313 350
 
@@ -359,11 +396,17 @@  discard block
 block discarded – undo
359 396
 	
360 397
 	public function convertDM($coord,$latlong) {
361 398
 		if ($latlong == 'latitude') {
362
-			if ($coord < 0) $NSEW = 'S';
363
-			else $NSEW = 'N';
399
+			if ($coord < 0) {
400
+				$NSEW = 'S';
401
+			} else {
402
+				$NSEW = 'N';
403
+			}
364 404
 		} else {
365
-			if ($coord < 0) $NSEW = 'W';
366
-			else $NSEW = 'E';
405
+			if ($coord < 0) {
406
+				$NSEW = 'W';
407
+			} else {
408
+				$NSEW = 'E';
409
+			}
367 410
 		}
368 411
 		$coord = abs($coord);
369 412
 		$deg = floor($coord);
@@ -373,11 +416,17 @@  discard block
 block discarded – undo
373 416
 	}
374 417
 	public function convertDMS($coord,$latlong) {
375 418
 		if ($latlong == 'latitude') {
376
-			if ($coord < 0) $NSEW = 'S';
377
-			else $NSEW = 'N';
419
+			if ($coord < 0) {
420
+				$NSEW = 'S';
421
+			} else {
422
+				$NSEW = 'N';
423
+			}
378 424
 		} else {
379
-			if ($coord < 0) $NSEW = 'W';
380
-			else $NSEW = 'E';
425
+			if ($coord < 0) {
426
+				$NSEW = 'W';
427
+			} else {
428
+				$NSEW = 'E';
429
+			}
381 430
 		}
382 431
 		$coord = abs($coord);
383 432
 		$deg = floor($coord);
@@ -421,7 +470,9 @@  discard block
 block discarded – undo
421 470
 	public function hex2str($hex) {
422 471
 		$str = '';
423 472
 		$hexln = strlen($hex);
424
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
473
+		for($i=0;$i<$hexln;$i+=2) {
474
+			$str .= chr(hexdec(substr($hex,$i,2)));
475
+		}
425 476
 		return $str;
426 477
 	}
427 478
 	
@@ -458,8 +509,11 @@  discard block
 block discarded – undo
458 509
 		$b = $lat2 - $lat1;
459 510
 		$c = -($a*$lat1+$b*$lon1);
460 511
 		$d = $a*$lat3+$b*$lon3+$c;
461
-		if ($d > -$approx && $d < $approx) return true;
462
-		else return false;
512
+		if ($d > -$approx && $d < $approx) {
513
+			return true;
514
+		} else {
515
+			return false;
516
+		}
463 517
 	}
464 518
 	
465 519
 	public function array_merge_noappend() {
@@ -518,7 +572,9 @@  discard block
 block discarded – undo
518 572
 			return $result;
519 573
 		}
520 574
 		$handle = @opendir('./locale');
521
-		if ($handle === false) return $result;
575
+		if ($handle === false) {
576
+			return $result;
577
+		}
522 578
 		while (false !== ($file = readdir($handle))) {
523 579
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
524 580
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -589,8 +645,9 @@  discard block
 block discarded – undo
589 645
 		$error = false; 
590 646
 		if ($fp_out = gzopen($dest, $mode)) { 
591 647
 			if ($fp_in = fopen($source,'rb')) { 
592
-				while (!feof($fp_in)) 
593
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
648
+				while (!feof($fp_in)) {
649
+									gzwrite($fp_out, fread($fp_in, 1024 * 512));
650
+				}
594 651
 				fclose($fp_in); 
595 652
 			} else {
596 653
 				$error = true; 
@@ -599,14 +656,17 @@  discard block
 block discarded – undo
599 656
 		} else {
600 657
 			$error = true; 
601 658
 		}
602
-		if ($error)
603
-			return false; 
604
-		else
605
-			return $dest; 
659
+		if ($error) {
660
+					return false;
661
+		} else {
662
+					return $dest;
663
+		}
606 664
 	} 
607 665
 	
608 666
 	public function remove_accents($string) {
609
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
667
+		if ( !preg_match('/[\x80-\xff]/', $string) ) {
668
+			return $string;
669
+		}
610 670
 		$chars = array(
611 671
 		    // Decompositions for Latin-1 Supplement
612 672
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -730,7 +790,9 @@  discard block
 block discarded – undo
730 790
 		$ip = gethostbyname($host);
731 791
 		$s = socket_create(AF_INET, SOCK_STREAM, 0);
732 792
 		$r = @socket_connect($s, $ip, $port);
733
-		if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
793
+		if (!socket_set_nonblock($s)) {
794
+			echo "Unable to set nonblock on socket\n";
795
+		}
734 796
 		if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
735 797
 			return $s;
736 798
 		}
@@ -775,18 +837,22 @@  discard block
 block discarded – undo
775 837
 		//NOTE: use a trailing slash for folders!!!
776 838
 		//see http://bugs.php.net/bug.php?id=27609
777 839
 		//see http://bugs.php.net/bug.php?id=30931
778
-		if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
840
+		if ($path{strlen($path)-1}=='/') {
841
+			// recursively return a temporary file path
779 842
 			return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
780
-		else if (is_dir($path))
781
-			return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
843
+		} else if (is_dir($path)) {
844
+					return $this->is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
845
+		}
782 846
 		// check tmp file for read/write capabilities
783 847
 		$rm = file_exists($path);
784 848
 		$f = @fopen($path, 'a');
785
-		if ($f===false)
786
-			return false;
849
+		if ($f===false) {
850
+					return false;
851
+		}
787 852
 		fclose($f);
788
-		if (!$rm)
789
-			unlink($path);
853
+		if (!$rm) {
854
+					unlink($path);
855
+		}
790 856
 		return true;
791 857
 	}
792 858
 	
@@ -802,7 +868,9 @@  discard block
 block discarded – undo
802 868
 	 * @return Array Coordinate of the route
803 869
 	*/
804 870
 	public function greatcircle($begin_lat,$begin_lon,$end_lat,$end_lon,$nbpts = 20, $offset = 10) {
805
-		if ($nbpts <= 2) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
871
+		if ($nbpts <= 2) {
872
+			return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
873
+		}
806 874
 		$sx = deg2rad($begin_lon);
807 875
 		$sy = deg2rad($begin_lat);
808 876
 		$ex = deg2rad($end_lon);
@@ -811,7 +879,9 @@  discard block
 block discarded – undo
811 879
 		$h = $sy - $ey;
812 880
 		$z = pow(sin($h/2.0),2) + cos($sy)*cos($ey)*pow(sin($w/2.0),2);
813 881
 		$g = 2.0*asin(sqrt($z));
814
-		if ($g == M_PI || is_nan($g)) return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
882
+		if ($g == M_PI || is_nan($g)) {
883
+			return array(array($begin_lon,$begin_lat),array($end_lon,$end_lat));
884
+		}
815 885
 		$first_pass = array();
816 886
 		$delta = 1.0/($nbpts-1);
817 887
 		for ($i =0; $i < $nbpts; ++$i) {
Please login to merge, or discard this patch.
require/class.Image.php 4 patches
Doc Comments   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -286,6 +286,7 @@  discard block
 block discarded – undo
286 286
 	*
287 287
 	* @param String $aircraft_registration the registration of the aircraft
288 288
 	* @param String $aircraft_name type of the aircraft
289
+	* @param string $type
289 290
 	* @return array the aircraft thumbnail, orignal url and copyright
290 291
 	*
291 292
 	*/
@@ -318,7 +319,7 @@  discard block
 block discarded – undo
318 319
     /**
319 320
      * Gets the aircraft image from Deviantart
320 321
      *
321
-     * @param $type
322
+     * @param string $type
322 323
      * @param String $registration the registration of the aircraft
323 324
      * @param String $name type of the aircraft
324 325
      * @return array the aircraft thumbnail, orignal url and copyright
@@ -360,6 +361,7 @@  discard block
 block discarded – undo
360 361
 	*
361 362
 	* @param String $aircraft_registration the registration of the aircraft
362 363
 	* @param String $aircraft_name type of the aircraft
364
+	* @param string $type
363 365
 	* @return array the aircraft thumbnail, orignal url and copyright
364 366
 	*
365 367
 	*/
@@ -402,6 +404,7 @@  discard block
 block discarded – undo
402 404
 	*
403 405
 	* @param String $aircraft_registration the registration of the aircraft
404 406
 	* @param String $aircraft_name type of the aircraft
407
+	* @param string $type
405 408
 	* @return array the aircraft thumbnail, orignal url and copyright
406 409
 	*
407 410
 	*/
@@ -436,6 +439,7 @@  discard block
 block discarded – undo
436 439
 	*
437 440
 	* @param String $registration the registration of the aircraft
438 441
 	* @param String $name type of the aircraft
442
+	* @param string $type
439 443
 	* @return array the aircraft thumbnail, orignal url and copyright
440 444
 	*
441 445
 	*/
@@ -466,8 +470,8 @@  discard block
 block discarded – undo
466 470
 	}
467 471
 
468 472
     /**
469
-     * @param $type
470
-     * @param $aircraft_icao
473
+     * @param string $type
474
+     * @param string $aircraft_icao
471 475
      * @param $airline_icao
472 476
      * @return array
473 477
      */
@@ -490,7 +494,7 @@  discard block
 block discarded – undo
490 494
     /**
491 495
      * Gets the aircraft image from Bing
492 496
      *
493
-     * @param $type
497
+     * @param string $type
494 498
      * @param String $aircraft_registration the registration of the aircraft
495 499
      * @param String $aircraft_name type of the aircraft
496 500
      * @return array the aircraft thumbnail, orignal url and copyright
@@ -529,6 +533,7 @@  discard block
 block discarded – undo
529 533
 	*
530 534
 	* @param String $aircraft_registration the registration of the aircraft
531 535
 	* @param String $aircraft_name type of the aircraft
536
+	* @param string $type
532 537
 	* @return array the aircraft thumbnail, orignal url and copyright
533 538
 	*
534 539
 	*/
@@ -554,6 +559,7 @@  discard block
 block discarded – undo
554 559
 	*
555 560
 	* @param String $registration the registration of the aircraft/mmsi
556 561
 	* @param String $name name
562
+	* @param string $type
557 563
 	* @return array the aircraft thumbnail, orignal url and copyright
558 564
 	*
559 565
 	*/
@@ -615,6 +621,7 @@  discard block
 block discarded – undo
615 621
 	*
616 622
 	* @param String $registration the registration of the aircraft
617 623
 	* @param String $name type of the aircraft
624
+	* @param string $type
618 625
 	* @return array the aircraft thumbnail, orignal url and copyright
619 626
 	*
620 627
 	*/
Please login to merge, or discard this patch.
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
 		if ($this->db === null) die('Error: No DB connection. (Image)');
23 23
 	}
24 24
 
25
-    /**
26
-     * Gets the images based on the aircraft registration
27
-     *
28
-     * @param $registration
29
-     * @param string $aircraft_icao
30
-     * @param string $airline_icao
31
-     * @return array the images list
32
-     */
25
+	/**
26
+	 * Gets the images based on the aircraft registration
27
+	 *
28
+	 * @param $registration
29
+	 * @param string $aircraft_icao
30
+	 * @param string $airline_icao
31
+	 * @return array the images list
32
+	 */
33 33
 	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
34 34
 	{
35 35
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -49,15 +49,15 @@  discard block
 block discarded – undo
49 49
 		else return array();
50 50
 	}
51 51
 
52
-    /**
53
-     * Gets the images based on the ship name
54
-     *
55
-     * @param $mmsi
56
-     * @param string $imo
57
-     * @param string $name
58
-     * @param string $type_name
59
-     * @return array the images list
60
-     */
52
+	/**
53
+	 * Gets the images based on the ship name
54
+	 *
55
+	 * @param $mmsi
56
+	 * @param string $imo
57
+	 * @param string $name
58
+	 * @param string $type_name
59
+	 * @return array the images list
60
+	 */
61 61
 	public function getMarineImage($mmsi,$imo = '',$name = '',$type_name = '')
62 62
 	{
63 63
 		global $globalMarineImagePics;
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
 		return $result;
95 95
 	}
96 96
 
97
-    /**
98
-     * Gets the image copyright based on the Exif data
99
-     *
100
-     * @param $url
101
-     * @return String image copyright
102
-     */
97
+	/**
98
+	 * Gets the image copyright based on the Exif data
99
+	 *
100
+	 * @param $url
101
+	 * @return String image copyright
102
+	 */
103 103
 	public function getExifCopyright($url) {
104 104
 		$exif = exif_read_data($url);
105 105
 		$copyright = '';
@@ -113,14 +113,14 @@  discard block
 block discarded – undo
113 113
 		return $copyright;
114 114
 	}
115 115
 
116
-    /**
117
-     * Adds the images based on the aircraft registration
118
-     *
119
-     * @param $registration
120
-     * @param string $aircraft_icao
121
-     * @param string $airline_icao
122
-     * @return String either success or error
123
-     */
116
+	/**
117
+	 * Adds the images based on the aircraft registration
118
+	 *
119
+	 * @param $registration
120
+	 * @param string $aircraft_icao
121
+	 * @param string $airline_icao
122
+	 * @return String either success or error
123
+	 */
124 124
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
125 125
 	{
126 126
 		global $globalDebug,$globalAircraftImageFetch, $globalOffline;
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
 		return "success";
148 148
 	}
149 149
 
150
-    /**
151
-     * Adds the images based on the marine name
152
-     *
153
-     * @param $mmsi
154
-     * @param string $imo
155
-     * @param string $name
156
-     * @return String either success or error
157
-     */
150
+	/**
151
+	 * Adds the images based on the marine name
152
+	 *
153
+	 * @param $mmsi
154
+	 * @param string $imo
155
+	 * @param string $name
156
+	 * @return String either success or error
157
+	 */
158 158
 	public function addMarineImage($mmsi,$imo = '',$name = '')
159 159
 	{
160 160
 		global $globalDebug,$globalMarineImageFetch, $globalOffline;
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
 		return "success";
191 191
 	}
192 192
 
193
-    /**
194
-     * Gets the aircraft image
195
-     *
196
-     * @param String $aircraft_registration the registration of the aircraft
197
-     * @param string $aircraft_icao
198
-     * @param string $airline_icao
199
-     * @return array the aircraft thumbnail, orignal url and copyright
200
-     */
193
+	/**
194
+	 * Gets the aircraft image
195
+	 *
196
+	 * @param String $aircraft_registration the registration of the aircraft
197
+	 * @param string $aircraft_icao
198
+	 * @param string $airline_icao
199
+	 * @return array the aircraft thumbnail, orignal url and copyright
200
+	 */
201 201
 	public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '')
202 202
 	{
203 203
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
@@ -241,14 +241,14 @@  discard block
 block discarded – undo
241 241
 	}
242 242
 
243 243
 	/**
244
-	* Gets the vessel image
245
-	*
246
-	* @param String $mmsi the vessel mmsi
247
-	* @param String $imo the vessel imo
248
-	* @param String $name the vessel name
249
-	* @return array the aircraft thumbnail, orignal url and copyright
250
-	*
251
-	*/
244
+	 * Gets the vessel image
245
+	 *
246
+	 * @param String $mmsi the vessel mmsi
247
+	 * @param String $imo the vessel imo
248
+	 * @param String $name the vessel name
249
+	 * @return array the aircraft thumbnail, orignal url and copyright
250
+	 *
251
+	 */
252 252
 	public function findMarineImage($mmsi,$imo = '',$name = '')
253 253
 	{
254 254
 		global $globalMarineImageSources;
@@ -282,13 +282,13 @@  discard block
 block discarded – undo
282 282
 	}
283 283
 
284 284
 	/**
285
-	* Gets the aircraft image from Planespotters
286
-	*
287
-	* @param String $aircraft_registration the registration of the aircraft
288
-	* @param String $aircraft_name type of the aircraft
289
-	* @return array the aircraft thumbnail, orignal url and copyright
290
-	*
291
-	*/
285
+	 * Gets the aircraft image from Planespotters
286
+	 *
287
+	 * @param String $aircraft_registration the registration of the aircraft
288
+	 * @param String $aircraft_name type of the aircraft
289
+	 * @return array the aircraft thumbnail, orignal url and copyright
290
+	 *
291
+	 */
292 292
 	public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') {
293 293
 		$Common = new Common();
294 294
 		// If aircraft registration is only number, also check with aircraft model
@@ -315,14 +315,14 @@  discard block
 block discarded – undo
315 315
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
316 316
 	}
317 317
 
318
-    /**
319
-     * Gets the aircraft image from Deviantart
320
-     *
321
-     * @param $type
322
-     * @param String $registration the registration of the aircraft
323
-     * @param String $name type of the aircraft
324
-     * @return array the aircraft thumbnail, orignal url and copyright
325
-     */
318
+	/**
319
+	 * Gets the aircraft image from Deviantart
320
+	 *
321
+	 * @param $type
322
+	 * @param String $registration the registration of the aircraft
323
+	 * @param String $name type of the aircraft
324
+	 * @return array the aircraft thumbnail, orignal url and copyright
325
+	 */
326 326
 	public function fromDeviantart($type,$registration, $name='') {
327 327
 		$Common = new Common();
328 328
 		if ($type == 'aircraft') {
@@ -356,13 +356,13 @@  discard block
 block discarded – undo
356 356
 	}
357 357
 
358 358
 	/**
359
-	* Gets the aircraft image from JetPhotos
360
-	*
361
-	* @param String $aircraft_registration the registration of the aircraft
362
-	* @param String $aircraft_name type of the aircraft
363
-	* @return array the aircraft thumbnail, orignal url and copyright
364
-	*
365
-	*/
359
+	 * Gets the aircraft image from JetPhotos
360
+	 *
361
+	 * @param String $aircraft_registration the registration of the aircraft
362
+	 * @param String $aircraft_name type of the aircraft
363
+	 * @return array the aircraft thumbnail, orignal url and copyright
364
+	 *
365
+	 */
366 366
 	public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') {
367 367
 		$Common = new Common();
368 368
 		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
@@ -398,13 +398,13 @@  discard block
 block discarded – undo
398 398
 	}
399 399
 
400 400
 	/**
401
-	* Gets the aircraft image from PlanePictures
402
-	*
403
-	* @param String $aircraft_registration the registration of the aircraft
404
-	* @param String $aircraft_name type of the aircraft
405
-	* @return array the aircraft thumbnail, orignal url and copyright
406
-	*
407
-	*/
401
+	 * Gets the aircraft image from PlanePictures
402
+	 *
403
+	 * @param String $aircraft_registration the registration of the aircraft
404
+	 * @param String $aircraft_name type of the aircraft
405
+	 * @return array the aircraft thumbnail, orignal url and copyright
406
+	 *
407
+	 */
408 408
 	public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') {
409 409
 		$Common = new Common();
410 410
 		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
@@ -432,13 +432,13 @@  discard block
 block discarded – undo
432 432
 	}
433 433
 
434 434
 	/**
435
-	* Gets the aircraft image from Flickr
436
-	*
437
-	* @param String $registration the registration of the aircraft
438
-	* @param String $name type of the aircraft
439
-	* @return array the aircraft thumbnail, orignal url and copyright
440
-	*
441
-	*/
435
+	 * Gets the aircraft image from Flickr
436
+	 *
437
+	 * @param String $registration the registration of the aircraft
438
+	 * @param String $name type of the aircraft
439
+	 * @return array the aircraft thumbnail, orignal url and copyright
440
+	 *
441
+	 */
442 442
 	public function fromFlickr($type,$registration,$name='') {
443 443
 		$Common = new Common();
444 444
 		if ($type == 'aircraft') {
@@ -465,13 +465,13 @@  discard block
 block discarded – undo
465 465
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
466 466
 	}
467 467
 
468
-    /**
469
-     * @param $type
470
-     * @param $aircraft_icao
471
-     * @param $airline_icao
472
-     * @return array
473
-     */
474
-    public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) {
468
+	/**
469
+	 * @param $type
470
+	 * @param $aircraft_icao
471
+	 * @param $airline_icao
472
+	 * @return array
473
+	 */
474
+	public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) {
475 475
 		$Common = new Common();
476 476
 		//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
477 477
 		if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) {
@@ -487,14 +487,14 @@  discard block
 block discarded – undo
487 487
 		}
488 488
 	}
489 489
 
490
-    /**
491
-     * Gets the aircraft image from Bing
492
-     *
493
-     * @param $type
494
-     * @param String $aircraft_registration the registration of the aircraft
495
-     * @param String $aircraft_name type of the aircraft
496
-     * @return array the aircraft thumbnail, orignal url and copyright
497
-     */
490
+	/**
491
+	 * Gets the aircraft image from Bing
492
+	 *
493
+	 * @param $type
494
+	 * @param String $aircraft_registration the registration of the aircraft
495
+	 * @param String $aircraft_name type of the aircraft
496
+	 * @return array the aircraft thumbnail, orignal url and copyright
497
+	 */
498 498
 	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
499 499
 		global $globalImageBingKey;
500 500
 		$Common = new Common();
@@ -525,13 +525,13 @@  discard block
 block discarded – undo
525 525
 	}
526 526
 
527 527
 	/**
528
-	* Gets the aircraft image from airport-data
529
-	*
530
-	* @param String $aircraft_registration the registration of the aircraft
531
-	* @param String $aircraft_name type of the aircraft
532
-	* @return array the aircraft thumbnail, orignal url and copyright
533
-	*
534
-	*/
528
+	 * Gets the aircraft image from airport-data
529
+	 *
530
+	 * @param String $aircraft_registration the registration of the aircraft
531
+	 * @param String $aircraft_name type of the aircraft
532
+	 * @return array the aircraft thumbnail, orignal url and copyright
533
+	 *
534
+	 */
535 535
 	public function fromAirportData($type,$aircraft_registration,$aircraft_name='') {
536 536
 		$Common = new Common();
537 537
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
@@ -550,13 +550,13 @@  discard block
 block discarded – undo
550 550
 	}
551 551
 
552 552
 	/**
553
-	* Gets image from WikiMedia
554
-	*
555
-	* @param String $registration the registration of the aircraft/mmsi
556
-	* @param String $name name
557
-	* @return array the aircraft thumbnail, orignal url and copyright
558
-	*
559
-	*/
553
+	 * Gets image from WikiMedia
554
+	 *
555
+	 * @param String $registration the registration of the aircraft/mmsi
556
+	 * @param String $name name
557
+	 * @return array the aircraft thumbnail, orignal url and copyright
558
+	 *
559
+	 */
560 560
 	public function fromWikimedia($type,$registration,$name='') {
561 561
 		$Common = new Common();
562 562
 		if ($type == 'aircraft') {
@@ -611,13 +611,13 @@  discard block
 block discarded – undo
611 611
 	}
612 612
 
613 613
 	/**
614
-	* Gets the aircraft image from custom url
615
-	*
616
-	* @param String $registration the registration of the aircraft
617
-	* @param String $name type of the aircraft
618
-	* @return array the aircraft thumbnail, orignal url and copyright
619
-	*
620
-	*/
614
+	 * Gets the aircraft image from custom url
615
+	 *
616
+	 * @param String $registration the registration of the aircraft
617
+	 * @param String $name type of the aircraft
618
+	 * @return array the aircraft thumbnail, orignal url and copyright
619
+	 *
620
+	 */
621 621
 	public function fromCustomSource($type,$registration,$name='') {
622 622
 		global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug;
623 623
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
Please login to merge, or discard this patch.
Spacing   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -30,22 +30,22 @@  discard block
 block discarded – undo
30 30
      * @param string $airline_icao
31 31
      * @return array the images list
32 32
      */
33
-	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
33
+	public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
34 34
 	{
35
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
36
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
37
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
35
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
36
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
37
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
38 38
 		$reg = $registration;
39 39
 		if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao;
40 40
 		$reg = trim($reg);
41
-		$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 
41
+		$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 
42 42
 			FROM spotter_image 
43 43
 			WHERE spotter_image.registration = :registration LIMIT 1";
44 44
 		$sth = $this->db->prepare($query);
45 45
 		$sth->execute(array(':registration' => $reg));
46 46
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
47 47
 		if (!empty($result)) return $result;
48
-		elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
48
+		elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) return $this->getSpotterImage('', $aircraft_icao, $airline_icao);
49 49
 		else return array();
50 50
 	}
51 51
 
@@ -58,34 +58,34 @@  discard block
 block discarded – undo
58 58
      * @param string $type_name
59 59
      * @return array the images list
60 60
      */
61
-	public function getMarineImage($mmsi,$imo = '',$name = '',$type_name = '')
61
+	public function getMarineImage($mmsi, $imo = '', $name = '', $type_name = '')
62 62
 	{
63 63
 		global $globalMarineImagePics;
64
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
65
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
66
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
67
-		$type_name = str_replace('&#39;',"'",filter_var($type_name,FILTER_SANITIZE_STRING));
64
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
65
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
66
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
67
+		$type_name = str_replace('&#39;', "'", filter_var($type_name, FILTER_SANITIZE_STRING));
68 68
 		if (isset($globalMarineImagePics) && !empty($globalMarineImagePics)) {
69 69
 			if ($type_name != '' && isset($globalMarineImagePics['type'][$type_name])) {
70 70
 				if (!isset($globalMarineImagePics['type'][$type_name]['image_thumbnail'])) {
71 71
 					$globalMarineImagePics['type'][$type_name]['image_thumbnail'] = $globalMarineImagePics['type'][$type_name]['image'];
72 72
 				}
73
-				return array($globalMarineImagePics['type'][$type_name]+array('image_thumbnail' => '','image' => '', 'image_copyright' => '','image_source' => '','image_source_website' => ''));
73
+				return array($globalMarineImagePics['type'][$type_name] + array('image_thumbnail' => '', 'image' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
74 74
 			}
75 75
 		}
76 76
 		$name = trim($name);
77 77
 		if ($mmsi == '' && $imo == '' && $name == '') return array();
78
-		$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 
78
+		$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 
79 79
 			FROM marine_image 
80 80
 			WHERE marine_image.mmsi = :mmsi";
81 81
 		$query_data = array(':mmsi' => $mmsi);
82 82
 		if ($imo != '') {
83 83
 			$query .= " AND marine_image.imo = :imo";
84
-			$query_data = array_merge($query_data,array(':imo' => $imo));
84
+			$query_data = array_merge($query_data, array(':imo' => $imo));
85 85
 		}
86 86
 		if ($name != '') {
87 87
 			$query .= " AND marine_image.name = :name";
88
-			$query_data = array_merge($query_data,array(':name' => $name));
88
+			$query_data = array_merge($query_data, array(':name' => $name));
89 89
 		}
90 90
 		$query .= " LIMIT 1";
91 91
 		$sth = $this->db->prepare($query);
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
 		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
107 107
 		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
108 108
 		if ($copyright != '') {
109
-			$copyright = str_replace('Copyright ','',$copyright);
110
-			$copyright = str_replace('© ','',$copyright);
111
-			$copyright = str_replace('(c) ','',$copyright);
109
+			$copyright = str_replace('Copyright ', '', $copyright);
110
+			$copyright = str_replace('© ', '', $copyright);
111
+			$copyright = str_replace('(c) ', '', $copyright);
112 112
 		}
113 113
 		return $copyright;
114 114
 	}
@@ -121,25 +121,25 @@  discard block
 block discarded – undo
121 121
      * @param string $airline_icao
122 122
      * @return String either success or error
123 123
      */
124
-	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
124
+	public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
125 125
 	{
126
-		global $globalDebug,$globalAircraftImageFetch, $globalOffline;
126
+		global $globalDebug, $globalAircraftImageFetch, $globalOffline;
127 127
 		if ((isset($globalAircraftImageFetch) && $globalAircraftImageFetch === FALSE) || (isset($globalOffline) && $globalOffline === TRUE)) return '';
128
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
128
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
129 129
 		$registration = trim($registration);
130 130
 		//getting the aircraft image
131 131
 		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
132 132
 		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
133 133
 		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
134
-		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
134
+		$image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao);
135 135
 		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
136 136
 		if ($image_url['original'] != '') {
137 137
 			if ($globalDebug) echo 'Found !'."\n";
138
-			$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)";
138
+			$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)";
139 139
 			try {
140 140
 				$sth = $this->db->prepare($query);
141
-				$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']));
142
-			} catch(PDOException $e) {
141
+				$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']));
142
+			} catch (PDOException $e) {
143 143
 				echo $e->getMessage()."\n";
144 144
 				return "error";
145 145
 			}
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
      * @param string $name
156 156
      * @return String either success or error
157 157
      */
158
-	public function addMarineImage($mmsi,$imo = '',$name = '')
158
+	public function addMarineImage($mmsi, $imo = '', $name = '')
159 159
 	{
160
-		global $globalDebug,$globalMarineImageFetch, $globalOffline;
160
+		global $globalDebug, $globalMarineImageFetch, $globalOffline;
161 161
 		if ((isset($globalMarineImageFetch) && !$globalMarineImageFetch) || (isset($globalOffline) && $globalOffline === TRUE)) return '';
162
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
163
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
164
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
162
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
163
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
164
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
165 165
 		$name = trim($name);
166 166
 		$Marine = new Marine($this->db);
167 167
 		if ($imo == '' || $name == '') {
@@ -175,14 +175,14 @@  discard block
 block discarded – undo
175 175
 
176 176
 		//getting the aircraft image
177 177
 		if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...';
178
-		$image_url = $this->findMarineImage($mmsi,$imo,$name);
178
+		$image_url = $this->findMarineImage($mmsi, $imo, $name);
179 179
 		if ($image_url['original'] != '') {
180 180
 			if ($globalDebug) echo 'Found !'."\n";
181
-			$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)";
181
+			$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)";
182 182
 			try {
183 183
 				$sth = $this->db->prepare($query);
184
-				$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']));
185
-			} catch(PDOException $e) {
184
+				$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']));
185
+			} catch (PDOException $e) {
186 186
 				echo $e->getMessage()."\n";
187 187
 				return "error";
188 188
 			}
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
204 204
 		$Spotter = new Spotter($this->db);
205 205
 		if (!isset($globalIVAO)) $globalIVAO = FALSE;
206
-		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
206
+		$aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING);
207 207
 		if ($aircraft_registration != '' && $aircraft_registration != 'NA' && (!isset($globalVA) || $globalVA !== TRUE)) {
208
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
208
+			if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
209 209
 			$aircraft_registration = urlencode(trim($aircraft_registration));
210 210
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
211 211
 			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
@@ -219,25 +219,25 @@  discard block
 block discarded – undo
219 219
 			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
220 220
 			else $aircraft_name = '';
221 221
 			$aircraft_registration = $aircraft_icao;
222
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
222
+		} else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
223 223
 		unset($Spotter);
224
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
224
+		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
225 225
 		foreach ($globalAircraftImageSources as $source) {
226 226
 			$source = strtolower($source);
227
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
228
-			if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
229
-			if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
230
-			if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
231
-			if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
232
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
233
-			if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
234
-			if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
235
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
236
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
227
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft', $aircraft_icao, $airline_icao);
228
+			if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft', $aircraft_registration, $aircraft_name);
229
+			if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft', $aircraft_registration, $aircraft_name);
230
+			if ($source == 'bing') $images_array = $this->fromBing('aircraft', $aircraft_registration, $aircraft_name);
231
+			if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft', $aircraft_registration, $aircraft_name);
232
+			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft', $aircraft_registration, $aircraft_name);
233
+			if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft', $aircraft_registration, $aircraft_name);
234
+			if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft', $aircraft_registration, $aircraft_name);
235
+			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft', $aircraft_registration, $aircraft_name);
236
+			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft', $aircraft_registration, $aircraft_name);
237 237
 			if (isset($images_array) && $images_array['original'] != '') return $images_array;
238 238
 		}
239 239
 		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
240
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
240
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
241 241
 	}
242 242
 
243 243
 	/**
@@ -249,14 +249,14 @@  discard block
 block discarded – undo
249 249
 	* @return array the aircraft thumbnail, orignal url and copyright
250 250
 	*
251 251
 	*/
252
-	public function findMarineImage($mmsi,$imo = '',$name = '')
252
+	public function findMarineImage($mmsi, $imo = '', $name = '')
253 253
 	{
254 254
 		global $globalMarineImageSources;
255
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
255
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
256 256
 		//$imo = filter_var($imo,FILTER_SANITIZE_STRING);
257
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
257
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
258 258
 		$name = trim($name);
259
-		if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
259
+		if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
260 260
 		/*
261 261
 		$Marine = new Marine($this->db);
262 262
 		if ($imo == '' || $name == '') {
@@ -268,17 +268,17 @@  discard block
 block discarded – undo
268 268
 		}
269 269
 		unset($Marine);
270 270
 		*/
271
-		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
271
+		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing');
272 272
 		foreach ($globalMarineImageSources as $source) {
273 273
 			$source = strtolower($source);
274
-			if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name);
275
-			if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name);
276
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name);
277
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name);
278
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name);
274
+			if ($source == 'flickr') $images_array = $this->fromFlickr('marine', $mmsi, $name);
275
+			if ($source == 'bing') $images_array = $this->fromBing('marine', $mmsi, $name);
276
+			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine', $mmsi, $name);
277
+			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine', $mmsi, $name);
278
+			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine', $mmsi, $name);
279 279
 			if (isset($images_array) && $images_array['original'] != '') return $images_array;
280 280
 		}
281
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
281
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
282 282
 	}
283 283
 
284 284
 	/**
@@ -289,30 +289,30 @@  discard block
 block discarded – undo
289 289
 	* @return array the aircraft thumbnail, orignal url and copyright
290 290
 	*
291 291
 	*/
292
-	public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') {
292
+	public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') {
293 293
 		$Common = new Common();
294 294
 		// If aircraft registration is only number, also check with aircraft model
295
-		if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') {
296
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
295
+		if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') {
296
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
297 297
 		} else {
298 298
 			//$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss';
299
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
299
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
300 300
 		}
301 301
 		$data = $Common->getData($url);
302
-		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
302
+		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
303 303
 		if ($xml = simplexml_load_string($data)) {
304 304
 			if (isset($xml->channel->item)) {
305 305
 				$image_url = array();
306
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
306
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
307 307
 				$image_url['thumbnail'] = $thumbnail_url;
308
-				$image_url['original'] = str_replace('thumbnail','original',$thumbnail_url);
309
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
310
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
308
+				$image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url);
309
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
310
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
311 311
 				$image_url['source'] = 'planespotters';
312 312
 				return $image_url;
313 313
 			}
314 314
 		} 
315
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
315
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
316 316
 	}
317 317
 
318 318
     /**
@@ -323,36 +323,36 @@  discard block
 block discarded – undo
323 323
      * @param String $name type of the aircraft
324 324
      * @return array the aircraft thumbnail, orignal url and copyright
325 325
      */
326
-	public function fromDeviantart($type,$registration, $name='') {
326
+	public function fromDeviantart($type, $registration, $name = '') {
327 327
 		$Common = new Common();
328 328
 		if ($type == 'aircraft') {
329 329
 			// If aircraft registration is only number, also check with aircraft model
330
-			if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') {
331
-				$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name);
330
+			if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') {
331
+				$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name);
332 332
 			} else {
333
-				$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration;
333
+				$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration;
334 334
 			}
335 335
 		} elseif ($type == 'marine') {
336
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"';
336
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"';
337 337
 		} else {
338
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"';
338
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"';
339 339
 		}
340 340
 		$data = $Common->getData($url);
341
-		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
341
+		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
342 342
 		if ($xml = simplexml_load_string($data)) {
343 343
 			if (isset($xml->channel->item->link)) {
344 344
 				$image_url = array();
345
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
345
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
346 346
 				$image_url['thumbnail'] = $thumbnail_url;
347
-				$original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
347
+				$original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
348 348
 				$image_url['original'] = $original_url;
349
-				$image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
350
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
349
+				$image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
350
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
351 351
 				$image_url['source'] = 'deviantart';
352 352
 				return $image_url;
353 353
 			}
354 354
 		} 
355
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
355
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
356 356
 	}
357 357
 
358 358
 	/**
@@ -363,38 +363,38 @@  discard block
 block discarded – undo
363 363
 	* @return array the aircraft thumbnail, orignal url and copyright
364 364
 	*
365 365
 	*/
366
-	public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') {
366
+	public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') {
367 367
 		$Common = new Common();
368
-		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
368
+		$url = 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
369 369
 		$data = $Common->getData($url);
370 370
 		$dom = new DOMDocument();
371 371
 		@$dom->loadHTML($data);
372 372
 		$all_pics = array();
373
-		foreach($dom->getElementsByTagName('img') as $image) {
373
+		foreach ($dom->getElementsByTagName('img') as $image) {
374 374
 			if ($image->getAttribute('itemprop') == "http://schema.org/image") {
375 375
 				$all_pics[] = $image->getAttribute('src');
376 376
 			}
377 377
 		}
378 378
 		$all_authors = array();
379
-		foreach($dom->getElementsByTagName('meta') as $author) {
379
+		foreach ($dom->getElementsByTagName('meta') as $author) {
380 380
 			if ($author->getAttribute('itemprop') == "http://schema.org/author") {
381 381
 				$all_authors[] = $author->getAttribute('content');
382 382
 			}
383 383
 		}
384 384
 		$all_ref = array();
385
-		foreach($dom->getElementsByTagName('a') as $link) {
385
+		foreach ($dom->getElementsByTagName('a') as $link) {
386 386
 			$all_ref[] = $link->getAttribute('href');
387 387
 		}
388 388
 		if (isset($all_pics[0])) {
389 389
 			$image_url = array();
390 390
 			$image_url['thumbnail'] = $all_pics[0];
391
-			$image_url['original'] = str_replace('_tb','',$all_pics[0]);
391
+			$image_url['original'] = str_replace('_tb', '', $all_pics[0]);
392 392
 			$image_url['copyright'] = $all_authors[0];
393 393
 			$image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8];
394 394
 			$image_url['source'] = 'JetPhotos';
395 395
 			return $image_url;
396 396
 		}
397
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
397
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
398 398
 	}
399 399
 
400 400
 	/**
@@ -405,30 +405,30 @@  discard block
 block discarded – undo
405 405
 	* @return array the aircraft thumbnail, orignal url and copyright
406 406
 	*
407 407
 	*/
408
-	public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') {
408
+	public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') {
409 409
 		$Common = new Common();
410
-		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
410
+		$url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
411 411
 		$data = $Common->getData($url);
412 412
 		$dom = new DOMDocument();
413 413
 		@$dom->loadHTML($data);
414 414
 		$all_pics = array();
415
-		foreach($dom->getElementsByTagName('img') as $image) {
415
+		foreach ($dom->getElementsByTagName('img') as $image) {
416 416
 			$all_pics[] = $image->getAttribute('src');
417 417
 		}
418 418
 		$all_links = array();
419
-		foreach($dom->getElementsByTagName('a') as $link) {
420
-			$all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href'));
419
+		foreach ($dom->getElementsByTagName('a') as $link) {
420
+			$all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href'));
421 421
 		}
422
-		if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) {
422
+		if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) {
423 423
 			$image_url = array();
424 424
 			$image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1];
425
-			$image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]);
425
+			$image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]);
426 426
 			$image_url['copyright'] = $all_links[6]['text'];
427 427
 			$image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href'];
428 428
 			$image_url['source'] = 'PlanePictures';
429 429
 			return $image_url;
430 430
 		}
431
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
431
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
432 432
 	}
433 433
 
434 434
 	/**
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 	* @return array the aircraft thumbnail, orignal url and copyright
440 440
 	*
441 441
 	*/
442
-	public function fromFlickr($type,$registration,$name='') {
442
+	public function fromFlickr($type, $registration, $name = '') {
443 443
 		$Common = new Common();
444 444
 		if ($type == 'aircraft') {
445 445
 			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);
@@ -449,20 +449,20 @@  discard block
 block discarded – undo
449 449
 			else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship';
450 450
 		}
451 451
 		$data = $Common->getData($url);
452
-		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
452
+		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
453 453
 		if ($xml = simplexml_load_string($data)) {
454 454
 			if (isset($xml->channel->item)) {
455
-				$original_url = trim((string)$xml->channel->item->enclosure->attributes()->url);
455
+				$original_url = trim((string) $xml->channel->item->enclosure->attributes()->url);
456 456
 				$image_url = array();
457 457
 				$image_url['thumbnail'] = $original_url;
458 458
 				$image_url['original'] = $original_url;
459
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
460
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
459
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
460
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
461 461
 				$image_url['source'] = 'flickr';
462 462
 				return $image_url;
463 463
 			}
464 464
 		} 
465
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
465
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
466 466
 	}
467 467
 
468 468
     /**
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 			$image_url['source'] = 'ivao.aero';
484 484
 			return $image_url;
485 485
 		} else {
486
-			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
486
+			return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
487 487
 		}
488 488
 	}
489 489
 
@@ -495,10 +495,10 @@  discard block
 block discarded – undo
495 495
      * @param String $aircraft_name type of the aircraft
496 496
      * @return array the aircraft thumbnail, orignal url and copyright
497 497
      */
498
-	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
498
+	public function fromBing($type, $aircraft_registration, $aircraft_name = '') {
499 499
 		global $globalImageBingKey;
500 500
 		$Common = new Common();
501
-		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
501
+		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
502 502
 		if ($type == 'aircraft') {
503 503
 			if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
504 504
 			else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
@@ -506,8 +506,8 @@  discard block
 block discarded – undo
506 506
 			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';
507 507
 			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';
508 508
 		}
509
-		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
510
-		$data = $Common->getData($url,'get','',$headers);
509
+		$headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey));
510
+		$data = $Common->getData($url, 'get', '', $headers);
511 511
 		$result = json_decode($data);
512 512
 		if (isset($result->d->results[0]->MediaUrl)) {
513 513
 			$image_url = array();
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 			$image_url['source'] = 'bing';
522 522
 			return $image_url;
523 523
 		}
524
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
524
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
525 525
 	}
526 526
 
527 527
 	/**
@@ -532,21 +532,21 @@  discard block
 block discarded – undo
532 532
 	* @return array the aircraft thumbnail, orignal url and copyright
533 533
 	*
534 534
 	*/
535
-	public function fromAirportData($type,$aircraft_registration,$aircraft_name='') {
535
+	public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') {
536 536
 		$Common = new Common();
537 537
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
538 538
 		$data = $Common->getData($url);
539 539
 		$result = json_decode($data);
540 540
 		if (isset($result->count) && $result->count > 0) {
541 541
 			$image_url = array();
542
-			$image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image);
542
+			$image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image);
543 543
 			$image_url['source_website'] = $result->data[0]->link;
544 544
 			$image_url['thumbnail'] = $result->data[0]->image;
545 545
 			$image_url['copyright'] = $result->data[0]->photographer;
546 546
 			$image_url['source'] = 'AirportData';
547 547
 			return $image_url;
548 548
 		}
549
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
549
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
550 550
 	}
551 551
 
552 552
 	/**
@@ -557,20 +557,20 @@  discard block
 block discarded – undo
557 557
 	* @return array the aircraft thumbnail, orignal url and copyright
558 558
 	*
559 559
 	*/
560
-	public function fromWikimedia($type,$registration,$name='') {
560
+	public function fromWikimedia($type, $registration, $name = '') {
561 561
 		$Common = new Common();
562 562
 		if ($type == 'aircraft') {
563 563
 			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);
564 564
 			else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
565 565
 		} elseif ($type == 'marine') {
566 566
 			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"';
567
-			else return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
567
+			else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
568 568
 		}
569 569
 		$data = $Common->getData($url);
570 570
 		$result = json_decode($data);
571 571
 		if (isset($result->query->search[0]->title)) {
572 572
 			$fileo = $result->query->search[0]->title;
573
-			if (substr($fileo,-3) == 'pdf') return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
573
+			if (substr($fileo, -3) == 'pdf') return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
574 574
 			$file = urlencode($fileo);
575 575
 			$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;
576 576
 			$data2 = $Common->getData($url2);
@@ -595,11 +595,11 @@  discard block
 block discarded – undo
595 595
 				if (isset($result2->query->pages)) {
596 596
 					foreach ($result2->query->pages as $page) {
597 597
 						if (isset($page->imageinfo[0]->extmetadata->Artist)) {
598
-							$image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
598
+							$image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
599 599
 							if (isset($page->imageinfo[0]->extmetadata->License->value)) {
600 600
 								$image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')';
601 601
 							}
602
-							$image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright']));
602
+							$image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright']));
603 603
 							return $image_url;
604 604
 						}
605 605
 					}
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 				return $image_url;
608 608
 			}
609 609
 		}
610
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
610
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
611 611
 	}
612 612
 
613 613
 	/**
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 	* @return array the aircraft thumbnail, orignal url and copyright
619 619
 	*
620 620
 	*/
621
-	public function fromCustomSource($type,$registration,$name='') {
621
+	public function fromCustomSource($type, $registration, $name = '') {
622 622
 		global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug;
623 623
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
624 624
 		if (!empty($globalAircraftImageCustomSources) && $type == 'aircraft') {
@@ -635,15 +635,15 @@  discard block
 block discarded – undo
635 635
 					print_r($source);
636 636
 					print_r($customsources);
637 637
 				}
638
-				$url = str_replace('{registration}',$registration,$source['original']);
639
-				$url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']);
638
+				$url = str_replace('{registration}', $registration, $source['original']);
639
+				$url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']);
640 640
 				if ($Common->urlexist($url)) {
641 641
 					$image_url = array();
642 642
 					$image_url['thumbnail'] = $url_thumbnail;
643 643
 					$image_url['original'] = $url;
644 644
 					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
645 645
 					else $exifCopyright = '';
646
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
646
+					if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright;
647 647
 					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
648 648
 					else $image_url['copyright'] = $source['source_website'];
649 649
 					$image_url['source_website'] = $source['source_website'];
@@ -651,8 +651,8 @@  discard block
 block discarded – undo
651 651
 					return $image_url;
652 652
 				}
653 653
 			}
654
-			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
655
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
654
+			return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
655
+		} else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
656 656
 
657 657
 		if (!empty($globalMarineImageCustomSources) && $type == 'marine') {
658 658
 			$customsources = array();
@@ -668,19 +668,19 @@  discard block
 block discarded – undo
668 668
 					print_r($source);
669 669
 					print_r($customsources);
670 670
 				}
671
-				$url = str_replace('{registration}',$registration,$source['original']);
672
-				$url = str_replace('{mmsi}',$registration,$url);
673
-				$url = str_replace('{name}',$name,$url);
674
-				$url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']);
675
-				$url_thumbnail = str_replace('{mmsi}',$registration,$url_thumbnail);
676
-				$url_thumbnail = str_replace('{name}',$name,$url_thumbnail);
671
+				$url = str_replace('{registration}', $registration, $source['original']);
672
+				$url = str_replace('{mmsi}', $registration, $url);
673
+				$url = str_replace('{name}', $name, $url);
674
+				$url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']);
675
+				$url_thumbnail = str_replace('{mmsi}', $registration, $url_thumbnail);
676
+				$url_thumbnail = str_replace('{name}', $name, $url_thumbnail);
677 677
 				if ($Common->urlexist($url)) {
678 678
 					$image_url = array();
679 679
 					$image_url['thumbnail'] = $url_thumbnail;
680 680
 					$image_url['original'] = $url;
681 681
 					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
682 682
 					else $exifCopyright = '';
683
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
683
+					if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright;
684 684
 					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
685 685
 					else $image_url['copyright'] = $source['source_website'];
686 686
 					$image_url['source_website'] = $source['source_website'];
Please login to merge, or discard this patch.
Braces   +223 added lines, -82 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@  discard block
 block discarded – undo
19 19
 	public function __construct($dbc = null) {
20 20
 		$Connection = new Connection($dbc);
21 21
 		$this->db = $Connection->db();
22
-		if ($this->db === null) die('Error: No DB connection. (Image)');
22
+		if ($this->db === null) {
23
+			die('Error: No DB connection. (Image)');
24
+		}
23 25
 	}
24 26
 
25 27
     /**
@@ -36,7 +38,9 @@  discard block
 block discarded – undo
36 38
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
37 39
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
38 40
 		$reg = $registration;
39
-		if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao;
41
+		if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') {
42
+			$reg = $aircraft_icao.$airline_icao;
43
+		}
40 44
 		$reg = trim($reg);
41 45
 		$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 
42 46
 			FROM spotter_image 
@@ -44,9 +48,13 @@  discard block
 block discarded – undo
44 48
 		$sth = $this->db->prepare($query);
45 49
 		$sth->execute(array(':registration' => $reg));
46 50
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
47
-		if (!empty($result)) return $result;
48
-		elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
49
-		else return array();
51
+		if (!empty($result)) {
52
+			return $result;
53
+		} elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) {
54
+			return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
55
+		} else {
56
+			return array();
57
+		}
50 58
 	}
51 59
 
52 60
     /**
@@ -74,7 +82,9 @@  discard block
 block discarded – undo
74 82
 			}
75 83
 		}
76 84
 		$name = trim($name);
77
-		if ($mmsi == '' && $imo == '' && $name == '') return array();
85
+		if ($mmsi == '' && $imo == '' && $name == '') {
86
+			return array();
87
+		}
78 88
 		$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 
79 89
 			FROM marine_image 
80 90
 			WHERE marine_image.mmsi = :mmsi";
@@ -103,8 +113,11 @@  discard block
 block discarded – undo
103 113
 	public function getExifCopyright($url) {
104 114
 		$exif = exif_read_data($url);
105 115
 		$copyright = '';
106
-		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
107
-		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
116
+		if (isset($exif['COMPUTED']['copyright'])) {
117
+			$copyright = $exif['COMPUTED']['copyright'];
118
+		} elseif (isset($exif['copyright'])) {
119
+			$copyright = $exif['copyright'];
120
+		}
108 121
 		if ($copyright != '') {
109 122
 			$copyright = str_replace('Copyright ','',$copyright);
110 123
 			$copyright = str_replace('© ','',$copyright);
@@ -124,17 +137,27 @@  discard block
 block discarded – undo
124 137
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
125 138
 	{
126 139
 		global $globalDebug,$globalAircraftImageFetch, $globalOffline;
127
-		if ((isset($globalAircraftImageFetch) && $globalAircraftImageFetch === FALSE) || (isset($globalOffline) && $globalOffline === TRUE)) return '';
140
+		if ((isset($globalAircraftImageFetch) && $globalAircraftImageFetch === FALSE) || (isset($globalOffline) && $globalOffline === TRUE)) {
141
+			return '';
142
+		}
128 143
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
129 144
 		$registration = trim($registration);
130 145
 		//getting the aircraft image
131
-		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
132
-		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
133
-		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
146
+		if ($globalDebug && $registration != '') {
147
+			echo 'Try to find an aircraft image for '.$registration.'...';
148
+		} elseif ($globalDebug && $aircraft_icao != '') {
149
+			echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
150
+		} elseif ($globalDebug && $airline_icao != '') {
151
+			echo 'Try to find an aircraft image for '.$airline_icao.'...';
152
+		}
134 153
 		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
135
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
154
+		if ($registration == '' && $aircraft_icao != '') {
155
+			$registration = $aircraft_icao.$airline_icao;
156
+		}
136 157
 		if ($image_url['original'] != '') {
137
-			if ($globalDebug) echo 'Found !'."\n";
158
+			if ($globalDebug) {
159
+				echo 'Found !'."\n";
160
+			}
138 161
 			$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)";
139 162
 			try {
140 163
 				$sth = $this->db->prepare($query);
@@ -143,7 +166,9 @@  discard block
 block discarded – undo
143 166
 				echo $e->getMessage()."\n";
144 167
 				return "error";
145 168
 			}
146
-		} elseif ($globalDebug) echo "Not found :'(\n";
169
+		} elseif ($globalDebug) {
170
+			echo "Not found :'(\n";
171
+		}
147 172
 		return "success";
148 173
 	}
149 174
 
@@ -158,7 +183,9 @@  discard block
 block discarded – undo
158 183
 	public function addMarineImage($mmsi,$imo = '',$name = '')
159 184
 	{
160 185
 		global $globalDebug,$globalMarineImageFetch, $globalOffline;
161
-		if ((isset($globalMarineImageFetch) && !$globalMarineImageFetch) || (isset($globalOffline) && $globalOffline === TRUE)) return '';
186
+		if ((isset($globalMarineImageFetch) && !$globalMarineImageFetch) || (isset($globalOffline) && $globalOffline === TRUE)) {
187
+			return '';
188
+		}
162 189
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
163 190
 		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
164 191
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
@@ -168,16 +195,22 @@  discard block
 block discarded – undo
168 195
 			$identity = $Marine->getIdentity($mmsi);
169 196
 			if (isset($identity[0]['mmsi'])) {
170 197
 				$imo = $identity[0]['imo'];
171
-				if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name'];
198
+				if ($identity[0]['ship_name'] != '') {
199
+					$name = $identity[0]['ship_name'];
200
+				}
172 201
 			}
173 202
 		}
174 203
 		unset($Marine);
175 204
 
176 205
 		//getting the aircraft image
177
-		if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...';
206
+		if ($globalDebug && $name != '') {
207
+			echo 'Try to find an vessel image for '.$name.'...';
208
+		}
178 209
 		$image_url = $this->findMarineImage($mmsi,$imo,$name);
179 210
 		if ($image_url['original'] != '') {
180
-			if ($globalDebug) echo 'Found !'."\n";
211
+			if ($globalDebug) {
212
+				echo 'Found !'."\n";
213
+			}
181 214
 			$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)";
182 215
 			try {
183 216
 				$sth = $this->db->prepare($query);
@@ -186,7 +219,9 @@  discard block
 block discarded – undo
186 219
 				echo $e->getMessage()."\n";
187 220
 				return "error";
188 221
 			}
189
-		} elseif ($globalDebug) echo "Not found :'(\n";
222
+		} elseif ($globalDebug) {
223
+			echo "Not found :'(\n";
224
+		}
190 225
 		return "success";
191 226
 	}
192 227
 
@@ -202,41 +237,85 @@  discard block
 block discarded – undo
202 237
 	{
203 238
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
204 239
 		$Spotter = new Spotter($this->db);
205
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
240
+		if (!isset($globalIVAO)) {
241
+			$globalIVAO = FALSE;
242
+		}
206 243
 		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
207 244
 		if ($aircraft_registration != '' && $aircraft_registration != 'NA' && (!isset($globalVA) || $globalVA !== TRUE)) {
208
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
245
+			if (strpos($aircraft_registration,'/') !== false) {
246
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
247
+			}
209 248
 			$aircraft_registration = urlencode(trim($aircraft_registration));
210 249
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
211
-			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
212
-			else $aircraft_name = '';
213
-			if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao'];
214
-			else $aircraft_icao = '';
215
-			if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao'];
216
-			else $airline_icao = '';
250
+			if (isset($aircraft_info[0]['aircraft_name'])) {
251
+				$aircraft_name = $aircraft_info[0]['aircraft_name'];
252
+			} else {
253
+				$aircraft_name = '';
254
+			}
255
+			if (isset($aircraft_info[0]['aircraft_icao'])) {
256
+				$aircraft_name = $aircraft_info[0]['aircraft_icao'];
257
+			} else {
258
+				$aircraft_icao = '';
259
+			}
260
+			if (isset($aircraft_info[0]['airline_icao'])) {
261
+				$airline_icao = $aircraft_info[0]['airline_icao'];
262
+			} else {
263
+				$airline_icao = '';
264
+			}
217 265
 		} elseif ($aircraft_icao != '') {
218 266
 			$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao);
219
-			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
220
-			else $aircraft_name = '';
267
+			if (isset($aircraft_info[0]['type'])) {
268
+				$aircraft_name = $aircraft_info[0]['type'];
269
+			} else {
270
+				$aircraft_name = '';
271
+			}
221 272
 			$aircraft_registration = $aircraft_icao;
222
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
273
+		} else {
274
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
275
+		}
223 276
 		unset($Spotter);
224
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
277
+		if (!isset($globalAircraftImageSources)) {
278
+			$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
279
+		}
225 280
 		foreach ($globalAircraftImageSources as $source) {
226 281
 			$source = strtolower($source);
227
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
228
-			if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
229
-			if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
230
-			if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
231
-			if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
232
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
233
-			if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
234
-			if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
235
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
236
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
237
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
238
-		}
239
-		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
282
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') {
283
+				$images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
284
+			}
285
+			if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) {
286
+				$images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
287
+			}
288
+			if ($source == 'flickr' && extension_loaded('simplexml')) {
289
+				$images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
290
+			}
291
+			if ($source == 'bing') {
292
+				$images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
293
+			}
294
+			if ($source == 'deviantart' && extension_loaded('simplexml')) {
295
+				$images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
296
+			}
297
+			if ($source == 'wikimedia') {
298
+				$images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
299
+			}
300
+			if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) {
301
+				$images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
302
+			}
303
+			if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) {
304
+				$images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
305
+			}
306
+			if ($source == 'airportdata' && !$globalIVAO) {
307
+				$images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
308
+			}
309
+			if ($source == 'customsources') {
310
+				$images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
311
+			}
312
+			if (isset($images_array) && $images_array['original'] != '') {
313
+				return $images_array;
314
+			}
315
+		}
316
+		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) {
317
+			return $this->findAircraftImage($aircraft_icao);
318
+		}
240 319
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
241 320
 	}
242 321
 
@@ -256,7 +335,9 @@  discard block
 block discarded – undo
256 335
 		//$imo = filter_var($imo,FILTER_SANITIZE_STRING);
257 336
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
258 337
 		$name = trim($name);
259
-		if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
338
+		if (strlen($name) < 4) {
339
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
340
+		}
260 341
 		/*
261 342
 		$Marine = new Marine($this->db);
262 343
 		if ($imo == '' || $name == '') {
@@ -268,15 +349,29 @@  discard block
 block discarded – undo
268 349
 		}
269 350
 		unset($Marine);
270 351
 		*/
271
-		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
352
+		if (!isset($globalMarineImageSources)) {
353
+			$globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
354
+		}
272 355
 		foreach ($globalMarineImageSources as $source) {
273 356
 			$source = strtolower($source);
274
-			if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name);
275
-			if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name);
276
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name);
277
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name);
278
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name);
279
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
357
+			if ($source == 'flickr') {
358
+				$images_array = $this->fromFlickr('marine',$mmsi,$name);
359
+			}
360
+			if ($source == 'bing') {
361
+				$images_array = $this->fromBing('marine',$mmsi,$name);
362
+			}
363
+			if ($source == 'deviantart') {
364
+				$images_array = $this->fromDeviantart('marine',$mmsi,$name);
365
+			}
366
+			if ($source == 'wikimedia') {
367
+				$images_array = $this->fromWikimedia('marine',$mmsi,$name);
368
+			}
369
+			if ($source == 'customsources') {
370
+				$images_array = $this->fromCustomSource('marine',$mmsi,$name);
371
+			}
372
+			if (isset($images_array) && $images_array['original'] != '') {
373
+				return $images_array;
374
+			}
280 375
 		}
281 376
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
282 377
 	}
@@ -299,7 +394,9 @@  discard block
 block discarded – undo
299 394
 			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
300 395
 		}
301 396
 		$data = $Common->getData($url);
302
-		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
397
+		if (substr($data, 0, 5) != "<?xml") {
398
+			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
399
+		}
303 400
 		if ($xml = simplexml_load_string($data)) {
304 401
 			if (isset($xml->channel->item)) {
305 402
 				$image_url = array();
@@ -338,7 +435,9 @@  discard block
 block discarded – undo
338 435
 			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"';
339 436
 		}
340 437
 		$data = $Common->getData($url);
341
-		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
438
+		if (substr($data, 0, 5) != "<?xml") {
439
+			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
440
+		}
342 441
 		if ($xml = simplexml_load_string($data)) {
343 442
 			if (isset($xml->channel->item->link)) {
344 443
 				$image_url = array();
@@ -442,14 +541,22 @@  discard block
 block discarded – undo
442 541
 	public function fromFlickr($type,$registration,$name='') {
443 542
 		$Common = new Common();
444 543
 		if ($type == 'aircraft') {
445
-			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);
446
-			else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft';
544
+			if ($name != '') {
545
+				$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);
546
+			} else {
547
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft';
548
+			}
447 549
 		} elseif ($type == 'marine') {
448
-			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name);
449
-			else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship';
550
+			if ($name != '') {
551
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name);
552
+			} else {
553
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship';
554
+			}
450 555
 		}
451 556
 		$data = $Common->getData($url);
452
-		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
557
+		if (substr($data, 0, 5) != "<?xml") {
558
+			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
559
+		}
453 560
 		if ($xml = simplexml_load_string($data)) {
454 561
 			if (isset($xml->channel->item)) {
455 562
 				$original_url = trim((string)$xml->channel->item->enclosure->attributes()->url);
@@ -498,13 +605,21 @@  discard block
 block discarded – undo
498 605
 	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
499 606
 		global $globalImageBingKey;
500 607
 		$Common = new Common();
501
-		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
608
+		if (!isset($globalImageBingKey) || $globalImageBingKey == '') {
609
+			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
610
+		}
502 611
 		if ($type == 'aircraft') {
503
-			if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
504
-			else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
612
+			if ($aircraft_name != '') {
613
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
614
+			} else {
615
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
616
+			}
505 617
 		} elseif ($type == 'marine') {
506
-			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';
507
-			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';
618
+			if ($aircraft_name != '') {
619
+				$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';
620
+			} else {
621
+				$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';
622
+			}
508 623
 		}
509 624
 		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
510 625
 		$data = $Common->getData($url,'get','',$headers);
@@ -560,17 +675,25 @@  discard block
 block discarded – undo
560 675
 	public function fromWikimedia($type,$registration,$name='') {
561 676
 		$Common = new Common();
562 677
 		if ($type == 'aircraft') {
563
-			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);
564
-			else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
678
+			if ($name != '') {
679
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
680
+			} else {
681
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
682
+			}
565 683
 		} elseif ($type == 'marine') {
566
-			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"';
567
-			else return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
684
+			if ($name != '') {
685
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"';
686
+			} else {
687
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
688
+			}
568 689
 		}
569 690
 		$data = $Common->getData($url);
570 691
 		$result = json_decode($data);
571 692
 		if (isset($result->query->search[0]->title)) {
572 693
 			$fileo = $result->query->search[0]->title;
573
-			if (substr($fileo,-3) == 'pdf') return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
694
+			if (substr($fileo,-3) == 'pdf') {
695
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
696
+			}
574 697
 			$file = urlencode($fileo);
575 698
 			$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;
576 699
 			$data2 = $Common->getData($url2);
@@ -641,18 +764,27 @@  discard block
 block discarded – undo
641 764
 					$image_url = array();
642 765
 					$image_url['thumbnail'] = $url_thumbnail;
643 766
 					$image_url['original'] = $url;
644
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
645
-					else $exifCopyright = '';
646
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
647
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
648
-					else $image_url['copyright'] = $source['source_website'];
767
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
768
+						$exifCopyright = $this->getExifCopyright($url);
769
+					} else {
770
+						$exifCopyright = '';
771
+					}
772
+					if ($exifCopyright  != '') {
773
+						$image_url['copyright'] = $exifCopyright;
774
+					} elseif (isset($source['copyright'])) {
775
+						$image_url['copyright'] = $source['copyright'];
776
+					} else {
777
+						$image_url['copyright'] = $source['source_website'];
778
+					}
649 779
 					$image_url['source_website'] = $source['source_website'];
650 780
 					$image_url['source'] = $source['source'];
651 781
 					return $image_url;
652 782
 				}
653 783
 			}
654 784
 			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
655
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
785
+		} else {
786
+			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
787
+		}
656 788
 
657 789
 		if (!empty($globalMarineImageCustomSources) && $type == 'marine') {
658 790
 			$customsources = array();
@@ -678,18 +810,27 @@  discard block
 block discarded – undo
678 810
 					$image_url = array();
679 811
 					$image_url['thumbnail'] = $url_thumbnail;
680 812
 					$image_url['original'] = $url;
681
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
682
-					else $exifCopyright = '';
683
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
684
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
685
-					else $image_url['copyright'] = $source['source_website'];
813
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
814
+						$exifCopyright = $this->getExifCopyright($url);
815
+					} else {
816
+						$exifCopyright = '';
817
+					}
818
+					if ($exifCopyright  != '') {
819
+						$image_url['copyright'] = $exifCopyright;
820
+					} elseif (isset($source['copyright'])) {
821
+						$image_url['copyright'] = $source['copyright'];
822
+					} else {
823
+						$image_url['copyright'] = $source['source_website'];
824
+					}
686 825
 					$image_url['source_website'] = $source['source_website'];
687 826
 					$image_url['source'] = $source['source'];
688 827
 					return $image_url;
689 828
 				}
690 829
 			}
691 830
 			return false;
692
-		} else return false;
831
+		} else {
832
+			return false;
833
+		}
693 834
 	}
694 835
 }
695 836
 
Please login to merge, or discard this patch.